improve:主题切换

This commit is contained in:
2025-10-05 09:33:25 +08:00
parent c32eaed534
commit cc054aeb75
5 changed files with 95 additions and 19 deletions
+5 -1
View File
@@ -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)
+11
View File
@@ -122,4 +122,15 @@
<SolidColorBrush x:Key="SeewoTimerWindowTitleForeground" Color="White"/>
<SolidColorBrush x:Key="SeewoTimerWindowPrimaryButtonBackground" Color="#4CAF50"/>
<SolidColorBrush x:Key="SeewoTimerWindowPrimaryButtonForeground" Color="White"/>
<!-- 说明书窗口主题颜色 -->
<SolidColorBrush x:Key="OperatingGuideWindowBackground" Color="#1f1f1f"/>
<SolidColorBrush x:Key="OperatingGuideWindowBorderBrush" Color="#0066BF"/>
<SolidColorBrush x:Key="OperatingGuideWindowTextForeground" Color="White"/>
<SolidColorBrush x:Key="OperatingGuideWindowButtonBackground" Color="#2a2a2a"/>
<SolidColorBrush x:Key="OperatingGuideWindowButtonForeground" Color="White"/>
<SolidColorBrush x:Key="OperatingGuideWindowFullscreenButtonBackground" Color="#2a2a2a"/>
<SolidColorBrush x:Key="OperatingGuideWindowFullscreenButtonForeground" Color="White"/>
<SolidColorBrush x:Key="OperatingGuideWindowCloseButtonBackground" Color="#E32A34"/>
<SolidColorBrush x:Key="OperatingGuideWindowCloseButtonForeground" Color="White"/>
</ResourceDictionary>
+11
View File
@@ -122,4 +122,15 @@
<SolidColorBrush x:Key="SeewoTimerWindowTitleForeground" Color="#333333"/>
<SolidColorBrush x:Key="SeewoTimerWindowPrimaryButtonBackground" Color="#4CAF50"/>
<SolidColorBrush x:Key="SeewoTimerWindowPrimaryButtonForeground" Color="White"/>
<!-- 说明书窗口主题颜色 -->
<SolidColorBrush x:Key="OperatingGuideWindowBackground" Color="#F0F3F9"/>
<SolidColorBrush x:Key="OperatingGuideWindowBorderBrush" Color="#0066BF"/>
<SolidColorBrush x:Key="OperatingGuideWindowTextForeground" Color="Black"/>
<SolidColorBrush x:Key="OperatingGuideWindowButtonBackground" Color="#FBFBFD"/>
<SolidColorBrush x:Key="OperatingGuideWindowButtonForeground" Color="Black"/>
<SolidColorBrush x:Key="OperatingGuideWindowFullscreenButtonBackground" Color="#FBFBFD"/>
<SolidColorBrush x:Key="OperatingGuideWindowFullscreenButtonForeground" Color="Black"/>
<SolidColorBrush x:Key="OperatingGuideWindowCloseButtonBackground" Color="#E32A34"/>
<SolidColorBrush x:Key="OperatingGuideWindowCloseButtonForeground" Color="White"/>
</ResourceDictionary>
+18 -18
View File
@@ -10,7 +10,7 @@
WindowStartupLocation="CenterScreen"
Title="Ink Canvas Annotation 使用指南"
Height="600" Width="500">
<Border Background="#F0F3F9" CornerRadius="10" BorderThickness="1" BorderBrush="#0066BF" Margin="10,10,10,50">
<Border Background="{DynamicResource OperatingGuideWindowBackground}" CornerRadius="10" BorderThickness="1" BorderBrush="{DynamicResource OperatingGuideWindowBorderBrush}" Margin="10,10,10,50">
<Grid>
<Border MouseMove="WindowDragMove" Visibility="Visible" Width="64" Height="15" CornerRadius="8" Background="Gray" Margin="0,0,0,5" HorizontalAlignment="Center" VerticalAlignment="Bottom" />
<ScrollViewer Margin="0,0,0,30" VerticalScrollBarVisibility="Auto"
@@ -20,7 +20,7 @@
<ui:SimpleStackPanel Margin="20,20,20,0" Orientation="Horizontal" HorizontalAlignment="Left">
<Image Margin="5, 0" Source="/Resources/Icons-Fluent/ic_fluent_keyboard_24_regular.png"
RenderOptions.BitmapScalingMode="HighQuality" Height="40" Width="40"/>
<TextBlock FontSize="22" Text="软件快捷键" TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBlock FontSize="22" Text="软件快捷键" TextWrapping="Wrap" VerticalAlignment="Center" Foreground="{DynamicResource OperatingGuideWindowTextForeground}"/>
</ui:SimpleStackPanel>
<Viewbox Height="320" HorizontalAlignment="Left">
@@ -28,44 +28,44 @@
<ui:SimpleStackPanel Margin="20, 0" Height="20" Orientation="Horizontal" HorizontalAlignment="Left">
<Image Source="/Resources/Icons-Fluent/ic_fluent_control_button_24_regular.png"
RenderOptions.BitmapScalingMode="HighQuality" Height="20" Width="20"/>
<TextBlock FontSize="10" Text=" + Z —— 撤销" TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBlock FontSize="10" Text=" + Z —— 撤销" TextWrapping="Wrap" VerticalAlignment="Center" Foreground="{DynamicResource OperatingGuideWindowTextForeground}"/>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Margin="20, 0" Height="20" Orientation="Horizontal" HorizontalAlignment="Left">
<Image Source="/Resources/Icons-Fluent/ic_fluent_control_button_24_regular.png"
RenderOptions.BitmapScalingMode="HighQuality" Height="20" Width="20"/>
<TextBlock FontSize="10" Text=" + Y —— 重做" TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBlock FontSize="10" Text=" + Y —— 重做" TextWrapping="Wrap" VerticalAlignment="Center" Foreground="{DynamicResource OperatingGuideWindowTextForeground}"/>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Margin="20, 0" Height="20" Orientation="Horizontal" HorizontalAlignment="Left">
<Image Source="/Resources/Icons-Fluent/ic_fluent_control_button_24_regular.png"
RenderOptions.BitmapScalingMode="HighQuality" Height="20" Width="20"/>
<TextBlock FontSize="10" Text=" + E —— 清屏" TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBlock FontSize="10" Text=" + E —— 清屏" TextWrapping="Wrap" VerticalAlignment="Center" Foreground="{DynamicResource OperatingGuideWindowTextForeground}"/>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Margin="20, 0" Height="20" Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock FontSize="10" Text=" Alt + V —— 显示/隐藏笑脸右侧工具栏(Visibility" TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBlock FontSize="10" Text=" Alt + V —— 显示/隐藏笑脸右侧工具栏(Visibility" TextWrapping="Wrap" VerticalAlignment="Center" Foreground="{DynamicResource OperatingGuideWindowTextForeground}"/>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Margin="20, 0" Height="20" Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock FontSize="10" Text=" Alt + C —— 截屏(Capture" TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBlock FontSize="10" Text=" Alt + C —— 截屏(Capture" TextWrapping="Wrap" VerticalAlignment="Center" Foreground="{DynamicResource OperatingGuideWindowTextForeground}"/>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Margin="20, 0" Height="20" Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock FontSize="10" Text=" Alt + S —— 切换至选择模式(Select" TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBlock FontSize="10" Text=" Alt + S —— 切换至选择模式(Select" TextWrapping="Wrap" VerticalAlignment="Center" Foreground="{DynamicResource OperatingGuideWindowTextForeground}"/>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Margin="20, 0" Height="20" Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock FontSize="10" Text=" Alt + D —— 切换至批注模式 / 墨迹颜色选择器(Draw" TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBlock FontSize="10" Text=" Alt + D —— 切换至批注模式 / 墨迹颜色选择器(Draw" TextWrapping="Wrap" VerticalAlignment="Center" Foreground="{DynamicResource OperatingGuideWindowTextForeground}"/>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Margin="20, 0" Height="20" Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock FontSize="10" Text=" Alt + Q —— 退出批注模式(Quit" TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBlock FontSize="10" Text=" Alt + Q —— 退出批注模式(Quit" TextWrapping="Wrap" VerticalAlignment="Center" Foreground="{DynamicResource OperatingGuideWindowTextForeground}"/>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Margin="20, 0" Height="20" Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock FontSize="10" Text=" Alt + B —— 切换/退出画板模式(Board" TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBlock FontSize="10" Text=" Alt + B —— 切换/退出画板模式(Board" TextWrapping="Wrap" VerticalAlignment="Center" Foreground="{DynamicResource OperatingGuideWindowTextForeground}"/>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Margin="20, 0" Height="20" Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock FontSize="10" Text=" Alt + E —— 切换至面积擦/墨迹擦功能(Eraser" TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBlock FontSize="10" Text=" Alt + E —— 切换至面积擦/墨迹擦功能(Eraser" TextWrapping="Wrap" VerticalAlignment="Center" Foreground="{DynamicResource OperatingGuideWindowTextForeground}"/>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Margin="20, 0" Height="20" Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock FontSize="10" Text=" Alt + L —— 切换至单次直线绘制功能(Line" TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBlock FontSize="10" Text=" Alt + L —— 切换至单次直线绘制功能(Line" TextWrapping="Wrap" VerticalAlignment="Center" Foreground="{DynamicResource OperatingGuideWindowTextForeground}"/>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Margin="20, 0" Height="20" Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock FontSize="10" Text="Shift + Esc —— 退出 PPT 放映" TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBlock FontSize="10" Text="Shift + Esc —— 退出 PPT 放映" TextWrapping="Wrap" VerticalAlignment="Center" Foreground="{DynamicResource OperatingGuideWindowTextForeground}"/>
</ui:SimpleStackPanel>
</ui:SimpleStackPanel>
</Viewbox>
@@ -75,22 +75,22 @@
<ui:SimpleStackPanel Height="180" Orientation="Horizontal">
<Border x:Name="BtnFullscreen" MouseUp="BtnFullscreen_MouseUp" HorizontalAlignment="Right" VerticalAlignment="Bottom"
Margin="5"
Background="#FBFBFD" Height="20" Width="20" CornerRadius="100">
Background="{DynamicResource OperatingGuideWindowFullscreenButtonBackground}" Height="20" Width="20" CornerRadius="100">
<Border.Effect>
<DropShadowEffect Direction="0" ShadowDepth="0" Opacity="0.1" BlurRadius="3"/>
</Border.Effect>
<Viewbox Margin="5.5">
<ui:SymbolIcon Name="SymbolIconFullscreen" Symbol="FullScreen" Foreground="Black"/>
<ui:SymbolIcon Name="SymbolIconFullscreen" Symbol="FullScreen" Foreground="{DynamicResource OperatingGuideWindowFullscreenButtonForeground}"/>
</Viewbox>
</Border>
<Border x:Name="BtnClose" MouseUp="BtnClose_MouseUp" HorizontalAlignment="Right" VerticalAlignment="Bottom"
Margin="5"
Background="#E32A34" Height="20" Width="20" CornerRadius="100">
Background="{DynamicResource OperatingGuideWindowCloseButtonBackground}" Height="20" Width="20" CornerRadius="100">
<Border.Effect>
<DropShadowEffect Direction="0" ShadowDepth="0" Opacity="0.1" BlurRadius="3"/>
</Border.Effect>
<Viewbox Margin="5.5">
<ui:SymbolIcon Symbol="Clear" Foreground="White"/>
<ui:SymbolIcon Symbol="Clear" Foreground="{DynamicResource OperatingGuideWindowCloseButtonForeground}"/>
</Viewbox>
</Border>
</ui:SimpleStackPanel>
@@ -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;
}
/// <summary>
/// 刷新主题
/// </summary>
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)
{
}
}
/// <summary>
/// 检查系统主题是否为浅色
/// </summary>
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;
}
}
}