diff --git a/Consts/SettingsMultilangConst.zh.resx b/Consts/SettingsMultilangConst.zh.resx
index b5df3c1..4fa03e9 100644
--- a/Consts/SettingsMultilangConst.zh.resx
+++ b/Consts/SettingsMultilangConst.zh.resx
@@ -98,13 +98,13 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- 跟随系统
+ 亮色模式
暗色模式
- 亮色模式
+ 跟随系统
点击切换显示主题
diff --git a/Preses/GlobalPres.cs b/Preses/GlobalPres.cs
index c02deb0..e8fdf70 100644
--- a/Preses/GlobalPres.cs
+++ b/Preses/GlobalPres.cs
@@ -1,12 +1,25 @@
-using System.Windows;
+using System.Diagnostics;
+using System.Windows;
using CommunityToolkit.Mvvm.ComponentModel;
using MaterialDesignThemes.Wpf;
+using Sheas_Cealer.Props;
using Sheas_Cealer.Utils;
namespace Sheas_Cealer.Preses;
internal partial class GlobalPres : ObservableObject
{
+ internal GlobalPres()
+ {
+ IsLightTheme = Settings.Default.IsLightTheme switch
+ {
+ -1 => null,
+ 0 => false,
+ 1 => true,
+ _ => throw new UnreachableException()
+ };
+ }
+
[ObservableProperty]
private static bool? isLightTheme = null;
partial void OnIsLightThemeChanged(bool? value)
@@ -19,5 +32,8 @@ internal partial class GlobalPres : ObservableObject
foreach (Window currentWindow in Application.Current.Windows)
BorderThemeSetter.SetBorderTheme(currentWindow, value);
+
+ Settings.Default.IsLightTheme = (sbyte)(value.HasValue ? value.GetValueOrDefault() ? 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 4166d68..2de53ce 100644
--- a/Props/Settings.Designer.cs
+++ b/Props/Settings.Designer.cs
@@ -12,7 +12,7 @@ namespace Sheas_Cealer.Props {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.12.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -58,5 +58,17 @@ namespace Sheas_Cealer.Props {
this["ExtraArgs"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("-1")]
+ public sbyte IsLightTheme {
+ get {
+ return ((sbyte)(this["IsLightTheme"]));
+ }
+ set {
+ this["IsLightTheme"] = value;
+ }
+ }
}
}
diff --git a/Props/Settings.settings b/Props/Settings.settings
index ae75391..61b1d77 100644
--- a/Props/Settings.settings
+++ b/Props/Settings.settings
@@ -11,5 +11,8 @@
+
+ -1
+
\ No newline at end of file
diff --git a/Utils/BorderThemeSetter.cs b/Utils/BorderThemeSetter.cs
index 80d7bdf..0e017df 100644
--- a/Utils/BorderThemeSetter.cs
+++ b/Utils/BorderThemeSetter.cs
@@ -16,6 +16,9 @@ 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();