improve:主题切换

This commit is contained in:
2025-10-04 21:55:55 +08:00
parent eef2a915fa
commit 402f8bb9f9
8 changed files with 224 additions and 78 deletions
+27
View File
@@ -34,6 +34,9 @@ namespace Ink_Canvas
// 加载背景
LoadBackground(settings);
// 应用主题
ApplyTheme(settings);
// 设置窗口为置顶
Topmost = true;
@@ -75,6 +78,27 @@ namespace Ink_Canvas
}
}
private void ApplyTheme(Settings settings)
{
try
{
// 根据主题设置窗口背景
if (settings.RandSettings.SelectedBackgroundIndex <= 0)
{
// 没有自定义背景时,使用主题背景色
var backgroundBrush = Application.Current.FindResource("RandWindowBackground") as SolidColorBrush;
if (backgroundBrush != null)
{
MainBorder.Background = backgroundBrush;
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"应用点名窗口主题出错: {ex.Message}", LogHelper.LogType.Error);
}
}
public RandWindow(Settings settings, bool IsAutoClose)
{
InitializeComponent();
@@ -88,6 +112,9 @@ namespace Ink_Canvas
// 加载背景
LoadBackground(settings);
// 应用主题
ApplyTheme(settings);
// 设置窗口为置顶
Topmost = true;