diff --git a/App.xaml.cs b/App.xaml.cs
index 28c0f82..e47a33a 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -1,12 +1,17 @@
using System.Windows;
using System.Windows.Threading;
+using Sheas_Cealer.Preses;
using Sheas_Cealer.Wins;
namespace Sheas_Cealer;
public partial class App : Application
{
- protected override void OnStartup(StartupEventArgs e) => new MainWin(e.Args).Show();
+ protected override void OnStartup(StartupEventArgs e)
+ {
+ _ = new SettingsPres();
+ new MainWin(e.Args).Show();
+ }
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
diff --git a/Consts/SettingsMultilangConst.Designer.cs b/Consts/SettingsMultilangConst.Designer.cs
index bf8aeb6..53a59b4 100644
--- a/Consts/SettingsMultilangConst.Designer.cs
+++ b/Consts/SettingsMultilangConst.Designer.cs
@@ -61,7 +61,52 @@ namespace Sheas_Cealer.Consts {
}
///
- /// 查找类似 Auto Theme 的本地化字符串。
+ /// 查找类似 Change successfuly, restart to refresh the windows 的本地化字符串。
+ ///
+ public static string _ChangeLangSuccessMsg {
+ get {
+ return ResourceManager.GetString("_ChangeLangSuccessMsg", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Switch Lang (中文 → En) 的本地化字符串。
+ ///
+ public static string LangsButtonChineseLangContent {
+ get {
+ return ResourceManager.GetString("LangsButtonChineseLangContent", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Switch Lang (En → Auto) 的本地化字符串。
+ ///
+ public static string LangsButtonEnglishLangContent {
+ get {
+ return ResourceManager.GetString("LangsButtonEnglishLangContent", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Switch Lang (Auto → 中文) 的本地化字符串。
+ ///
+ public static string LangsButtonInheritLangContent {
+ get {
+ return ResourceManager.GetString("LangsButtonInheritLangContent", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 点击切换界面语言 的本地化字符串。
+ ///
+ public static string LangsButtonToolTip {
+ get {
+ return ResourceManager.GetString("LangsButtonToolTip", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Switch Theme (Dark → Light) 的本地化字符串。
///
public static string ThemesButtonDarkThemeContent {
get {
@@ -70,7 +115,7 @@ namespace Sheas_Cealer.Consts {
}
///
- /// 查找类似 Dark Theme 的本地化字符串。
+ /// 查找类似 Switch Theme (Auto → Dark) 的本地化字符串。
///
public static string ThemesButtonInheritThemeContent {
get {
@@ -79,7 +124,7 @@ namespace Sheas_Cealer.Consts {
}
///
- /// 查找类似 Light Theme 的本地化字符串。
+ /// 查找类似 Switch Theme (Light → Auto) 的本地化字符串。
///
public static string ThemesButtonLightThemeContent {
get {
diff --git a/Consts/SettingsMultilangConst.resx b/Consts/SettingsMultilangConst.resx
index c227766..4ad3bd6 100644
--- a/Consts/SettingsMultilangConst.resx
+++ b/Consts/SettingsMultilangConst.resx
@@ -97,16 +97,31 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ Switch Lang (中文 → En)
+
+
+ Switch Lang (En → Auto)
+
+
+ Switch Lang (Auto → 中文)
+
+
+ 点击切换界面语言
+
- Auto Theme
+ Switch Theme (Dark → Light)
- Dark Theme
+ Switch Theme (Auto → Dark)
- Light Theme
+ Switch Theme (Light → Auto)
Click to switch themes
+
+ Change successfuly, restart to refresh the windows
+
\ No newline at end of file
diff --git a/Consts/SettingsMultilangConst.zh.resx b/Consts/SettingsMultilangConst.zh.resx
index 4fa03e9..ed8688c 100644
--- a/Consts/SettingsMultilangConst.zh.resx
+++ b/Consts/SettingsMultilangConst.zh.resx
@@ -97,16 +97,31 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 切换语言 (中文 → En)
+
+
+ 切换语言 (En → 系统)
+
+
+ 切换语言 (系统 → 中文)
+
+
+ Click to switch langs
+
- 亮色模式
+ 切换主题 (暗色 → 亮色)
- 暗色模式
+ 切换主题 (系统 → 暗色)
- 跟随系统
+ 切换主题 (亮色 → 系统)
点击切换显示主题
+
+ 语言更改完成,重启以刷新界面
+
\ No newline at end of file
diff --git a/Convs/SettingsLangsButtonContentConv.cs b/Convs/SettingsLangsButtonContentConv.cs
new file mode 100644
index 0000000..749db68
--- /dev/null
+++ b/Convs/SettingsLangsButtonContentConv.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+using Sheas_Cealer.Consts;
+
+namespace Sheas_Cealer.Convs;
+
+internal class SettingsLangsButtonContentConv : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool? isEnglishLang = value as bool?;
+
+ return isEnglishLang.HasValue ?
+ isEnglishLang.GetValueOrDefault() ? SettingsConst.LangsButtonEnglishLangContent : SettingsConst.LangsButtonChineseLangContent :
+ SettingsConst.LangsButtonInheritLangContent;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
+}
\ No newline at end of file
diff --git a/Preses/GlobalPres.cs b/Preses/GlobalPres.cs
index e8fdf70..8c00412 100644
--- a/Preses/GlobalPres.cs
+++ b/Preses/GlobalPres.cs
@@ -27,13 +27,13 @@ internal partial class GlobalPres : ObservableObject
PaletteHelper paletteHelper = new();
Theme newTheme = paletteHelper.GetTheme();
- newTheme.SetBaseTheme(value.HasValue ? value.GetValueOrDefault() ? BaseTheme.Light : BaseTheme.Dark : BaseTheme.Inherit);
+ newTheme.SetBaseTheme(value.HasValue ? value.Value ? BaseTheme.Light : BaseTheme.Dark : BaseTheme.Inherit);
paletteHelper.SetTheme(newTheme);
foreach (Window currentWindow in Application.Current.Windows)
BorderThemeSetter.SetBorderTheme(currentWindow, value);
- Settings.Default.IsLightTheme = (sbyte)(value.HasValue ? value.GetValueOrDefault() ? 1 : 0 : -1);
+ Settings.Default.IsLightTheme = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
Settings.Default.Save();
}
}
\ No newline at end of file
diff --git a/Preses/SettingsPres.cs b/Preses/SettingsPres.cs
index 9d31ee9..9223b5e 100644
--- a/Preses/SettingsPres.cs
+++ b/Preses/SettingsPres.cs
@@ -1,3 +1,38 @@
-namespace Sheas_Cealer.Preses;
+using System.Diagnostics;
+using System.Globalization;
+using System.Threading;
+using System.Windows;
+using System.Windows.Markup;
+using CommunityToolkit.Mvvm.ComponentModel;
+using Sheas_Cealer.Props;
-internal partial class SettingsPres : GlobalPres;
\ No newline at end of file
+namespace Sheas_Cealer.Preses;
+
+internal partial class SettingsPres : GlobalPres
+{
+ internal SettingsPres()
+ {
+ IsEnglishLang = Settings.Default.IsEnglishLang switch
+ {
+ -1 => null,
+ 0 => false,
+ 1 => true,
+ _ => throw new UnreachableException()
+ };
+ }
+
+ [ObservableProperty]
+ private static bool? isEnglishLang = null;
+ partial void OnIsEnglishLangChanged(bool? value)
+ {
+ CultureInfo newCulture = value.HasValue ? new(value.Value ? "en" : "zh") : CultureInfo.InstalledUICulture;
+
+ Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = newCulture;
+
+ foreach (Window currentWindow in Application.Current.Windows)
+ currentWindow.Language = XmlLanguage.GetLanguage(newCulture.IetfLanguageTag);
+
+ Settings.Default.IsEnglishLang = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
+ Settings.Default.Save();
+ }
+}
\ No newline at end of file
diff --git a/Props/Settings.Designer.cs b/Props/Settings.Designer.cs
index 2de53ce..2ec3182 100644
--- a/Props/Settings.Designer.cs
+++ b/Props/Settings.Designer.cs
@@ -70,5 +70,17 @@ namespace Sheas_Cealer.Props {
this["IsLightTheme"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("-1")]
+ public sbyte IsEnglishLang {
+ get {
+ return ((sbyte)(this["IsEnglishLang"]));
+ }
+ set {
+ this["IsEnglishLang"] = value;
+ }
+ }
}
}
diff --git a/Props/Settings.settings b/Props/Settings.settings
index 61b1d77..9a650fb 100644
--- a/Props/Settings.settings
+++ b/Props/Settings.settings
@@ -14,5 +14,8 @@
-1
+
+ -1
+
\ No newline at end of file
diff --git a/Utils/BorderThemeSetter.cs b/Utils/BorderThemeSetter.cs
index 0e017df..80d7bdf 100644
--- a/Utils/BorderThemeSetter.cs
+++ b/Utils/BorderThemeSetter.cs
@@ -16,9 +16,6 @@ internal static partial class BorderThemeSetter
internal static void SetBorderTheme(Window window, bool? isLightTheme)
{
- if (!window.IsLoaded)
- return;
-
nint isDarkTheme;
nint desktopHwnd = nint.Zero;
nint windowHwnd = new WindowInteropHelper(window).EnsureHandle();
diff --git a/Wins/MainWin.xaml.cs b/Wins/MainWin.xaml.cs
index 181b476..c5af45f 100644
--- a/Wins/MainWin.xaml.cs
+++ b/Wins/MainWin.xaml.cs
@@ -535,7 +535,6 @@ public partial class MainWin : Window
int nullSniNum = 0;
foreach (KeyValuePair cealHostDomainPairs, string? cealHostSni, string cealHostIp)>> cealHostRulesPair in CealHostRulesDict)
- {
foreach ((List<(string cealHostIncludeDomain, string cealHostExcludeDomain)> cealHostDomainPairs, string? cealHostSni, string cealHostIp) in cealHostRulesPair.Value ?? [])
{
string cealHostSniWithoutNull = cealHostSni ?? $"{cealHostRulesPair.Key}{(cealHostRulesPair.Value ?? []).Count + ++nullSniNum}";
@@ -553,7 +552,6 @@ public partial class MainWin : Window
if (isValidCealHostDomainExist)
hostResolverRules += $"MAP {cealHostSniWithoutNull} {cealHostIp},";
}
- }
CealArgs = @$"--host-rules=""{hostRules.TrimEnd(',')}"" --host-resolver-rules=""{hostResolverRules.TrimEnd(',')}"" --test-type --ignore-certificate-errors";
diff --git a/Wins/SettingsWin.xaml b/Wins/SettingsWin.xaml
index f1d68c6..d1c5a68 100644
--- a/Wins/SettingsWin.xaml
+++ b/Wins/SettingsWin.xaml
@@ -12,10 +12,11 @@
KeyDown="SettingsWin_KeyDown">
-
+
+
+
+
\ No newline at end of file
diff --git a/Wins/SettingsWin.xaml.cs b/Wins/SettingsWin.xaml.cs
index da9c0a9..6870f49 100644
--- a/Wins/SettingsWin.xaml.cs
+++ b/Wins/SettingsWin.xaml.cs
@@ -1,6 +1,7 @@
using System;
using System.Windows;
using System.Windows.Input;
+using Sheas_Cealer.Consts;
using Sheas_Cealer.Preses;
using Sheas_Cealer.Utils;
@@ -23,6 +24,12 @@ public partial class SettingsWin : Window
}
private void ThemesButton_Click(object sender, RoutedEventArgs e) => SettingsPres!.IsLightTheme = SettingsPres.IsLightTheme.HasValue ? SettingsPres.IsLightTheme.Value ? null : true : false;
+ private void LangsButton_Click(object sender, RoutedEventArgs e)
+ {
+ SettingsPres!.IsEnglishLang = SettingsPres.IsEnglishLang.HasValue ? SettingsPres.IsEnglishLang.Value ? null : true : false;
+
+ MessageBox.Show(SettingsConst._ChangeLangSuccessMsg);
+ }
private void SettingsWin_KeyDown(object sender, KeyEventArgs e)
{