diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml index 3ce56cf922..e6598b2e2d 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -11,8 +11,15 @@ Title="{DynamicResource wox_settings}" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" - Height="600" Width="800" PreviewKeyDown="Window_PreviewKeyDown" + Height="600" Width="800" + Closed="OnClosed" d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}"> + + + + + + diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index ee4e595972..c022d7286b 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -309,15 +309,6 @@ namespace Wox #endregion - private void Window_PreviewKeyDown(object sender, KeyEventArgs e) - { - // Hide window with ESC, but make sure it is not pressed as a hotkey - if (e.Key == Key.Escape && !HotkeyControl.IsFocused) - { - Close(); - } - } - private async void OnCheckUpdates(object sender, RoutedEventArgs e) { var version = await Updater.NewVersion(); @@ -338,5 +329,15 @@ namespace Wox Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); e.Handled = true; } + + private void OnClosed(object sender, EventArgs e) + { + _viewModel.Save(); + } + + private void OnCloseExecuted(object sender, ExecutedRoutedEventArgs e) + { + Close(); + } } } diff --git a/Wox/ViewModel/SettingWindowViewModel.cs b/Wox/ViewModel/SettingWindowViewModel.cs index fb74005c9c..4a9c1b1a71 100644 --- a/Wox/ViewModel/SettingWindowViewModel.cs +++ b/Wox/ViewModel/SettingWindowViewModel.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Windows; using System.Windows.Controls; +using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using PropertyChanged; @@ -32,7 +33,6 @@ namespace Wox.ViewModel public Settings Settings { get; set; } - //todo happlebao save public void Save() { _storage.Save();