improve:主题切换
This commit is contained in:
@@ -74,6 +74,9 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 强制刷新UI
|
// 强制刷新UI
|
||||||
window.InvalidateVisual();
|
window.InvalidateVisual();
|
||||||
|
|
||||||
|
// 通知其他窗口刷新主题
|
||||||
|
RefreshOtherWindowsTheme();
|
||||||
}
|
}
|
||||||
else if (theme == "Dark")
|
else if (theme == "Dark")
|
||||||
{
|
{
|
||||||
@@ -115,6 +118,9 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 强制刷新UI
|
// 强制刷新UI
|
||||||
window.InvalidateVisual();
|
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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -430,6 +430,25 @@ namespace Ink_Canvas
|
|||||||
InitializeUI();
|
InitializeUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 刷新主题,当主窗口主题切换时调用
|
||||||
|
/// </summary>
|
||||||
|
public void RefreshTheme()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 重新应用主题
|
||||||
|
ApplyTheme();
|
||||||
|
|
||||||
|
// 强制刷新UI
|
||||||
|
InvalidateVisual();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogHelper.WriteLogToFile($"刷新计时器窗口主题出错: {ex.Message}", LogHelper.LogType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateButtonTexts()
|
private void UpdateButtonTexts()
|
||||||
{
|
{
|
||||||
if (useLegacyUI)
|
if (useLegacyUI)
|
||||||
|
|||||||
@@ -478,6 +478,25 @@ namespace Ink_Canvas
|
|||||||
// 这里可以添加必要的清理代码
|
// 这里可以添加必要的清理代码
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 刷新主题,当主窗口主题切换时调用
|
||||||
|
/// </summary>
|
||||||
|
public void RefreshTheme()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 重新应用主题
|
||||||
|
ApplyTheme(MainWindow.Settings);
|
||||||
|
|
||||||
|
// 强制刷新UI
|
||||||
|
InvalidateVisual();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogHelper.WriteLogToFile($"刷新点名窗口主题出错: {ex.Message}", LogHelper.LogType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Win32 API 声明
|
#region Win32 API 声明
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
|
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
|
||||||
|
|||||||
Reference in New Issue
Block a user