diff --git a/App.config b/App.config index fb0c1f3..0a2370c 100644 --- a/App.config +++ b/App.config @@ -2,11 +2,15 @@ - + + - + + + + \ No newline at end of file diff --git a/App.xaml b/App.xaml index 5041b34..5ca23ca 100644 --- a/App.xaml +++ b/App.xaml @@ -22,7 +22,7 @@ - + diff --git a/App.xaml.cs b/App.xaml.cs index dfdc8cf..3b34256 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.Configuration; using System.Diagnostics; using System.IO; using System.Security.Principal; @@ -53,6 +54,17 @@ namespace ShanghaiEnvironmentalTechnology RestartAsAdmin(); Shutdown(); } + + // 加载保存的语言 + string savedLanguage = ConfigurationManager.AppSettings["Language"] ?? "zh-CN"; + var resourceDict = new ResourceDictionary + { + Source = new Uri($"/Resources/Strings.{savedLanguage}.xaml", UriKind.Relative) + }; + + Current.Resources.MergedDictionaries.Clear(); + Current.Resources.MergedDictionaries.Add(resourceDict); + } private bool IsRunAsAdmin() diff --git a/Main.xaml b/Main.xaml index cd64874..28ec7f5 100644 --- a/Main.xaml +++ b/Main.xaml @@ -1,14 +1,51 @@  - + Title="{DynamicResource WindowTitle}" + Height="768" Width="1024" Loaded="Window_Loaded" WindowStartupLocation="CenterScreen"> + + + + + + + + + + + 中文 + English + + + -