From 8a56d109fda5dbb24f857cb77b0609abe6aef385 Mon Sep 17 00:00:00 2001 From: "SONGE9B3\\song_pd_win11" Date: Tue, 3 Jan 2023 18:58:00 +0800 Subject: [PATCH] perf: add theme re/wr with config --- STranslate/ViewModel/MainVM.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/STranslate/ViewModel/MainVM.cs b/STranslate/ViewModel/MainVM.cs index c1a6696..7d38715 100644 --- a/STranslate/ViewModel/MainVM.cs +++ b/STranslate/ViewModel/MainVM.cs @@ -25,6 +25,9 @@ namespace STranslate.ViewModel Environment.Exit(-1); } + InputCombo = LanguageEnumDict.Keys.ToList(); + OutputCombo = LanguageEnumDict.Keys.ToList(); + //复制输入 CopyInputCmd = new RelayCommand((_) => true, (_) => { @@ -79,9 +82,11 @@ namespace STranslate.ViewModel { try { - InputCombo = LanguageEnumDict.Keys.ToList(); - OutputCombo = LanguageEnumDict.Keys.ToList(); GlobalConfig = ConfigHelper.Instance.ReadConfig(); + + //配置读取主题 + Application.Current.Resources.MergedDictionaries[0].Source = GlobalConfig.IsBright ? new Uri(_ThemeDefault) : new Uri(_ThemeDark); + //更新服务 TranslationInterface = GlobalConfig.Servers.ToList(); @@ -115,7 +120,7 @@ namespace STranslate.ViewModel { ConfigHelper.Instance.WriteConfig(new ConfigModel { - IsBright = true, + IsBright = Application.Current.Resources.MergedDictionaries[0].Source.ToString() == _ThemeDefault ? true : false, SourceLanguage = InputComboSelected, TargetLanguage = OutputComboSelected, SelectServer = TranslationInterface.FindIndex(x => x == SelectedTranslationInterface),