From 6d358c2bf0374c647b47b311e14bba3aaa63f221 Mon Sep 17 00:00:00 2001 From: xyy <544939200@qq.com> Date: Thu, 7 May 2026 16:51:45 +0800 Subject: [PATCH] --- App.config | 8 +- App.xaml | 2 +- App.xaml.cs | 12 ++ Main.xaml | 54 ++++++- Main.xaml.cs | 41 +++++ MainWindow.xaml | 14 +- Resources/ResourceManager.cs | 45 ++++++ Resources/Strings.en-US.xaml | 151 +++++++++++++++++ Resources/Strings.zh-CN.xaml | 153 ++++++++++++++++++ Window1.xaml | 30 ++-- Window1.xaml.cs | 128 ++++++++++----- Window2.xaml | 36 ++--- Window2.xaml.cs | 67 +++++++- Window5.xaml.cs | 84 ---------- ...proj => 睡眠呼吸暂停治疗面罩多功能测试仪.csproj | 0 睡眠多功能.sln | 6 +- 16 files changed, 648 insertions(+), 183 deletions(-) create mode 100644 Resources/ResourceManager.cs create mode 100644 Resources/Strings.en-US.xaml create mode 100644 Resources/Strings.zh-CN.xaml rename 睡眠多功能.csproj => 睡眠呼吸暂停治疗面罩多功能测试仪.csproj (100%) 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 + + + -