From 68a74be2795b2b571c207df0b23ecdac69d32c6a Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sat, 10 Jan 2026 17:31:39 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"add:=E6=96=B0=E8=AE=BE=E7=BD=AE"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 63585911a72f7947c768c8c6acb21c64fd95d3bf. --- .../SettingsViews/AppearancePanel.xaml | 12 +-- .../SettingsViews/ComboBoxStyles.xaml | 6 -- .../SettingsViews/CrashActionPanel.xaml | 4 +- .../SettingsViews/CrashActionPanel.xaml.cs | 69 +------------- .../SettingsViews/StartupPanel.xaml.cs | 4 +- .../SettingsViews/ThemeHelper.cs | 90 ++++--------------- .../SettingsViews/ThemePanel.xaml.cs | 28 ++++-- .../SettingsViews/SettingsWindow.xaml.cs | 4 +- 8 files changed, 51 insertions(+), 166 deletions(-) diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml index be81ef4a..3bc677f5 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml @@ -40,7 +40,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -292,7 +292,7 @@ - + @@ -304,7 +304,7 @@ - + @@ -399,7 +399,7 @@ - + @@ -429,7 +429,7 @@ - + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/ComboBoxStyles.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/ComboBoxStyles.xaml index 89b7d02a..8e56336d 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/ComboBoxStyles.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/ComboBoxStyles.xaml @@ -116,21 +116,15 @@ - - - - diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/CrashActionPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/CrashActionPanel.xaml index 3dcb3f05..9eb13b1a 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/CrashActionPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/CrashActionPanel.xaml @@ -22,10 +22,10 @@ TextWrapping="Wrap" Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" HorizontalAlignment="Left" MaxWidth="450"/> - + - + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/CrashActionPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/CrashActionPanel.xaml.cs index 8a138375..e2897f1c 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/CrashActionPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/CrashActionPanel.xaml.cs @@ -1,8 +1,6 @@ using System; using System.Windows; using System.Windows.Controls; -using System.Windows.Input; -using Ink_Canvas; namespace Ink_Canvas.Windows.SettingsViews { @@ -11,13 +9,6 @@ namespace Ink_Canvas.Windows.SettingsViews public CrashActionPanel() { InitializeComponent(); - Loaded += CrashActionPanel_Loaded; - } - - private void CrashActionPanel_Loaded(object sender, RoutedEventArgs e) - { - LoadSettings(); - ApplyTheme(); } public event EventHandler IsTopBarNeedShadowEffect; @@ -35,73 +26,17 @@ namespace Ink_Canvas.Windows.SettingsViews IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs()); } } - - public void LoadSettings() - { - try - { - if (App.CrashAction == App.CrashActionType.SilentRestart) - { - ThemeHelper.SetOptionButtonSelectedState(CrashActionSilentRestartBorder, true); - ThemeHelper.SetOptionButtonSelectedState(CrashActionNoActionBorder, false); - } - else - { - ThemeHelper.SetOptionButtonSelectedState(CrashActionSilentRestartBorder, false); - ThemeHelper.SetOptionButtonSelectedState(CrashActionNoActionBorder, true); - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine($"CrashActionPanel 加载设置时出错: {ex.Message}"); - } - } - - private void OptionButton_Click(object sender, MouseButtonEventArgs e) - { - var border = sender as Border; - if (border != null) - { - string tag = border.Tag?.ToString(); - if (!string.IsNullOrEmpty(tag)) - { - // 清除同组其他按钮的选中状态 - if (tag == "CrashAction_SilentRestart") - { - ThemeHelper.SetOptionButtonSelectedState(CrashActionSilentRestartBorder, true); - ThemeHelper.SetOptionButtonSelectedState(CrashActionNoActionBorder, false); - App.CrashAction = App.CrashActionType.SilentRestart; - if (MainWindow.Settings?.Startup != null) - { - MainWindow.Settings.Startup.CrashAction = (int)App.CrashActionType.SilentRestart; - } - } - else if (tag == "CrashAction_NoAction") - { - ThemeHelper.SetOptionButtonSelectedState(CrashActionSilentRestartBorder, false); - ThemeHelper.SetOptionButtonSelectedState(CrashActionNoActionBorder, true); - App.CrashAction = App.CrashActionType.NoAction; - if (MainWindow.Settings?.Startup != null) - { - MainWindow.Settings.Startup.CrashAction = (int)App.CrashActionType.NoAction; - } - } - } - } - } - public void ApplyTheme() { try { ThemeHelper.ApplyThemeToControl(this); - // 重新应用按钮状态以适配主题 - LoadSettings(); } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine($"CrashActionPanel 应用主题时出错: {ex.Message}"); + System.Diagnostics.Debug.WriteLine($"CrashActionPanel 应用主题时出�? {ex.Message}"); } } } } + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/StartupPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/StartupPanel.xaml.cs index 0dfaa815..0403c705 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/StartupPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/StartupPanel.xaml.cs @@ -218,9 +218,7 @@ namespace Ink_Canvas.Windows.SettingsViews private void SetToggleSwitchState(Border toggleSwitch, bool isOn) { if (toggleSwitch == null) return; - toggleSwitch.Background = isOn - ? ThemeHelper.GetToggleSwitchOnBackgroundBrush() - : ThemeHelper.GetToggleSwitchOffBackgroundBrush(); + toggleSwitch.Background = isOn ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) : new SolidColorBrush(Color.FromRgb(225, 225, 225)); var innerBorder = toggleSwitch.Child as Border; if (innerBorder != null) { diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemeHelper.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemeHelper.cs index 649a4010..c7db8819 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemeHelper.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemeHelper.cs @@ -1,5 +1,4 @@ using System; -using System.ComponentModel; using System.Windows; using System.Windows.Controls; using System.Windows.Media; @@ -50,9 +49,9 @@ namespace Ink_Canvas.Windows.SettingsViews public static Color ToggleSwitchOnBackground => IsDarkTheme ? Color.FromRgb(0, 122, 204) : Color.FromRgb(53, 132, 228); public static Color ToggleSwitchOffBackground => IsDarkTheme ? ButtonBackground : Color.FromRgb(225, 225, 225); public static Color OptionButtonSelectedBackground => SelectedBackground; - public static Color OptionButtonUnselectedBackground => ButtonBackground; + public static Color OptionButtonUnselectedBackground => Colors.Transparent; public static Color OptionButtonSelectedBorder => IsDarkTheme ? Color.FromRgb(100, 100, 100) : Color.FromRgb(160, 160, 160); - public static Color OptionButtonUnselectedBorder => IsDarkTheme ? Color.FromRgb(90, 90, 90) : Color.FromRgb(220, 220, 220); + public static Color OptionButtonUnselectedBorder => IsDarkTheme ? Color.FromRgb(50, 50, 50) : Color.FromRgb(220, 220, 220); public static Color TextBoxBackground => IsDarkTheme ? Color.FromRgb(43, 43, 43) : Color.FromRgb(255, 255, 255); public static Color TextBoxBorder => IsDarkTheme ? Color.FromRgb(62, 62, 62) : Color.FromRgb(200, 200, 200); public static Color ScrollBarTrack => IsDarkTheme ? Color.FromRgb(25, 25, 25) : Color.FromRgb(243, 243, 243); @@ -586,12 +585,11 @@ namespace Ink_Canvas.Windows.SettingsViews var border = comboBoxItem.Template.FindName("Border", comboBoxItem) as System.Windows.Controls.Border; if (border != null) { - // 优先检查当前状态 if (comboBoxItem.IsSelected) { border.Background = GetSelectedBackgroundBrush(); - border.BorderBrush = new SolidColorBrush(Colors.Transparent); - border.BorderThickness = new Thickness(0); + border.BorderBrush = GetBorderPrimaryBrush(); + border.BorderThickness = new Thickness(1); } else if (comboBoxItem.IsMouseOver) { @@ -611,8 +609,7 @@ namespace Ink_Canvas.Windows.SettingsViews } else if (color.R == 245 && color.G == 245 && color.B == 245) { - // 如果当前是悬浮颜色,但 IsMouseOver 为 false,说明鼠标已离开,恢复默认 - border.Background = GetTextBoxBackgroundBrush(); + border.Background = GetHoverBackgroundBrush(); } else if (color.R == 225 && color.G == 225 && color.B == 225) { @@ -648,76 +645,25 @@ namespace Ink_Canvas.Windows.SettingsViews comboBoxItem.MouseLeave += ComboBoxItem_MouseLeave; comboBoxItem.Selected += ComboBoxItem_Selected; comboBoxItem.Unselected += ComboBoxItem_Unselected; - - var descriptor = System.ComponentModel.DependencyPropertyDescriptor.FromProperty( - System.Windows.UIElement.IsMouseOverProperty, typeof(System.Windows.UIElement)); - if (descriptor != null) - { - descriptor.RemoveValueChanged(comboBoxItem, ComboBoxItem_IsMouseOverChanged); - descriptor.AddValueChanged(comboBoxItem, ComboBoxItem_IsMouseOverChanged); - } } catch { } } - - private static void ComboBoxItem_IsMouseOverChanged(object sender, EventArgs e) - { - if (sender is System.Windows.Controls.ComboBoxItem comboBoxItem) - { - comboBoxItem.Dispatcher.BeginInvoke(new Action(() => - { - var border = comboBoxItem.Template?.FindName("Border", comboBoxItem) as System.Windows.Controls.Border; - if (border != null) - { - if (comboBoxItem.IsSelected) - { - border.Background = GetSelectedBackgroundBrush(); - border.BorderBrush = new SolidColorBrush(Colors.Transparent); - border.BorderThickness = new Thickness(0); - } - else if (comboBoxItem.IsMouseOver) - { - border.Background = GetHoverBackgroundBrush(); - border.BorderBrush = new SolidColorBrush(Colors.Transparent); - border.BorderThickness = new Thickness(0); - } - else - { - border.Background = GetTextBoxBackgroundBrush(); - border.BorderBrush = new SolidColorBrush(Colors.Transparent); - border.BorderThickness = new Thickness(0); - } - } - }), System.Windows.Threading.DispatcherPriority.Loaded); - } - } private static void ComboBoxItem_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) { if (sender is System.Windows.Controls.ComboBoxItem comboBoxItem) { - // 使用 Dispatcher 确保在 XAML Trigger 之后执行 - comboBoxItem.Dispatcher.BeginInvoke(new Action(() => + var border = comboBoxItem.Template?.FindName("Border", comboBoxItem) as System.Windows.Controls.Border; + if (border != null) { - var border = comboBoxItem.Template?.FindName("Border", comboBoxItem) as System.Windows.Controls.Border; - if (border != null) + if (!comboBoxItem.IsSelected) { - // 选中状态优先于悬浮状态 - if (comboBoxItem.IsSelected) - { - border.Background = GetSelectedBackgroundBrush(); - border.BorderBrush = new SolidColorBrush(Colors.Transparent); - border.BorderThickness = new Thickness(0); - } - else if (comboBoxItem.IsMouseOver) - { - border.Background = GetHoverBackgroundBrush(); - border.BorderBrush = new SolidColorBrush(Colors.Transparent); - border.BorderThickness = new Thickness(0); - } + border.Background = GetHoverBackgroundBrush(); + border.BorderBrush = new SolidColorBrush(Colors.Transparent); + border.BorderThickness = new Thickness(0); } - }), System.Windows.Threading.DispatcherPriority.Loaded); + } } } private static void ComboBoxItem_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) @@ -730,8 +676,8 @@ namespace Ink_Canvas.Windows.SettingsViews if (comboBoxItem.IsSelected) { border.Background = GetSelectedBackgroundBrush(); - border.BorderBrush = new SolidColorBrush(Colors.Transparent); - border.BorderThickness = new Thickness(0); + border.BorderBrush = GetBorderPrimaryBrush(); + border.BorderThickness = new Thickness(1); } else { @@ -750,8 +696,8 @@ namespace Ink_Canvas.Windows.SettingsViews if (border != null) { border.Background = GetSelectedBackgroundBrush(); - border.BorderBrush = new SolidColorBrush(Colors.Transparent); - border.BorderThickness = new Thickness(0); + border.BorderBrush = GetBorderPrimaryBrush(); + border.BorderThickness = new Thickness(1); } } } @@ -821,13 +767,13 @@ namespace Ink_Canvas.Windows.SettingsViews baseTrigger.Property == System.Windows.Controls.ComboBoxItem.IsSelectedProperty && (bool)baseTrigger.Value == true) { - setterBase.Value = new SolidColorBrush(Colors.Transparent); + setterBase.Value = GetBorderPrimaryBrush(); } else if (setterBase.Property == System.Windows.Controls.Border.BorderThicknessProperty && baseTrigger.Property == System.Windows.Controls.ComboBoxItem.IsSelectedProperty && (bool)baseTrigger.Value == true) { - setterBase.Value = new Thickness(0); + setterBase.Value = new Thickness(1); } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemePanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemePanel.xaml.cs index 2494af0b..55b071f4 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemePanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemePanel.xaml.cs @@ -229,8 +229,8 @@ namespace Ink_Canvas.Windows.SettingsViews { if (toggleSwitch == null) return; toggleSwitch.Background = isOn - ? ThemeHelper.GetToggleSwitchOnBackgroundBrush() - : ThemeHelper.GetToggleSwitchOffBackgroundBrush(); + ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) + : new SolidColorBrush(Color.FromRgb(225, 225, 225)); var innerBorder = toggleSwitch.Child as Border; if (innerBorder != null) { @@ -476,11 +476,23 @@ namespace Ink_Canvas.Windows.SettingsViews var button = this.FindDescendantByName($"{group}{buttonNames[i]}Border") as Border; if (button != null) { - ThemeHelper.SetOptionButtonSelectedState(button, i == selectedIndex); - var textBlock = button.Child as TextBlock; - if (textBlock != null) + if (i == selectedIndex) { - textBlock.FontWeight = i == selectedIndex ? FontWeights.Bold : FontWeights.Normal; + button.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); + var textBlock = button.Child as TextBlock; + if (textBlock != null) + { + textBlock.FontWeight = FontWeights.Bold; + } + } + else + { + button.Background = new SolidColorBrush(Colors.Transparent); + var textBlock = button.Child as TextBlock; + if (textBlock != null) + { + textBlock.FontWeight = FontWeights.Normal; + } } } } @@ -516,7 +528,7 @@ namespace Ink_Canvas.Windows.SettingsViews string childTag = childBorder.Tag?.ToString(); if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) { - ThemeHelper.SetOptionButtonSelectedState(childBorder, false); + childBorder.Background = new SolidColorBrush(Colors.Transparent); var textBlock = childBorder.Child as TextBlock; if (textBlock != null) { @@ -528,7 +540,7 @@ namespace Ink_Canvas.Windows.SettingsViews } // 设置当前按钮为选中状态 - ThemeHelper.SetOptionButtonSelectedState(border, true); + border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); var currentTextBlock = border.Child as TextBlock; if (currentTextBlock != null) { diff --git a/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml.cs index 5eb85f36..4fad4269 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml.cs @@ -1434,7 +1434,7 @@ namespace Ink_Canvas.Windows ClearOtherOptionsInGroup(border, tag); // 设置当前按钮为选中状态 - ThemeHelper.SetOptionButtonSelectedState(border, true); + border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); var textBlock = border.Child as TextBlock; if (textBlock != null) { @@ -1464,7 +1464,7 @@ namespace Ink_Canvas.Windows string childTag = border.Tag?.ToString(); if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(groupName + "_")) { - ThemeHelper.SetOptionButtonSelectedState(border, false); + border.Background = new SolidColorBrush(Colors.Transparent); var textBlock = border.Child as TextBlock; if (textBlock != null) {