diff --git a/STranslate/View/MainWindow.xaml b/STranslate/View/MainWindow.xaml index da0ed64..612c4fa 100644 --- a/STranslate/View/MainWindow.xaml +++ b/STranslate/View/MainWindow.xaml @@ -17,6 +17,7 @@ ResizeMode="NoResize" Topmost="True" Deactivated="Window_Deactivated" + Closing="Mwin_Closing" WindowStyle="None" SizeToContent="Height" Width="400" diff --git a/STranslate/View/MainWindow.xaml.cs b/STranslate/View/MainWindow.xaml.cs index 379851e..a48f4ba 100644 --- a/STranslate/View/MainWindow.xaml.cs +++ b/STranslate/View/MainWindow.xaml.cs @@ -79,5 +79,10 @@ namespace STranslate.View this.Hide(); } } + + private void Mwin_Closing(object sender, System.ComponentModel.CancelEventArgs e) + { + HotkeysHelper.UnRegisterHotKey(); + } } } \ No newline at end of file diff --git a/STranslate/ViewModel/MainVM.cs b/STranslate/ViewModel/MainVM.cs index 6de1dd6..5cda315 100644 --- a/STranslate/ViewModel/MainVM.cs +++ b/STranslate/ViewModel/MainVM.cs @@ -209,20 +209,20 @@ namespace STranslate.ViewModel { try { - GlobalConfig = ConfigHelper.Instance.ReadConfig(); + _GlobalConfig = ConfigHelper.Instance.ReadConfig(); //配置读取主题 - Application.Current.Resources.MergedDictionaries[0].Source = GlobalConfig.IsBright ? new Uri(_ThemeDefault) : new Uri(_ThemeDark); + Application.Current.Resources.MergedDictionaries[0].Source = _GlobalConfig.IsBright ? new Uri(_ThemeDefault) : new Uri(_ThemeDark); //更新服务 - TranslationInterface = GlobalConfig.Servers.ToList(); + TranslationInterface = _GlobalConfig.Servers.ToList(); if (TranslationInterface.Count < 1) throw new Exception("尚未配置任何翻译接口服务"); try { //配置读取接口 - SelectedTranslationInterface = TranslationInterface[GlobalConfig.SelectServer]; + SelectedTranslationInterface = TranslationInterface[_GlobalConfig.SelectServer]; } catch (Exception ex) { @@ -230,8 +230,8 @@ namespace STranslate.ViewModel } //从配置读取source target - InputComboSelected = GlobalConfig.SourceLanguage; - OutputComboSelected = GlobalConfig.TargetLanguage; + InputComboSelected = _GlobalConfig.SourceLanguage; + OutputComboSelected = _GlobalConfig.TargetLanguage; return true; } @@ -251,7 +251,7 @@ namespace STranslate.ViewModel SourceLanguage = InputComboSelected, TargetLanguage = OutputComboSelected, SelectServer = TranslationInterface.FindIndex(x => x == SelectedTranslationInterface), - Servers = GlobalConfig.Servers, + Servers = _GlobalConfig.Servers, }); } catch (Exception ex) @@ -401,7 +401,7 @@ namespace STranslate.ViewModel /// /// 全局配置文件 /// - public ConfigModel GlobalConfig; + private ConfigModel _GlobalConfig; /// /// 识别语种