From 5bebf077e471dddea828e1259b0efcac59192099 Mon Sep 17 00:00:00 2001
From: CJKmkp <2564608840@qq.com>
Date: Sat, 4 Oct 2025 22:59:11 +0800
Subject: [PATCH] =?UTF-8?q?improve:=E4=B8=BB=E9=A2=98=E5=88=87=E6=8D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Ink Canvas/Windows/SeewoStyleTimerWindow.xaml | 11 +--
.../Windows/SeewoStyleTimerWindow.xaml.cs | 68 +++++++++++++++---
...vasForClass.csproj.AssemblyReference.cache | Bin 38044 -> 38181 bytes
3 files changed, 61 insertions(+), 18 deletions(-)
diff --git a/Ink Canvas/Windows/SeewoStyleTimerWindow.xaml b/Ink Canvas/Windows/SeewoStyleTimerWindow.xaml
index 738b12eb..fd4a0243 100644
--- a/Ink Canvas/Windows/SeewoStyleTimerWindow.xaml
+++ b/Ink Canvas/Windows/SeewoStyleTimerWindow.xaml
@@ -5,18 +5,11 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Ink_Canvas"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
- ui:ThemeManager.RequestedTheme="Light" Topmost="True" Background="Transparent"
+ Topmost="True" Background="Transparent"
mc:Ignorable="d" WindowStyle="None" AllowsTransparency="True"
Loaded="Window_Loaded" Closing="Window_Closing" WindowStartupLocation="CenterScreen"
Title="Ink Canvas 画板 - 计时器" Height="400" Width="600">
-
-
-
-
-
-
-
-
+
diff --git a/Ink Canvas/Windows/SeewoStyleTimerWindow.xaml.cs b/Ink Canvas/Windows/SeewoStyleTimerWindow.xaml.cs
index de7d6fe2..e719f753 100644
--- a/Ink Canvas/Windows/SeewoStyleTimerWindow.xaml.cs
+++ b/Ink Canvas/Windows/SeewoStyleTimerWindow.xaml.cs
@@ -91,16 +91,10 @@ namespace Ink_Canvas
{
try
{
- // 根据主题设置数字显示颜色
- var digitForeground = Application.Current.FindResource("SeewoTimerWindowDigitForeground") as SolidColorBrush;
- if (digitForeground != null)
+ // 应用主题设置
+ if (MainWindow.Settings != null)
{
- Digit1Display.Foreground = digitForeground;
- Digit2Display.Foreground = digitForeground;
- Digit3Display.Foreground = digitForeground;
- Digit4Display.Foreground = digitForeground;
- Digit5Display.Foreground = digitForeground;
- Digit6Display.Foreground = digitForeground;
+ ApplyTheme(MainWindow.Settings);
}
}
catch (Exception ex)
@@ -109,6 +103,62 @@ namespace Ink_Canvas
}
}
+ private void ApplyTheme(Settings settings)
+ {
+ try
+ {
+ if (settings.Appearance.Theme == 0) // 浅色主题
+ {
+ iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Light);
+ }
+ else if (settings.Appearance.Theme == 1) // 深色主题
+ {
+ iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Dark);
+ }
+ else // 跟随系统主题
+ {
+ bool isSystemLight = IsSystemThemeLight();
+ if (isSystemLight)
+ {
+ iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Light);
+ }
+ else
+ {
+ iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Dark);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"应用仿希沃倒计时窗口主题出错: {ex.Message}", LogHelper.LogType.Error);
+ }
+ }
+
+ private bool IsSystemThemeLight()
+ {
+ var light = false;
+ try
+ {
+ var registryKey = Microsoft.Win32.Registry.CurrentUser;
+ var themeKey = registryKey.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize");
+ if (themeKey != null)
+ {
+ var value = themeKey.GetValue("AppsUseLightTheme");
+ if (value != null)
+ {
+ light = (int)value == 1;
+ }
+ themeKey.Close();
+ }
+ }
+ catch
+ {
+ // 如果读取注册表失败,默认为浅色主题
+ light = true;
+ }
+ return light;
+ }
+
private void UpdateDigitDisplays()
{
Digit1Display.Text = (hour / 10).ToString();
diff --git a/Ink Canvas/obj/Debug/net472/InkCanvasForClass.csproj.AssemblyReference.cache b/Ink Canvas/obj/Debug/net472/InkCanvasForClass.csproj.AssemblyReference.cache
index c8c2dfbd497b829755ee6211820ad2e2d43c9d13..57d842b8b7d92d5308ee26301638a87ff9085d80 100644
GIT binary patch
delta 70
zcmbQUl4B~nPN5rP?War*kO`k`FUd8TkDE=&SuZ6ghmjGefZ>7T
XjqeIqIY4T;%1rbO^o$LR4J{b}mk1Gb
delta 23
fcmZ3wifPVDCJr`6Lk0#0#>B~nPN5rP?WX_$OSlGi