Skip to content

Commit

Permalink
Added close confirmation dialog if user is in middle of compile
Browse files Browse the repository at this point in the history
  • Loading branch information
Exactol committed Feb 7, 2021
1 parent f701863 commit 40484c6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CompilePalX/Compiling/CompilingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static void CompilePalLogger_OnErrorFound(Error e)
private static Thread compileThread;
private static Stopwatch compileTimeStopwatch = new Stopwatch();

private static bool IsCompiling;
public static bool IsCompiling { get; private set; }

public static void ToggleCompileState()
{
Expand Down
13 changes: 8 additions & 5 deletions CompilePalX/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"

Title="Compile Pal X"
MinHeight="550" MinWidth="790"
Height="550" Width="790"
Closing="MetroWindow_Closing"
IconEdgeMode="Aliased" Icon="CompilePalIcon.ico" ShowIconOnTitleBar="False"
Activated="MetroWindow_Activated" BorderThickness="1" BorderBrush="{DynamicResource AccentColorBrush}" >
MinHeight="550" MinWidth="790"
Height="550" Width="790"
Closing="MetroWindow_Closing"
IconEdgeMode="Aliased" Icon="CompilePalIcon.ico" ShowIconOnTitleBar="False"
Activated="MetroWindow_Activated"
BorderThickness="1"
BorderBrush="{DynamicResource AccentColorBrush}"
>

<controls:MetroWindow.LeftWindowCommands>
<controls:WindowCommands>
Expand Down
11 changes: 11 additions & 0 deletions CompilePalX/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,17 @@ private void RemovePresetButton_Click(object sender, RoutedEventArgs e)

private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// prevent users from accidentally closing during a compile
if (CompilingManager.IsCompiling)
{
MessageBoxResult cancelBoxResult = MessageBox.Show("Compile in progress, are you sure you want to cancel?", "Cancel Confirmation", System.Windows.MessageBoxButton.YesNo);
if (cancelBoxResult != MessageBoxResult.Yes)
{
e.Cancel = true;
return;
}
}

ConfigurationManager.SavePresets();
ConfigurationManager.SaveProcesses();

Expand Down

0 comments on commit 40484c6

Please sign in to comment.