diff --git a/Application/FileConverter/Windows/SettingsWindow.xaml b/Application/FileConverter/Windows/SettingsWindow.xaml index 791f89c..b418de3 100644 --- a/Application/FileConverter/Windows/SettingsWindow.xaml +++ b/Application/FileConverter/Windows/SettingsWindow.xaml @@ -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"> diff --git a/Application/FileConverter/Windows/SettingsWindow.xaml.cs b/Application/FileConverter/Windows/SettingsWindow.xaml.cs index be2a439..6895c07 100644 --- a/Application/FileConverter/Windows/SettingsWindow.xaml.cs +++ b/Application/FileConverter/Windows/SettingsWindow.xaml.cs @@ -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()); + } } }