Fixed: Close window don't terminate application.

This commit is contained in:
Adrien Allard committed 2015-08-22 15:55:30 +02:00
1 parent 5db9c09cff
commit 3e7c7a4a30
2 files changed
+21 -8

No files matched your search

@@ -5,7 +5,8 @@
xmlns:valueConverters="clr-namespace:FileConverter.ValueConverters"
xmlns:generic="clr-namespace:FileConverter.ValueConverters.Generic"
Height="500" Width="700" MinHeight="370" MinWidth="440"
WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon-16x16.ico">
WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon-16x16.ico"
Closing="SettingsWindow_OnClosing">
<Window.Resources>
<generic:BoolToVisibility x:Key="BoolToVisibility"/>
<valueConverters:InputTypesToBool x:Key="InputTypesToBool"/>
@@ -98,13 +98,7 @@ namespace FileConverter
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
// Load previous preset in order to cancel changes.
Application application = Application.Current as Application;
application.Settings.Load();
this.Hide();
this.OnSettingsWindowHide?.Invoke(this, new EventArgs());
this.HideSettingsWindow();
}
private void SaveButton_Click(object sender, RoutedEventArgs e)
@@ -171,5 +165,23 @@ namespace FileConverter
this.SelectedPreset?.SetSettingsValue("Bitrate", bitrateValue.ToString("0"));
}
private void SettingsWindow_OnClosing(object sender, CancelEventArgs e)
{
e.Cancel = true;
this.HideSettingsWindow();
}
private void HideSettingsWindow()
{
// Load previous preset in order to cancel changes.
Application application = Application.Current as Application;
application.Settings.Load();
this.Hide();
this.OnSettingsWindowHide?.Invoke(this, new EventArgs());
}
}
}