1.1.3 -> 1.1.4 第24次更新

This commit is contained in:
Space Time 2024-12-03 23:41:25 +08:00
parent 2e07e97e01
commit fe8f73afb8
5 changed files with 38 additions and 4 deletions

View File

@ -98,13 +98,13 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="ThemesButtonDarkThemeContent" xml:space="preserve"> <data name="ThemesButtonDarkThemeContent" xml:space="preserve">
<value>跟随系统</value> <value>亮色模式</value>
</data> </data>
<data name="ThemesButtonInheritThemeContent" xml:space="preserve"> <data name="ThemesButtonInheritThemeContent" xml:space="preserve">
<value>暗色模式</value> <value>暗色模式</value>
</data> </data>
<data name="ThemesButtonLightThemeContent" xml:space="preserve"> <data name="ThemesButtonLightThemeContent" xml:space="preserve">
<value>亮色模式</value> <value>跟随系统</value>
</data> </data>
<data name="ThemesButtonToolTip" xml:space="preserve"> <data name="ThemesButtonToolTip" xml:space="preserve">
<value>点击切换显示主题</value> <value>点击切换显示主题</value>

View File

@ -1,12 +1,25 @@
using System.Windows; using System.Diagnostics;
using System.Windows;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
using Sheas_Cealer.Props;
using Sheas_Cealer.Utils; using Sheas_Cealer.Utils;
namespace Sheas_Cealer.Preses; namespace Sheas_Cealer.Preses;
internal partial class GlobalPres : ObservableObject internal partial class GlobalPres : ObservableObject
{ {
internal GlobalPres()
{
IsLightTheme = Settings.Default.IsLightTheme switch
{
-1 => null,
0 => false,
1 => true,
_ => throw new UnreachableException()
};
}
[ObservableProperty] [ObservableProperty]
private static bool? isLightTheme = null; private static bool? isLightTheme = null;
partial void OnIsLightThemeChanged(bool? value) partial void OnIsLightThemeChanged(bool? value)
@ -19,5 +32,8 @@ internal partial class GlobalPres : ObservableObject
foreach (Window currentWindow in Application.Current.Windows) foreach (Window currentWindow in Application.Current.Windows)
BorderThemeSetter.SetBorderTheme(currentWindow, value); BorderThemeSetter.SetBorderTheme(currentWindow, value);
Settings.Default.IsLightTheme = (sbyte)(value.HasValue ? value.GetValueOrDefault() ? 1 : 0 : -1);
Settings.Default.Save();
} }
} }

View File

@ -12,7 +12,7 @@ namespace Sheas_Cealer.Props {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [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 { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@ -58,5 +58,17 @@ namespace Sheas_Cealer.Props {
this["ExtraArgs"] = value; 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;
}
}
} }
} }

View File

@ -11,5 +11,8 @@
<Setting Name="ExtraArgs" Type="System.String" Scope="User"> <Setting Name="ExtraArgs" Type="System.String" Scope="User">
<Value Profile="(Default)" /> <Value Profile="(Default)" />
</Setting> </Setting>
<Setting Name="IsLightTheme" Type="System.SByte" Scope="User">
<Value Profile="(Default)">-1</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -16,6 +16,9 @@ internal static partial class BorderThemeSetter
internal static void SetBorderTheme(Window window, bool? isLightTheme) internal static void SetBorderTheme(Window window, bool? isLightTheme)
{ {
if (!window.IsLoaded)
return;
nint isDarkTheme; nint isDarkTheme;
nint desktopHwnd = nint.Zero; nint desktopHwnd = nint.Zero;
nint windowHwnd = new WindowInteropHelper(window).EnsureHandle(); nint windowHwnd = new WindowInteropHelper(window).EnsureHandle();