add:新设置
This commit is contained in:
@@ -172,11 +172,12 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
if (toggleSwitch == null) return;
|
if (toggleSwitch == null) return;
|
||||||
toggleSwitch.Background = isOn
|
toggleSwitch.Background = isOn
|
||||||
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
||||||
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
: (ThemeHelper.IsDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(225, 225, 225)));
|
||||||
var innerBorder = toggleSwitch.Child as Border;
|
var innerBorder = toggleSwitch.Child as Border;
|
||||||
if (innerBorder != null)
|
if (innerBorder != null)
|
||||||
{
|
{
|
||||||
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
||||||
|
innerBorder.Background = new SolidColorBrush(Colors.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using Ink_Canvas.Windows.SettingsViews;
|
using Ink_Canvas.Windows.SettingsViews;
|
||||||
@@ -97,12 +96,14 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
|
|
||||||
border.Background = isOn
|
border.Background = isOn
|
||||||
? new SolidColorBrush(Color.FromRgb(0x35, 0x84, 0xE4))
|
? new SolidColorBrush(Color.FromRgb(0x35, 0x84, 0xE4))
|
||||||
: new SolidColorBrush(Color.FromRgb(0xE1, 0xE1, 0xE1));
|
: (ThemeHelper.IsDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(0xE1, 0xE1, 0xE1)));
|
||||||
|
|
||||||
var innerBorder = border.Child as Border;
|
var innerBorder = border.Child as Border;
|
||||||
if (innerBorder != null)
|
if (innerBorder != null)
|
||||||
{
|
{
|
||||||
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
||||||
|
// 保持滑块为白色(主题切换时也更稳定)
|
||||||
|
innerBorder.Background = new SolidColorBrush(Colors.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -184,11 +184,12 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
if (toggleSwitch == null) return;
|
if (toggleSwitch == null) return;
|
||||||
toggleSwitch.Background = isOn
|
toggleSwitch.Background = isOn
|
||||||
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
||||||
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
: (ThemeHelper.IsDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(225, 225, 225)));
|
||||||
var innerBorder = toggleSwitch.Child as Border;
|
var innerBorder = toggleSwitch.Child as Border;
|
||||||
if (innerBorder != null)
|
if (innerBorder != null)
|
||||||
{
|
{
|
||||||
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
||||||
|
innerBorder.Background = new SolidColorBrush(Colors.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -122,11 +122,12 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
if (toggleSwitch == null) return;
|
if (toggleSwitch == null) return;
|
||||||
toggleSwitch.Background = isOn
|
toggleSwitch.Background = isOn
|
||||||
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
||||||
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
: (ThemeHelper.IsDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(225, 225, 225)));
|
||||||
var innerBorder = toggleSwitch.Child as Border;
|
var innerBorder = toggleSwitch.Child as Border;
|
||||||
if (innerBorder != null)
|
if (innerBorder != null)
|
||||||
{
|
{
|
||||||
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
||||||
|
innerBorder.Background = new SolidColorBrush(Colors.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -169,11 +169,12 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
if (toggleSwitch == null) return;
|
if (toggleSwitch == null) return;
|
||||||
toggleSwitch.Background = isOn
|
toggleSwitch.Background = isOn
|
||||||
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
||||||
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
: (ThemeHelper.IsDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(225, 225, 225)));
|
||||||
var innerBorder = toggleSwitch.Child as Border;
|
var innerBorder = toggleSwitch.Child as Border;
|
||||||
if (innerBorder != null)
|
if (innerBorder != null)
|
||||||
{
|
{
|
||||||
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
||||||
|
innerBorder.Background = new SolidColorBrush(Colors.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -261,11 +261,12 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
if (toggleSwitch == null) return;
|
if (toggleSwitch == null) return;
|
||||||
toggleSwitch.Background = isOn
|
toggleSwitch.Background = isOn
|
||||||
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
||||||
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
: (ThemeHelper.IsDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(225, 225, 225)));
|
||||||
var innerBorder = toggleSwitch.Child as Border;
|
var innerBorder = toggleSwitch.Child as Border;
|
||||||
if (innerBorder != null)
|
if (innerBorder != null)
|
||||||
{
|
{
|
||||||
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
||||||
|
innerBorder.Background = new SolidColorBrush(Colors.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -182,11 +182,12 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
if (toggleSwitch == null) return;
|
if (toggleSwitch == null) return;
|
||||||
toggleSwitch.Background = isOn
|
toggleSwitch.Background = isOn
|
||||||
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
||||||
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
: (ThemeHelper.IsDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(225, 225, 225)));
|
||||||
var innerBorder = toggleSwitch.Child as Border;
|
var innerBorder = toggleSwitch.Child as Border;
|
||||||
if (innerBorder != null)
|
if (innerBorder != null)
|
||||||
{
|
{
|
||||||
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
||||||
|
innerBorder.Background = new SolidColorBrush(Colors.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,11 +160,12 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
if (toggleSwitch == null) return;
|
if (toggleSwitch == null) return;
|
||||||
toggleSwitch.Background = isOn
|
toggleSwitch.Background = isOn
|
||||||
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
||||||
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
: (ThemeHelper.IsDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(225, 225, 225)));
|
||||||
var innerBorder = toggleSwitch.Child as Border;
|
var innerBorder = toggleSwitch.Child as Border;
|
||||||
if (innerBorder != null)
|
if (innerBorder != null)
|
||||||
{
|
{
|
||||||
innerBorder.HorizontalAlignment = isOn ? System.Windows.HorizontalAlignment.Right : System.Windows.HorizontalAlignment.Left;
|
innerBorder.HorizontalAlignment = isOn ? System.Windows.HorizontalAlignment.Right : System.Windows.HorizontalAlignment.Left;
|
||||||
|
innerBorder.Background = new SolidColorBrush(Colors.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -222,11 +222,14 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
private void SetToggleSwitchState(Border toggleSwitch, bool isOn)
|
private void SetToggleSwitchState(Border toggleSwitch, bool isOn)
|
||||||
{
|
{
|
||||||
if (toggleSwitch == null) return;
|
if (toggleSwitch == null) return;
|
||||||
toggleSwitch.Background = isOn ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
toggleSwitch.Background = isOn
|
||||||
|
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
||||||
|
: (ThemeHelper.IsDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(225, 225, 225)));
|
||||||
var innerBorder = toggleSwitch.Child as Border;
|
var innerBorder = toggleSwitch.Child as Border;
|
||||||
if (innerBorder != null)
|
if (innerBorder != null)
|
||||||
{
|
{
|
||||||
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
||||||
|
innerBorder.Background = new SolidColorBrush(Colors.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,35 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ThemeHelper
|
public static class ThemeHelper
|
||||||
{
|
{
|
||||||
|
private static bool IsToggleSwitchThumb(System.Windows.Controls.Border border)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (border == null) return false;
|
||||||
|
|
||||||
|
// ToggleSwitch thumb 常见尺寸:19x19,圆角 10,父级为 48x25 的开关背景
|
||||||
|
if (border.Width < 16 || border.Width > 24 || border.Height < 16 || border.Height > 24)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (border.CornerRadius.TopLeft < 8) return false;
|
||||||
|
|
||||||
|
if (border.Parent is System.Windows.Controls.Border parent)
|
||||||
|
{
|
||||||
|
if (parent.Width >= 40 && parent.Width <= 60 &&
|
||||||
|
parent.Height >= 20 && parent.Height <= 35 &&
|
||||||
|
parent.CornerRadius.TopLeft >= 10)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查当前是否为深色主题
|
/// 检查当前是否为深色主题
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -180,8 +209,12 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 其他白色背景(如搜索框)
|
// ToggleSwitch thumb 应保持白色,不参与主题背景替换
|
||||||
border.Background = GetTextBoxBackgroundBrush();
|
if (!IsToggleSwitchThumb(border))
|
||||||
|
{
|
||||||
|
// 其他白色背景(如搜索框)
|
||||||
|
border.Background = GetTextBoxBackgroundBrush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (color.R == 250 && color.G == 250 && color.B == 250) // #fafafa - 主背景
|
else if (color.R == 250 && color.G == 250 && color.B == 250) // #fafafa - 主背景
|
||||||
|
|||||||
@@ -230,11 +230,12 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
if (toggleSwitch == null) return;
|
if (toggleSwitch == null) return;
|
||||||
toggleSwitch.Background = isOn
|
toggleSwitch.Background = isOn
|
||||||
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
|
||||||
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
: (ThemeHelper.IsDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(225, 225, 225)));
|
||||||
var innerBorder = toggleSwitch.Child as Border;
|
var innerBorder = toggleSwitch.Child as Border;
|
||||||
if (innerBorder != null)
|
if (innerBorder != null)
|
||||||
{
|
{
|
||||||
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
||||||
|
innerBorder.Background = new SolidColorBrush(Colors.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user