add:新设置

This commit is contained in:
2026-02-07 14:02:26 +08:00
parent 654e15f845
commit fa7caf3592
8 changed files with 104 additions and 77 deletions
@@ -200,7 +200,10 @@ namespace Ink_Canvas.Windows.SettingsViews
var button = this.FindDescendantByName($"{group}{buttonName}Border") as Border; var button = this.FindDescendantByName($"{group}{buttonName}Border") as Border;
if (button != null) if (button != null)
{ {
// 清除同组其他按钮的选中状态 bool isDarkTheme = ThemeHelper.IsDarkTheme;
var selectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(25, 25, 25)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var unselectedBrush = new SolidColorBrush(Colors.Transparent);
var parent = button.Parent as Panel; var parent = button.Parent as Panel;
if (parent != null) if (parent != null)
{ {
@@ -211,23 +214,24 @@ namespace Ink_Canvas.Windows.SettingsViews
string childTag = childBorder.Tag?.ToString(); string childTag = childBorder.Tag?.ToString();
if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_"))
{ {
childBorder.Background = new SolidColorBrush(Colors.Transparent); childBorder.Background = unselectedBrush;
var textBlock = childBorder.Child as TextBlock; var textBlock = childBorder.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Normal; textBlock.FontWeight = FontWeights.Normal;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
} }
} }
} }
// 设置当前按钮为选中状态 button.Background = selectedBrush;
button.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
var currentTextBlock = button.Child as TextBlock; var currentTextBlock = button.Child as TextBlock;
if (currentTextBlock != null) if (currentTextBlock != null)
{ {
currentTextBlock.FontWeight = FontWeights.Bold; currentTextBlock.FontWeight = FontWeights.Bold;
currentTextBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
} }
@@ -450,7 +454,10 @@ namespace Ink_Canvas.Windows.SettingsViews
string group = parts[0]; string group = parts[0];
string value = parts[1]; string value = parts[1];
// 清除同组其他按钮的选中状态 bool isDarkTheme = ThemeHelper.IsDarkTheme;
var selectedBrush = isDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var unselectedBrush = new SolidColorBrush(Colors.Transparent);
var parent = border.Parent as Panel; var parent = border.Parent as Panel;
if (parent != null) if (parent != null)
{ {
@@ -461,23 +468,24 @@ namespace Ink_Canvas.Windows.SettingsViews
string childTag = childBorder.Tag?.ToString(); string childTag = childBorder.Tag?.ToString();
if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_"))
{ {
childBorder.Background = new SolidColorBrush(Colors.Transparent); childBorder.Background = unselectedBrush;
var textBlock = childBorder.Child as TextBlock; var textBlock = childBorder.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Normal; textBlock.FontWeight = FontWeights.Normal;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
} }
} }
} }
// 设置当前按钮为选中状态 border.Background = selectedBrush;
border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
var currentTextBlock = border.Child as TextBlock; var currentTextBlock = border.Child as TextBlock;
if (currentTextBlock != null) if (currentTextBlock != null)
{ {
currentTextBlock.FontWeight = FontWeights.Bold; currentTextBlock.FontWeight = FontWeights.Bold;
currentTextBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
if (MainWindow.Settings.Advanced == null) return; if (MainWindow.Settings.Advanced == null) return;
@@ -203,6 +203,10 @@ namespace Ink_Canvas.Windows.SettingsViews
string[] buttonNames = group == "EraserSize" ? buttons : hyperbolaButtons; string[] buttonNames = group == "EraserSize" ? buttons : hyperbolaButtons;
bool isDarkTheme = ThemeHelper.IsDarkTheme;
var selectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(25, 25, 25)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var unselectedBrush = new SolidColorBrush(Colors.Transparent);
for (int i = 0; i < buttonNames.Length && i <= selectedIndex; i++) for (int i = 0; i < buttonNames.Length && i <= selectedIndex; i++)
{ {
var button = this.FindDescendantByName($"{group}{buttonNames[i]}") as Border; var button = this.FindDescendantByName($"{group}{buttonNames[i]}") as Border;
@@ -210,20 +214,22 @@ namespace Ink_Canvas.Windows.SettingsViews
{ {
if (i == selectedIndex) if (i == selectedIndex)
{ {
button.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); button.Background = selectedBrush;
var textBlock = button.Child as TextBlock; var textBlock = button.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Bold; textBlock.FontWeight = FontWeights.Bold;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
else else
{ {
button.Background = new SolidColorBrush(Colors.Transparent); button.Background = unselectedBrush;
var textBlock = button.Child as TextBlock; var textBlock = button.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Normal; textBlock.FontWeight = FontWeights.Normal;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
} }
@@ -468,7 +474,10 @@ namespace Ink_Canvas.Windows.SettingsViews
string group = parts[0]; string group = parts[0];
string value = parts[1]; string value = parts[1];
// 清除同组其他按钮的选中状态 bool isDarkTheme = ThemeHelper.IsDarkTheme;
var selectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(25, 25, 25)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var unselectedBrush = new SolidColorBrush(Colors.Transparent);
var parent = border.Parent as Panel; var parent = border.Parent as Panel;
if (parent != null) if (parent != null)
{ {
@@ -479,23 +488,24 @@ namespace Ink_Canvas.Windows.SettingsViews
string childTag = childBorder.Tag?.ToString(); string childTag = childBorder.Tag?.ToString();
if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_"))
{ {
childBorder.Background = new SolidColorBrush(Colors.Transparent); childBorder.Background = unselectedBrush;
var textBlock = childBorder.Child as TextBlock; var textBlock = childBorder.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Normal; textBlock.FontWeight = FontWeights.Normal;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
} }
} }
} }
// 设置当前按钮为选中状态 border.Background = selectedBrush;
border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
var currentTextBlock = border.Child as TextBlock; var currentTextBlock = border.Child as TextBlock;
if (currentTextBlock != null) if (currentTextBlock != null)
{ {
currentTextBlock.FontWeight = FontWeights.Bold; currentTextBlock.FontWeight = FontWeights.Bold;
currentTextBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
var canvas = MainWindow.Settings.Canvas; var canvas = MainWindow.Settings.Canvas;
@@ -145,6 +145,10 @@ namespace Ink_Canvas.Windows.SettingsViews
string[] buttonNames = buttons[group]; string[] buttonNames = buttons[group];
bool isDarkTheme = ThemeHelper.IsDarkTheme;
var selectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(25, 25, 25)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var unselectedBrush = new SolidColorBrush(Colors.Transparent);
for (int i = 0; i < buttonNames.Length; i++) for (int i = 0; i < buttonNames.Length; i++)
{ {
var button = this.FindDescendantByName($"{group}{buttonNames[i]}Border") as Border; var button = this.FindDescendantByName($"{group}{buttonNames[i]}Border") as Border;
@@ -152,20 +156,22 @@ namespace Ink_Canvas.Windows.SettingsViews
{ {
if (i == selectedIndex) if (i == selectedIndex)
{ {
button.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); button.Background = selectedBrush;
var textBlock = button.Child as TextBlock; var textBlock = button.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Bold; textBlock.FontWeight = FontWeights.Bold;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
else else
{ {
button.Background = new SolidColorBrush(Colors.Transparent); button.Background = unselectedBrush;
var textBlock = button.Child as TextBlock; var textBlock = button.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Normal; textBlock.FontWeight = FontWeights.Normal;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
} }
@@ -256,7 +262,10 @@ namespace Ink_Canvas.Windows.SettingsViews
string group = parts[0]; string group = parts[0];
string value = parts[1]; string value = parts[1];
// 清除同组其他按钮的选中状态 bool isDarkTheme = ThemeHelper.IsDarkTheme;
var selectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(25, 25, 25)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var unselectedBrush = new SolidColorBrush(Colors.Transparent);
var parent = border.Parent as Panel; var parent = border.Parent as Panel;
if (parent != null) if (parent != null)
{ {
@@ -267,23 +276,24 @@ namespace Ink_Canvas.Windows.SettingsViews
string childTag = childBorder.Tag?.ToString(); string childTag = childBorder.Tag?.ToString();
if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_"))
{ {
childBorder.Background = new SolidColorBrush(Colors.Transparent); childBorder.Background = unselectedBrush;
var textBlock = childBorder.Child as TextBlock; var textBlock = childBorder.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Normal; textBlock.FontWeight = FontWeights.Normal;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
} }
} }
} }
// 设置当前按钮为选中状态 border.Background = selectedBrush;
border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
var currentTextBlock = border.Child as TextBlock; var currentTextBlock = border.Child as TextBlock;
if (currentTextBlock != null) if (currentTextBlock != null)
{ {
currentTextBlock.FontWeight = FontWeights.Bold; currentTextBlock.FontWeight = FontWeights.Bold;
currentTextBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
switch (group) switch (group)
@@ -193,6 +193,10 @@ namespace Ink_Canvas.Windows.SettingsViews
string[] buttonNames = buttons[group]; string[] buttonNames = buttons[group];
bool isDarkTheme = ThemeHelper.IsDarkTheme;
var selectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(25, 25, 25)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var unselectedBrush = new SolidColorBrush(Colors.Transparent);
for (int i = 0; i < buttonNames.Length; i++) for (int i = 0; i < buttonNames.Length; i++)
{ {
var button = this.FindDescendantByName($"{group}{buttonNames[i]}Border") as Border; var button = this.FindDescendantByName($"{group}{buttonNames[i]}Border") as Border;
@@ -200,20 +204,22 @@ namespace Ink_Canvas.Windows.SettingsViews
{ {
if (i == selectedIndex) if (i == selectedIndex)
{ {
button.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); button.Background = selectedBrush;
var textBlock = button.Child as TextBlock; var textBlock = button.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Bold; textBlock.FontWeight = FontWeights.Bold;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
else else
{ {
button.Background = new SolidColorBrush(Colors.Transparent); button.Background = unselectedBrush;
var textBlock = button.Child as TextBlock; var textBlock = button.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Normal; textBlock.FontWeight = FontWeights.Normal;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
} }
@@ -324,7 +330,10 @@ namespace Ink_Canvas.Windows.SettingsViews
string group = parts[0]; string group = parts[0];
string value = parts[1]; string value = parts[1];
// 清除同组其他按钮的选中状态 bool isDarkTheme = ThemeHelper.IsDarkTheme;
var selectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(25, 25, 25)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var unselectedBrush = new SolidColorBrush(Colors.Transparent);
var parent = border.Parent as Panel; var parent = border.Parent as Panel;
if (parent != null) if (parent != null)
{ {
@@ -335,23 +344,24 @@ namespace Ink_Canvas.Windows.SettingsViews
string childTag = childBorder.Tag?.ToString(); string childTag = childBorder.Tag?.ToString();
if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_"))
{ {
childBorder.Background = new SolidColorBrush(Colors.Transparent); childBorder.Background = unselectedBrush;
var textBlock = childBorder.Child as TextBlock; var textBlock = childBorder.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Normal; textBlock.FontWeight = FontWeights.Normal;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
} }
} }
} }
// 设置当前按钮为选中状态 border.Background = selectedBrush;
border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
var currentTextBlock = border.Child as TextBlock; var currentTextBlock = border.Child as TextBlock;
if (currentTextBlock != null) if (currentTextBlock != null)
{ {
currentTextBlock.FontWeight = FontWeights.Bold; currentTextBlock.FontWeight = FontWeights.Bold;
currentTextBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
var randSettings = MainWindow.Settings.RandSettings; var randSettings = MainWindow.Settings.RandSettings;
@@ -284,6 +284,10 @@ namespace Ink_Canvas.Windows.SettingsViews
string[] buttonNames = buttons[group]; string[] buttonNames = buttons[group];
bool isDarkTheme = ThemeHelper.IsDarkTheme;
var selectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(25, 25, 25)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var unselectedBrush = new SolidColorBrush(Colors.Transparent);
for (int i = 0; i < buttonNames.Length; i++) for (int i = 0; i < buttonNames.Length; i++)
{ {
var button = this.FindDescendantByName($"{group}{buttonNames[i]}Border") as Border; var button = this.FindDescendantByName($"{group}{buttonNames[i]}Border") as Border;
@@ -291,20 +295,22 @@ namespace Ink_Canvas.Windows.SettingsViews
{ {
if (i == selectedIndex) if (i == selectedIndex)
{ {
button.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); button.Background = selectedBrush;
var textBlock = button.Child as TextBlock; var textBlock = button.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Bold; textBlock.FontWeight = FontWeights.Bold;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
else else
{ {
button.Background = new SolidColorBrush(Colors.Transparent); button.Background = unselectedBrush;
var textBlock = button.Child as TextBlock; var textBlock = button.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Normal; textBlock.FontWeight = FontWeights.Normal;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
} }
@@ -497,7 +503,10 @@ namespace Ink_Canvas.Windows.SettingsViews
string group = parts[0]; string group = parts[0];
string value = parts[1]; string value = parts[1];
// 清除同组其他按钮的选中状态 bool isDarkTheme = ThemeHelper.IsDarkTheme;
var selectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(25, 25, 25)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var unselectedBrush = new SolidColorBrush(Colors.Transparent);
var parent = border.Parent as Panel; var parent = border.Parent as Panel;
if (parent != null) if (parent != null)
{ {
@@ -508,23 +517,24 @@ namespace Ink_Canvas.Windows.SettingsViews
string childTag = childBorder.Tag?.ToString(); string childTag = childBorder.Tag?.ToString();
if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_"))
{ {
childBorder.Background = new SolidColorBrush(Colors.Transparent); childBorder.Background = unselectedBrush;
var textBlock = childBorder.Child as TextBlock; var textBlock = childBorder.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Normal; textBlock.FontWeight = FontWeights.Normal;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
} }
} }
} }
// 设置当前按钮为选中状态 border.Background = selectedBrush;
border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
var currentTextBlock = border.Child as TextBlock; var currentTextBlock = border.Child as TextBlock;
if (currentTextBlock != null) if (currentTextBlock != null)
{ {
currentTextBlock.FontWeight = FontWeights.Bold; currentTextBlock.FontWeight = FontWeights.Bold;
currentTextBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
var pptSettings = MainWindow.Settings.PowerPointSettings; var pptSettings = MainWindow.Settings.PowerPointSettings;
@@ -247,18 +247,21 @@ namespace Ink_Canvas.Windows.SettingsViews
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Normal; textBlock.FontWeight = FontWeights.Normal;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
} }
} }
} }
// 设置当前按钮为选中状态 bool isDarkTheme = ThemeHelper.IsDarkTheme;
border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); var selectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(25, 25, 25)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
border.Background = selectedBrush;
var currentTextBlock = border.Child as TextBlock; var currentTextBlock = border.Child as TextBlock;
if (currentTextBlock != null) if (currentTextBlock != null)
{ {
currentTextBlock.FontWeight = FontWeights.Bold; currentTextBlock.FontWeight = FontWeights.Bold;
currentTextBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
HandleOptionChange(group, value); HandleOptionChange(group, value);
@@ -440,8 +440,8 @@ namespace Ink_Canvas.Windows.SettingsViews
try try
{ {
bool isDarkTheme = ThemeHelper.IsDarkTheme; bool isDarkTheme = ThemeHelper.IsDarkTheme;
var selectedBrush = isDarkTheme ? ThemeHelper.GetButtonBackgroundBrush() : new SolidColorBrush(Color.FromRgb(225, 225, 225)); var selectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(25, 25, 25)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var unselectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(35, 35, 35)) : new SolidColorBrush(Colors.Transparent); var unselectedBrush = new SolidColorBrush(Colors.Transparent);
if (UpdateChannelReleaseBorder != null) if (UpdateChannelReleaseBorder != null)
{ {
@@ -536,39 +536,9 @@ namespace Ink_Canvas.Windows.SettingsViews
{ {
bool isDarkTheme = ThemeHelper.IsDarkTheme; bool isDarkTheme = ThemeHelper.IsDarkTheme;
// 更新更新通道按钮 if (MainWindow.Settings?.Startup != null)
if (UpdateChannelReleaseBorder != null)
{ {
UpdateChannelReleaseBorder.Background = isDarkTheme UpdateUpdateChannelButtons(MainWindow.Settings.Startup.UpdateChannel);
? ThemeHelper.GetButtonBackgroundBrush()
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
var textBlock = UpdateChannelReleaseBorder.Child as TextBlock;
if (textBlock != null)
{
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
}
}
if (UpdateChannelPreviewBorder != null)
{
UpdateChannelPreviewBorder.Background = isDarkTheme
? ThemeHelper.GetButtonBackgroundBrush()
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
var textBlock = UpdateChannelPreviewBorder.Child as TextBlock;
if (textBlock != null)
{
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
}
}
if (UpdateChannelBetaBorder != null)
{
UpdateChannelBetaBorder.Background = isDarkTheme
? ThemeHelper.GetButtonBackgroundBrush()
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
var textBlock = UpdateChannelBetaBorder.Child as TextBlock;
if (textBlock != null)
{
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
}
} }
// 更新按钮 // 更新按钮
@@ -492,9 +492,6 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
} }
/// <summary>
/// 设置选项按钮状态
/// </summary>
private void SetOptionButtonState(string group, int selectedIndex) private void SetOptionButtonState(string group, int selectedIndex)
{ {
var buttons = new Dictionary<string, string[]> var buttons = new Dictionary<string, string[]>
@@ -509,6 +506,9 @@ namespace Ink_Canvas.Windows.SettingsViews
if (!buttons.ContainsKey(group)) return; if (!buttons.ContainsKey(group)) return;
string[] buttonNames = buttons[group]; string[] buttonNames = buttons[group];
bool isDarkTheme = ThemeHelper.IsDarkTheme;
var selectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(25, 25, 25)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var unselectedBrush = new SolidColorBrush(Colors.Transparent);
for (int i = 0; i < buttonNames.Length; i++) for (int i = 0; i < buttonNames.Length; i++)
{ {
@@ -517,20 +517,22 @@ namespace Ink_Canvas.Windows.SettingsViews
{ {
if (i == selectedIndex) if (i == selectedIndex)
{ {
button.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); button.Background = selectedBrush;
var textBlock = button.Child as TextBlock; var textBlock = button.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Bold; textBlock.FontWeight = FontWeights.Bold;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
else else
{ {
button.Background = new SolidColorBrush(Colors.Transparent); button.Background = unselectedBrush;
var textBlock = button.Child as TextBlock; var textBlock = button.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Normal; textBlock.FontWeight = FontWeights.Normal;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
} }
@@ -556,7 +558,10 @@ namespace Ink_Canvas.Windows.SettingsViews
string group = parts[0]; string group = parts[0];
string value = parts[1]; string value = parts[1];
// 清除同组其他按钮的选中状态 bool isDarkTheme = ThemeHelper.IsDarkTheme;
var selectedBrush = isDarkTheme ? new SolidColorBrush(Color.FromRgb(25, 25, 25)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var unselectedBrush = new SolidColorBrush(Colors.Transparent);
var parent = border.Parent as Panel; var parent = border.Parent as Panel;
if (parent != null) if (parent != null)
{ {
@@ -567,23 +572,24 @@ namespace Ink_Canvas.Windows.SettingsViews
string childTag = childBorder.Tag?.ToString(); string childTag = childBorder.Tag?.ToString();
if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_"))
{ {
childBorder.Background = new SolidColorBrush(Colors.Transparent); childBorder.Background = unselectedBrush;
var textBlock = childBorder.Child as TextBlock; var textBlock = childBorder.Child as TextBlock;
if (textBlock != null) if (textBlock != null)
{ {
textBlock.FontWeight = FontWeights.Normal; textBlock.FontWeight = FontWeights.Normal;
textBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
} }
} }
} }
} }
// 设置当前按钮为选中状态 border.Background = selectedBrush;
border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
var currentTextBlock = border.Child as TextBlock; var currentTextBlock = border.Child as TextBlock;
if (currentTextBlock != null) if (currentTextBlock != null)
{ {
currentTextBlock.FontWeight = FontWeights.Bold; currentTextBlock.FontWeight = FontWeights.Bold;
currentTextBlock.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
var appearance = MainWindow.Settings.Appearance; var appearance = MainWindow.Settings.Appearance;