Skip to content

Commit 4ed9b53

Browse files
committed
Handle non-ok result of custom command dialog
Closes #60
1 parent a40a7f2 commit 4ed9b53

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

src/ShutdownTimer/Menu.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,6 @@ private void StartButton_Click(object sender, EventArgs e)
132132
}
133133
}
134134

135-
ExceptionHandler.Log("Preparing for countdown start");
136-
startButton.Enabled = false;
137-
actionGroupBox.Enabled = false;
138-
timeGroupBox.Enabled = false;
139-
140-
SaveSettings();
141-
142135
if (actionComboBox.Text.Equals("Custom Command"))
143136
{
144137
ExceptionHandler.Log("Entering custom command setup");
@@ -148,8 +141,15 @@ private void StartButton_Click(object sender, EventArgs e)
148141
form.Message = "Please enter the command you want to have executed. If you wish to launch a file, just enter the full file path.\n\n" +
149142
"Note: Execution will use this user's permissions.";
150143
ExceptionHandler.Log("Requesting custom command from user...");
144+
151145
var result = form.ShowDialog();
152-
ExceptionHandler.Log("Saving command");
146+
if (result != DialogResult.OK)
147+
{
148+
ExceptionHandler.Log("User declined to enter custom command, aborting start.");
149+
return;
150+
}
151+
152+
ExceptionHandler.Log("Accepted command: \"" + result.ToString() + "\"");
153153
command = form.ReturnValue;
154154
}
155155
}
@@ -170,6 +170,13 @@ private void StartButton_Click(object sender, EventArgs e)
170170
}
171171
}
172172

173+
ExceptionHandler.Log("Preparing for countdown start");
174+
startButton.Enabled = false;
175+
actionGroupBox.Enabled = false;
176+
timeGroupBox.Enabled = false;
177+
178+
SaveSettings();
179+
173180
ExceptionHandler.Log("Initiaing countdown start");
174181
this.Hide();
175182
StartCountdown();

0 commit comments

Comments
 (0)