From cc054aeb752c4b67adebaa6779206122c286ed80 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 5 Oct 2025 09:33:25 +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/MainWindow_cs/MW_AutoTheme.cs | 6 ++- Ink Canvas/Resources/Styles/Dark.xaml | 11 ++++ Ink Canvas/Resources/Styles/Light.xaml | 11 ++++ Ink Canvas/Windows/OperatingGuideWindow.xaml | 36 ++++++------- .../Windows/OperatingGuideWindow.xaml.cs | 50 +++++++++++++++++++ 5 files changed, 95 insertions(+), 19 deletions(-) diff --git a/Ink Canvas/MainWindow_cs/MW_AutoTheme.cs b/Ink Canvas/MainWindow_cs/MW_AutoTheme.cs index c7755caf..88c967be 100644 --- a/Ink Canvas/MainWindow_cs/MW_AutoTheme.cs +++ b/Ink Canvas/MainWindow_cs/MW_AutoTheme.cs @@ -499,7 +499,7 @@ namespace Ink_Canvas { try { - // 刷新所有打开的计时器窗口 + // 刷新所有打开的窗口 foreach (Window window in Application.Current.Windows) { if (window is CountdownTimerWindow timerWindow) @@ -510,6 +510,10 @@ namespace Ink_Canvas { randWindow.RefreshTheme(); } + else if (window is OperatingGuideWindow operatingGuideWindow) + { + operatingGuideWindow.RefreshTheme(); + } } } catch (Exception) diff --git a/Ink Canvas/Resources/Styles/Dark.xaml b/Ink Canvas/Resources/Styles/Dark.xaml index 25f52bfd..c45b8d04 100644 --- a/Ink Canvas/Resources/Styles/Dark.xaml +++ b/Ink Canvas/Resources/Styles/Dark.xaml @@ -122,4 +122,15 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Ink Canvas/Resources/Styles/Light.xaml b/Ink Canvas/Resources/Styles/Light.xaml index 6c7eb63b..f371c364 100644 --- a/Ink Canvas/Resources/Styles/Light.xaml +++ b/Ink Canvas/Resources/Styles/Light.xaml @@ -122,4 +122,15 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Ink Canvas/Windows/OperatingGuideWindow.xaml b/Ink Canvas/Windows/OperatingGuideWindow.xaml index 67c81734..f8408520 100644 --- a/Ink Canvas/Windows/OperatingGuideWindow.xaml +++ b/Ink Canvas/Windows/OperatingGuideWindow.xaml @@ -10,7 +10,7 @@ WindowStartupLocation="CenterScreen" Title="Ink Canvas Annotation 使用指南" Height="600" Width="500"> - + - + @@ -28,44 +28,44 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -75,22 +75,22 @@ + Background="{DynamicResource OperatingGuideWindowFullscreenButtonBackground}" Height="20" Width="20" CornerRadius="100"> - + + Background="{DynamicResource OperatingGuideWindowCloseButtonBackground}" Height="20" Width="20" CornerRadius="100"> - + diff --git a/Ink Canvas/Windows/OperatingGuideWindow.xaml.cs b/Ink Canvas/Windows/OperatingGuideWindow.xaml.cs index 61c50f51..39ded587 100644 --- a/Ink Canvas/Windows/OperatingGuideWindow.xaml.cs +++ b/Ink Canvas/Windows/OperatingGuideWindow.xaml.cs @@ -1,6 +1,8 @@ using Ink_Canvas.Helpers; using System.Windows; using System.Windows.Input; +using iNKORE.UI.WPF.Modern; +using System; namespace Ink_Canvas { @@ -43,5 +45,53 @@ namespace Ink_Canvas { e.Handled = true; } + + /// + /// 刷新主题 + /// + public void RefreshTheme() + { + try + { + // 根据当前主题设置窗口主题 + bool isDarkTheme = MainWindow.Settings.Appearance.Theme == 1 || + (MainWindow.Settings.Appearance.Theme == 2 && !IsSystemThemeLight()); + + if (isDarkTheme) + { + ThemeManager.SetRequestedTheme(this, ElementTheme.Dark); + } + else + { + ThemeManager.SetRequestedTheme(this, ElementTheme.Light); + } + + // 强制刷新UI + InvalidateVisual(); + } + catch (Exception) + { + } + } + + /// + /// 检查系统主题是否为浅色 + /// + private bool IsSystemThemeLight() + { + var light = false; + try + { + var registryKey = Microsoft.Win32.Registry.CurrentUser; + var themeKey = + registryKey.OpenSubKey("software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"); + var keyValue = 0; + if (themeKey != null) keyValue = (int)themeKey.GetValue("SystemUsesLightTheme"); + if (keyValue == 1) light = true; + } + catch { } + + return light; + } } } \ No newline at end of file