improve:主题切换

This commit is contained in:
2025-10-05 09:16:36 +08:00
parent 3eba662772
commit fbf6a13f92
3 changed files with 69 additions and 0 deletions
+31
View File
@@ -74,6 +74,9 @@ namespace Ink_Canvas
// 强制刷新UI
window.InvalidateVisual();
// 通知其他窗口刷新主题
RefreshOtherWindowsTheme();
}
else if (theme == "Dark")
{
@@ -115,6 +118,9 @@ namespace Ink_Canvas
// 强制刷新UI
window.InvalidateVisual();
// 通知其他窗口刷新主题
RefreshOtherWindowsTheme();
}
}
@@ -485,5 +491,30 @@ namespace Ink_Canvas
// 忽略异常
}
}
/// <summary>
/// 刷新其他窗口的主题
/// </summary>
private void RefreshOtherWindowsTheme()
{
try
{
// 刷新所有打开的计时器窗口
foreach (Window window in Application.Current.Windows)
{
if (window is CountdownTimerWindow timerWindow)
{
timerWindow.RefreshTheme();
}
else if (window is RandWindow randWindow)
{
randWindow.RefreshTheme();
}
}
}
catch (Exception)
{
}
}
}
}