diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml index 0f7d72cf..f5a51a09 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml @@ -77,7 +77,7 @@ - + @@ -88,7 +88,7 @@ - + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml.cs index 54b62150..cd0757df 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml.cs @@ -169,7 +169,7 @@ namespace Ink_Canvas.Windows.SettingsViews if (toggleSwitch == null) return; toggleSwitch.Background = isOn ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) - : ThemeHelper.GetButtonBackgroundBrush(); + : new SolidColorBrush(Color.FromRgb(225, 225, 225)); var innerBorder = toggleSwitch.Child as Border; if (innerBorder != null) { diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml index 4c7692e2..fef55676 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml @@ -161,7 +161,7 @@ - + @@ -172,7 +172,7 @@ - + @@ -183,7 +183,7 @@ - + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml.cs index 6d5dc5d9..9e331498 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml.cs @@ -9,75 +9,9 @@ namespace Ink_Canvas.Windows.SettingsViews /// public partial class AppearancePanel : UserControl { - private bool _isLoaded = false; - public AppearancePanel() { InitializeComponent(); - Loaded += AppearancePanel_Loaded; - } - - private void AppearancePanel_Loaded(object sender, RoutedEventArgs e) - { - LoadSettings(); - // 添加触摸支持 - MainWindowSettingsHelper.EnableTouchSupportForControls(this); - // 应用主题 - ApplyTheme(); - _isLoaded = true; - } - - /// - /// 加载设置 - /// - public void LoadSettings() - { - if (MainWindow.Settings == null || MainWindow.Settings.Appearance == null) return; - - _isLoaded = false; - - try - { - var appearance = MainWindow.Settings.Appearance; - - // 浮动工具栏缩放 - if (ViewboxFloatingBarScaleTransformValueSlider != null) - { - double val = appearance.ViewboxFloatingBarScaleTransformValue; - if (val == 0) val = 1.0; - ViewboxFloatingBarScaleTransformValueSlider.Value = val; - if (ViewboxFloatingBarScaleTransformValueText != null) - { - ViewboxFloatingBarScaleTransformValueText.Text = val.ToString("F2"); - } - } - - // 浮动工具栏透明度 - if (ViewboxFloatingBarOpacityValueSlider != null) - { - ViewboxFloatingBarOpacityValueSlider.Value = appearance.ViewboxFloatingBarOpacityValue; - if (ViewboxFloatingBarOpacityValueText != null) - { - ViewboxFloatingBarOpacityValueText.Text = appearance.ViewboxFloatingBarOpacityValue.ToString("F2"); - } - } - - // 浮栏在PPT下透明度 - if (ViewboxFloatingBarOpacityInPPTValueSlider != null) - { - ViewboxFloatingBarOpacityInPPTValueSlider.Value = appearance.ViewboxFloatingBarOpacityInPPTValue; - if (ViewboxFloatingBarOpacityInPPTValueText != null) - { - ViewboxFloatingBarOpacityInPPTValueText.Text = appearance.ViewboxFloatingBarOpacityInPPTValue.ToString("F2"); - } - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine($"加载外观设置时出错: {ex.Message}"); - } - - _isLoaded = true; } public event EventHandler IsTopBarNeedShadowEffect; @@ -110,41 +44,5 @@ namespace Ink_Canvas.Windows.SettingsViews System.Diagnostics.Debug.WriteLine($"AppearancePanel 应用主题时出错: {ex.Message}"); } } - - /// - /// Slider值变化事件处理 - /// - private void ViewboxFloatingBarScaleTransformValueSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) - { - if (!_isLoaded) return; - if (ViewboxFloatingBarScaleTransformValueSlider != null && ViewboxFloatingBarScaleTransformValueText != null) - { - double val = ViewboxFloatingBarScaleTransformValueSlider.Value; - ViewboxFloatingBarScaleTransformValueText.Text = val.ToString("F2"); - MainWindowSettingsHelper.InvokeSliderValueChanged("ViewboxFloatingBarScaleTransformValueSlider", val); - } - } - - private void ViewboxFloatingBarOpacityValueSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) - { - if (!_isLoaded) return; - if (ViewboxFloatingBarOpacityValueSlider != null && ViewboxFloatingBarOpacityValueText != null) - { - double val = ViewboxFloatingBarOpacityValueSlider.Value; - ViewboxFloatingBarOpacityValueText.Text = val.ToString("F2"); - MainWindowSettingsHelper.InvokeSliderValueChanged("ViewboxFloatingBarOpacityValueSlider", val); - } - } - - private void ViewboxFloatingBarOpacityInPPTValueSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) - { - if (!_isLoaded) return; - if (ViewboxFloatingBarOpacityInPPTValueSlider != null && ViewboxFloatingBarOpacityInPPTValueText != null) - { - double val = ViewboxFloatingBarOpacityInPPTValueSlider.Value; - ViewboxFloatingBarOpacityInPPTValueText.Text = val.ToString("F2"); - MainWindowSettingsHelper.InvokeSliderValueChanged("ViewboxFloatingBarOpacityInPPTValueSlider", val); - } - } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml index 37306bed..d5999941 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml @@ -288,8 +288,8 @@ - - + + @@ -304,8 +304,8 @@ - - + + @@ -318,8 +318,8 @@ - - + + @@ -332,8 +332,8 @@ - - + + @@ -346,8 +346,8 @@ - - + + @@ -360,8 +360,8 @@ - - + + @@ -377,8 +377,8 @@ - - + + @@ -391,8 +391,8 @@ - - + + @@ -405,8 +405,8 @@ - - + + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml.cs index d074631b..775be208 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml.cs @@ -1,10 +1,7 @@ -using Ink_Canvas; -using iNKORE.UI.WPF.Helpers; using System; using System.Windows; using System.Windows.Controls; -using System.Windows.Media; -using Application = System.Windows.Application; +using Ink_Canvas.Windows.SettingsViews; namespace Ink_Canvas.Windows.SettingsViews { @@ -34,80 +31,69 @@ namespace Ink_Canvas.Windows.SettingsViews /// /// 加载设置 /// - public void LoadSettings() + private void LoadSettings() { - if (MainWindow.Settings == null || MainWindow.Settings.Automation == null) - { - _isLoaded = true; - return; - } - - _isLoaded = false; - try { + if (MainWindow.Settings == null || MainWindow.Settings.Automation == null) return; + + _isLoaded = false; + var automation = MainWindow.Settings.Automation; // 设置所有 ToggleSwitch 的状态 - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInEasiNote"), automation.IsAutoFoldInEasiNote); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInEasiCamera"), automation.IsAutoFoldInEasiCamera); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInHiteTouchPro"), automation.IsAutoFoldInHiteTouchPro); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInEasiNote3"), automation.IsAutoFoldInEasiNote3); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInEasiNote3C"), automation.IsAutoFoldInEasiNote3C); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInEasiNote5C"), automation.IsAutoFoldInEasiNote5C); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInSeewoPincoTeacher"), automation.IsAutoFoldInSeewoPincoTeacher); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInHiteCamera"), automation.IsAutoFoldInHiteCamera); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInHiteLightBoard"), automation.IsAutoFoldInHiteLightBoard); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInWxBoardMain"), automation.IsAutoFoldInWxBoardMain); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInMSWhiteboard"), automation.IsAutoFoldInMSWhiteboard); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInAdmoxWhiteboard"), automation.IsAutoFoldInAdmoxWhiteboard); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInAdmoxBooth"), automation.IsAutoFoldInAdmoxBooth); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInQPoint"), automation.IsAutoFoldInQPoint); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInYiYunVisualPresenter"), automation.IsAutoFoldInYiYunVisualPresenter); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInMaxHubWhiteboard"), automation.IsAutoFoldInMaxHubWhiteboard); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInPPTSlideShow"), automation.IsAutoFoldInPPTSlideShow); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInEasiNoteIgnoreDesktopAnno"), automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInOldZyBoard"), automation.IsAutoFoldInOldZyBoard); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchKeepFoldAfterSoftwareExit"), automation.KeepFoldAfterSoftwareExit); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillPptService"), automation.IsAutoKillPptService); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillEasiNote"), automation.IsAutoKillEasiNote); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillHiteAnnotation"), automation.IsAutoKillHiteAnnotation); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoEnterAnnotationAfterKillHite"), automation.IsAutoEnterAnnotationAfterKillHite); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillVComYouJiao"), automation.IsAutoKillVComYouJiao); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillSeewoLauncher2DesktopAnnotation"), automation.IsAutoKillSeewoLauncher2DesktopAnnotation); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillInkCanvas"), automation.IsAutoKillInkCanvas); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillICA"), automation.IsAutoKillICA); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillIDT"), automation.IsAutoKillIDT); + SetToggleSwitchState("ToggleSwitchAutoFoldInEasiNote", automation.IsAutoFoldInEasiNote); + SetToggleSwitchState("ToggleSwitchAutoFoldInEasiCamera", automation.IsAutoFoldInEasiCamera); + SetToggleSwitchState("ToggleSwitchAutoFoldInHiteTouchPro", automation.IsAutoFoldInHiteTouchPro); + SetToggleSwitchState("ToggleSwitchAutoFoldInEasiNote3", automation.IsAutoFoldInEasiNote3); + SetToggleSwitchState("ToggleSwitchAutoFoldInEasiNote3C", automation.IsAutoFoldInEasiNote3C); + SetToggleSwitchState("ToggleSwitchAutoFoldInEasiNote5C", automation.IsAutoFoldInEasiNote5C); + SetToggleSwitchState("ToggleSwitchAutoFoldInSeewoPincoTeacher", automation.IsAutoFoldInSeewoPincoTeacher); + SetToggleSwitchState("ToggleSwitchAutoFoldInHiteCamera", automation.IsAutoFoldInHiteCamera); + SetToggleSwitchState("ToggleSwitchAutoFoldInHiteLightBoard", automation.IsAutoFoldInHiteLightBoard); + SetToggleSwitchState("ToggleSwitchAutoFoldInWxBoardMain", automation.IsAutoFoldInWxBoardMain); + SetToggleSwitchState("ToggleSwitchAutoFoldInMSWhiteboard", automation.IsAutoFoldInMSWhiteboard); + SetToggleSwitchState("ToggleSwitchAutoFoldInAdmoxWhiteboard", automation.IsAutoFoldInAdmoxWhiteboard); + SetToggleSwitchState("ToggleSwitchAutoFoldInAdmoxBooth", automation.IsAutoFoldInAdmoxBooth); + SetToggleSwitchState("ToggleSwitchAutoFoldInQPoint", automation.IsAutoFoldInQPoint); + SetToggleSwitchState("ToggleSwitchAutoFoldInYiYunVisualPresenter", automation.IsAutoFoldInYiYunVisualPresenter); + SetToggleSwitchState("ToggleSwitchAutoFoldInMaxHubWhiteboard", automation.IsAutoFoldInMaxHubWhiteboard); + SetToggleSwitchState("ToggleSwitchAutoFoldInPPTSlideShow", automation.IsAutoFoldInPPTSlideShow); + SetToggleSwitchState("ToggleSwitchAutoFoldInEasiNoteIgnoreDesktopAnno", automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno); + SetToggleSwitchState("ToggleSwitchAutoFoldInOldZyBoard", automation.IsAutoFoldInOldZyBoard); + SetToggleSwitchState("ToggleSwitchKeepFoldAfterSoftwareExit", automation.KeepFoldAfterSoftwareExit); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"AutomationPanel 加载设置时出错: {ex.Message}"); } - - _isLoaded = true; - } - - /// - /// 查找ToggleSwitch控件 - /// - private Border FindToggleSwitch(string name) - { - return this.FindDescendantByName(name) as Border; } /// /// 设置 ToggleSwitch 状态 /// - private void SetToggleSwitchState(Border toggleSwitch, bool isOn) + private void SetToggleSwitchState(string name, bool isOn) { - if (toggleSwitch == null) return; - toggleSwitch.Background = isOn - ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) - : ThemeHelper.GetButtonBackgroundBrush(); - var innerBorder = toggleSwitch.Child as Border; - if (innerBorder != null) + try { - innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left; + var border = FindName(name) as System.Windows.Controls.Border; + if (border != null) + { + bool currentState = border.Background.ToString().Contains("3584e4"); + if (currentState != isOn) + { + border.Background = isOn ? new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0x35, 0x84, 0xe4)) : new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0xe1, 0xe1, 0xe1)); + var innerBorder = border.Child as System.Windows.Controls.Border; + if (innerBorder != null) + { + innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left; + } + } + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"AutomationPanel 设置 ToggleSwitch {name} 状态时出错: {ex.Message}"); } } @@ -118,15 +104,12 @@ namespace Ink_Canvas.Windows.SettingsViews { if (!_isLoaded) return; - // 标记事件已处理,防止事件冒泡 - e.Handled = true; - - var border = sender as Border; + var border = sender as System.Windows.Controls.Border; if (border == null) return; - bool isOn = border.Background.ToString() == "#FF3584E4"; - bool newState = !isOn; - SetToggleSwitchState(border, newState); + bool currentState = border.Background.ToString().Contains("3584e4"); + bool newState = !currentState; + SetToggleSwitchState(border.Name, newState); // 通过 MainWindowSettingsHelper 调用 MainWindow 中的方法 string toggleSwitchName = border.Name; diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml index d7cf0aa8..5201d4e1 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml @@ -177,6 +177,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml.cs index 123271a8..63db2229 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml.cs @@ -108,6 +108,15 @@ namespace Ink_Canvas.Windows.SettingsViews // 保留双曲线渐近线 SetOptionButtonState("HyperbolaAsymptote", (int)canvas.HyperbolaAsymptoteOption); + // 绘制圆时显示圆心位置 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchShowCircleCenter"), canvas.ShowCircleCenter); + + // 使用WPF默认贝塞尔曲线平滑 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchFitToCurve"), canvas.FitToCurve && !canvas.UseAdvancedBezierSmoothing); + + // 使用高级贝塞尔曲线平滑 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAdvancedBezierSmoothing"), canvas.UseAdvancedBezierSmoothing); + // 启用异步墨迹平滑 SetToggleSwitchState(FindToggleSwitch("ToggleSwitchUseAsyncInkSmoothing"), canvas.UseAsyncInkSmoothing); @@ -123,6 +132,17 @@ namespace Ink_Canvas.Windows.SettingsViews // 启用直线端点吸附 SetToggleSwitchState(FindToggleSwitch("ToggleSwitchLineEndpointSnapping"), canvas.LineEndpointSnapping); + // 启用墨迹渐隐功能 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableInkFade"), canvas.EnableInkFade); + if (InkFadeTimePanel != null) + { + InkFadeTimePanel.Visibility = canvas.EnableInkFade ? Visibility.Visible : Visibility.Collapsed; + } + if (InkFadeTimeSlider != null) + { + InkFadeTimeSlider.Value = canvas.InkFadeTime; + } + // 定时自动保存墨迹 // 注意:这个设置可能在 Automation 或 Canvas 中,需要根据实际情况调整 // SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableAutoSaveStrokes"), ...); @@ -164,7 +184,7 @@ namespace Ink_Canvas.Windows.SettingsViews if (toggleSwitch == null) return; toggleSwitch.Background = isOn ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) - : ThemeHelper.GetButtonBackgroundBrush(); + : new SolidColorBrush(Color.FromRgb(225, 225, 225)); var innerBorder = toggleSwitch.Child as Border; if (innerBorder != null) { @@ -278,6 +298,33 @@ namespace Ink_Canvas.Windows.SettingsViews MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchCompressPicturesUploaded", newState); break; + case "ShowCircleCenter": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchShowCircleCenter", newState); + break; + + case "FitToCurve": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchFitToCurve", newState); + // 处理互斥逻辑 + if (newState) + { + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAdvancedBezierSmoothing", false); + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAdvancedBezierSmoothing"), false); + } + break; + + case "AdvancedBezierSmoothing": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAdvancedBezierSmoothing", newState); + // 处理互斥逻辑 + if (newState) + { + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchFitToCurve", false); + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchFitToCurve"), false); + } + break; + case "UseAsyncInkSmoothing": // 调用 MainWindow 中的方法 MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAsyncInkSmoothing", newState); @@ -303,6 +350,16 @@ namespace Ink_Canvas.Windows.SettingsViews MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchLineEndpointSnapping", newState); break; + case "EnableInkFade": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableInkFade", newState); + // 更新UI状态 + if (InkFadeTimePanel != null) + { + InkFadeTimePanel.Visibility = newState ? Visibility.Visible : Visibility.Collapsed; + } + break; + case "EnableAutoSaveStrokes": // 调用 MainWindow 中的方法 MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableAutoSaveStrokes", newState); @@ -519,6 +576,17 @@ namespace Ink_Canvas.Windows.SettingsViews /// /// Slider值变化事件处理 /// + private void InkFadeTimeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + if (!_isLoaded) return; + if (InkFadeTimeSlider != null && InkFadeTimeText != null) + { + double value = InkFadeTimeSlider.Value; + InkFadeTimeText.Text = $"{(int)value}ms"; + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("InkFadeTimeSlider", value); + } + } /// /// 应用主题 diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/GesturesPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/GesturesPanel.xaml.cs index 1cc9012d..5e71f8c2 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/GesturesPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/GesturesPanel.xaml.cs @@ -122,7 +122,7 @@ namespace Ink_Canvas.Windows.SettingsViews if (toggleSwitch == null) return; toggleSwitch.Background = isOn ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) - : ThemeHelper.GetButtonBackgroundBrush(); + : new SolidColorBrush(Color.FromRgb(225, 225, 225)); var innerBorder = toggleSwitch.Child as Border; if (innerBorder != null) { @@ -297,8 +297,8 @@ namespace Ink_Canvas.Windows.SettingsViews MainWindowSettingsHelper.UpdateSettingDirectly(() => { if (MainWindow.Settings.Canvas != null) - { - MainWindow.Settings.Canvas.PalmEraserSensitivity = sensitivity; + { + MainWindow.Settings.Canvas.PalmEraserSensitivity = sensitivity; } }, "ComboBoxPalmEraserSensitivity"); } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/InkRecognitionPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/InkRecognitionPanel.xaml index 8ebd1a84..ff5a3bdf 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/InkRecognitionPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/InkRecognitionPanel.xaml @@ -125,7 +125,7 @@ - + @@ -140,7 +140,7 @@ - + @@ -183,7 +183,7 @@ - + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/InkRecognitionPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/InkRecognitionPanel.xaml.cs index bc573bc5..9ec8aa82 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/InkRecognitionPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/InkRecognitionPanel.xaml.cs @@ -1,5 +1,3 @@ -using Ink_Canvas; -using iNKORE.UI.WPF.Helpers; using System; using System.Windows; using System.Windows.Controls; @@ -11,104 +9,9 @@ namespace Ink_Canvas.Windows.SettingsViews /// public partial class InkRecognitionPanel : UserControl { - private bool _isLoaded = false; - public InkRecognitionPanel() { InitializeComponent(); - Loaded += InkRecognitionPanel_Loaded; - } - - private void InkRecognitionPanel_Loaded(object sender, RoutedEventArgs e) - { - LoadSettings(); - // 添加触摸支持 - MainWindowSettingsHelper.EnableTouchSupportForControls(this); - // 应用主题 - ApplyTheme(); - _isLoaded = true; - } - - /// - /// 加载设置 - /// - public void LoadSettings() - { - if (MainWindow.Settings == null || MainWindow.Settings.Canvas == null || MainWindow.Settings.InkToShape == null) return; - - _isLoaded = false; - - try - { - var canvas = MainWindow.Settings.Canvas; - var inkToShape = MainWindow.Settings.InkToShape; - - // 自动拉直线阈值 - if (AutoStraightenLineThresholdSlider != null) - { - AutoStraightenLineThresholdSlider.Value = canvas.AutoStraightenLineThreshold; - if (AutoStraightenLineThresholdText != null) - { - AutoStraightenLineThresholdText.Text = ((int)canvas.AutoStraightenLineThreshold).ToString(); - } - } - - // 灵敏度 - if (LineStraightenSensitivitySlider != null) - { - LineStraightenSensitivitySlider.Value = inkToShape.LineStraightenSensitivity; - if (LineStraightenSensitivityText != null) - { - LineStraightenSensitivityText.Text = inkToShape.LineStraightenSensitivity.ToString("F2"); - } - } - - // 高精度直线拉直 - var toggleSwitchHighPrecisionLineStraighten = this.FindDescendantByName("ToggleSwitchHighPrecisionLineStraighten") as Border; - if (toggleSwitchHighPrecisionLineStraighten != null) - { - bool isOn = canvas.HighPrecisionLineStraighten; - toggleSwitchHighPrecisionLineStraighten.Background = isOn - ? new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(53, 132, 228)) - : ThemeHelper.GetButtonBackgroundBrush(); - var innerBorder = toggleSwitchHighPrecisionLineStraighten.Child as Border; - if (innerBorder != null) - { - innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left; - } - } - - // 直线端点吸附 - var toggleSwitchLineEndpointSnapping = this.FindDescendantByName("ToggleSwitchLineEndpointSnapping") as Border; - if (toggleSwitchLineEndpointSnapping != null) - { - bool isOn = canvas.LineEndpointSnapping; - toggleSwitchLineEndpointSnapping.Background = isOn - ? new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(53, 132, 228)) - : ThemeHelper.GetButtonBackgroundBrush(); - var innerBorder = toggleSwitchLineEndpointSnapping.Child as Border; - if (innerBorder != null) - { - innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left; - } - } - - // 吸附距离 - if (LineEndpointSnappingThresholdSlider != null) - { - LineEndpointSnappingThresholdSlider.Value = canvas.LineEndpointSnappingThreshold; - if (LineEndpointSnappingThresholdText != null) - { - LineEndpointSnappingThresholdText.Text = ((int)canvas.LineEndpointSnappingThreshold).ToString(); - } - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine($"加载墨迹识别设置时出错: {ex.Message}"); - } - - _isLoaded = true; } public event EventHandler IsTopBarNeedShadowEffect; @@ -141,42 +44,6 @@ namespace Ink_Canvas.Windows.SettingsViews System.Diagnostics.Debug.WriteLine($"InkRecognitionPanel 应用主题时出错: {ex.Message}"); } } - - /// - /// Slider值变化事件处理 - /// - private void AutoStraightenLineThresholdSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) - { - if (!_isLoaded) return; - if (AutoStraightenLineThresholdSlider != null && AutoStraightenLineThresholdText != null) - { - double val = AutoStraightenLineThresholdSlider.Value; - AutoStraightenLineThresholdText.Text = ((int)val).ToString(); - MainWindowSettingsHelper.InvokeSliderValueChanged("AutoStraightenLineThresholdSlider", val); - } - } - - private void LineStraightenSensitivitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) - { - if (!_isLoaded) return; - if (LineStraightenSensitivitySlider != null && LineStraightenSensitivityText != null) - { - double val = LineStraightenSensitivitySlider.Value; - LineStraightenSensitivityText.Text = val.ToString("F2"); - MainWindowSettingsHelper.InvokeSliderValueChanged("LineStraightenSensitivitySlider", val); - } - } - - private void LineEndpointSnappingThresholdSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) - { - if (!_isLoaded) return; - if (LineEndpointSnappingThresholdSlider != null && LineEndpointSnappingThresholdText != null) - { - double val = LineEndpointSnappingThresholdSlider.Value; - LineEndpointSnappingThresholdText.Text = ((int)val).ToString(); - MainWindowSettingsHelper.InvokeSliderValueChanged("LineEndpointSnappingThresholdSlider", val); - } - } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/LuckyRandomPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/LuckyRandomPanel.xaml.cs index b16f7c64..64cdb4bc 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/LuckyRandomPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/LuckyRandomPanel.xaml.cs @@ -169,7 +169,7 @@ namespace Ink_Canvas.Windows.SettingsViews if (toggleSwitch == null) return; toggleSwitch.Background = isOn ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) - : ThemeHelper.GetButtonBackgroundBrush(); + : new SolidColorBrush(Color.FromRgb(225, 225, 225)); var innerBorder = toggleSwitch.Child as Border; if (innerBorder != null) { @@ -199,8 +199,7 @@ namespace Ink_Canvas.Windows.SettingsViews { if (i == selectedIndex) { - // 使用主题适配的选中背景颜色 - button.Background = ThemeHelper.GetSelectedBackgroundBrush(); + button.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); var textBlock = button.Child as TextBlock; if (textBlock != null) { @@ -315,8 +314,8 @@ namespace Ink_Canvas.Windows.SettingsViews } } - // 设置当前按钮为选中状态,使用主题适配的选中背景颜色 - border.Background = ThemeHelper.GetSelectedBackgroundBrush(); + // 设置当前按钮为选中状态 + border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); var currentTextBlock = border.Child as TextBlock; if (currentTextBlock != null) { @@ -360,7 +359,7 @@ namespace Ink_Canvas.Windows.SettingsViews // 如果找不到控件,直接更新设置 MainWindowSettingsHelper.UpdateSettingDirectly(() => { - randSettings.ExternalCallerType = callerType; + randSettings.ExternalCallerType = callerType; }, "ComboBoxExternalCallerType"); } } @@ -370,7 +369,7 @@ namespace Ink_Canvas.Windows.SettingsViews // 背景选择逻辑 - 这个设置可能没有对应的方法,直接更新 MainWindowSettingsHelper.UpdateSettingDirectly(() => { - randSettings.SelectedBackgroundIndex = 0; // 默认背景 + randSettings.SelectedBackgroundIndex = 0; // 默认背景 }, "PickNameBackground"); break; } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/MainWindowSettingsHelper.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/MainWindowSettingsHelper.cs index d050560f..a88b64f5 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/MainWindowSettingsHelper.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/MainWindowSettingsHelper.cs @@ -73,51 +73,9 @@ namespace Ink_Canvas.Windows.SettingsViews } } } - else - { - // 如果找不到控件和属性,先更新设置 - // 对于自动收纳相关的设置,直接更新 Settings 对象 - if (toggleSwitchName.StartsWith("ToggleSwitchAutoFold") || toggleSwitchName == "ToggleSwitchKeepFoldAfterSoftwareExit") - { - UpdateAutoFoldSetting(toggleSwitchName, isOn); - - // 对于需要调用 StartOrStoptimerCheckAutoFold 的设置 - if (toggleSwitchName.StartsWith("ToggleSwitchAutoFold") && - !toggleSwitchName.Contains("PPTSlideShow") && - !toggleSwitchName.Contains("KeepFold") && - !toggleSwitchName.Contains("IgnoreDesktopAnno")) - { - try - { - InvokeMainWindowMethod("StartOrStoptimerCheckAutoFold"); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine($"调用 StartOrStoptimerCheckAutoFold 失败: {ex.Message}"); - } - } - - // 通知新设置面板同步状态 - NotifySettingsPanelsSyncState(toggleSwitchName); - return; - } - } - - // 尝试触发事件(可能通过反射调用) + // 即使找不到控件,也尝试触发事件(可能通过反射调用) var toggledMethodName = toggleSwitchName + "_Toggled"; - var method = mainWindow.GetType().GetMethod(toggledMethodName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); - if (method != null) - { - try - { - // 尝试直接调用方法 - InvokeMainWindowMethod(toggledMethodName, null, new RoutedEventArgs()); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine($"调用 {toggledMethodName} 失败: {ex.Message}"); - } - } + InvokeMainWindowMethod(toggledMethodName, null, new RoutedEventArgs()); // 通知新设置面板同步状态 NotifySettingsPanelsSyncState(toggleSwitchName); @@ -148,61 +106,6 @@ namespace Ink_Canvas.Windows.SettingsViews } } - /// - /// 更新自动收纳相关的设置 - /// - private static void UpdateAutoFoldSetting(string toggleSwitchName, bool isOn) - { - try - { - if (MainWindow.Settings?.Automation == null) return; - - // 根据 ToggleSwitch 名称映射到对应的设置属性 - var settingMap = new Dictionary> - { - { "ToggleSwitchAutoFoldInEasiNote", (val) => MainWindow.Settings.Automation.IsAutoFoldInEasiNote = val }, - { "ToggleSwitchAutoFoldInEasiCamera", (val) => MainWindow.Settings.Automation.IsAutoFoldInEasiCamera = val }, - { "ToggleSwitchAutoFoldInHiteTouchPro", (val) => MainWindow.Settings.Automation.IsAutoFoldInHiteTouchPro = val }, - { "ToggleSwitchAutoFoldInEasiNote3", (val) => MainWindow.Settings.Automation.IsAutoFoldInEasiNote3 = val }, - { "ToggleSwitchAutoFoldInEasiNote3C", (val) => MainWindow.Settings.Automation.IsAutoFoldInEasiNote3C = val }, - { "ToggleSwitchAutoFoldInEasiNote5C", (val) => MainWindow.Settings.Automation.IsAutoFoldInEasiNote5C = val }, - { "ToggleSwitchAutoFoldInSeewoPincoTeacher", (val) => MainWindow.Settings.Automation.IsAutoFoldInSeewoPincoTeacher = val }, - { "ToggleSwitchAutoFoldInHiteCamera", (val) => MainWindow.Settings.Automation.IsAutoFoldInHiteCamera = val }, - { "ToggleSwitchAutoFoldInHiteLightBoard", (val) => MainWindow.Settings.Automation.IsAutoFoldInHiteLightBoard = val }, - { "ToggleSwitchAutoFoldInWxBoardMain", (val) => MainWindow.Settings.Automation.IsAutoFoldInWxBoardMain = val }, - { "ToggleSwitchAutoFoldInMSWhiteboard", (val) => MainWindow.Settings.Automation.IsAutoFoldInMSWhiteboard = val }, - { "ToggleSwitchAutoFoldInAdmoxWhiteboard", (val) => MainWindow.Settings.Automation.IsAutoFoldInAdmoxWhiteboard = val }, - { "ToggleSwitchAutoFoldInAdmoxBooth", (val) => MainWindow.Settings.Automation.IsAutoFoldInAdmoxBooth = val }, - { "ToggleSwitchAutoFoldInQPoint", (val) => MainWindow.Settings.Automation.IsAutoFoldInQPoint = val }, - { "ToggleSwitchAutoFoldInYiYunVisualPresenter", (val) => MainWindow.Settings.Automation.IsAutoFoldInYiYunVisualPresenter = val }, - { "ToggleSwitchAutoFoldInMaxHubWhiteboard", (val) => MainWindow.Settings.Automation.IsAutoFoldInMaxHubWhiteboard = val }, - { "ToggleSwitchAutoFoldInPPTSlideShow", (val) => MainWindow.Settings.Automation.IsAutoFoldInPPTSlideShow = val }, - { "ToggleSwitchAutoFoldInEasiNoteIgnoreDesktopAnno", (val) => MainWindow.Settings.Automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno = val }, - { "ToggleSwitchAutoFoldInOldZyBoard", (val) => MainWindow.Settings.Automation.IsAutoFoldInOldZyBoard = val }, - { "ToggleSwitchKeepFoldAfterSoftwareExit", (val) => MainWindow.Settings.Automation.KeepFoldAfterSoftwareExit = val } - }; - - if (settingMap.ContainsKey(toggleSwitchName)) - { - settingMap[toggleSwitchName](isOn); - MainWindow.SaveSettingsToFile(); - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine($"更新自动收纳设置失败: {ex.Message}"); - } - } - - /// - /// ToggleSwitch 包装类,用于在找不到实际控件时模拟 ToggleSwitch - /// - private class ToggleSwitchWrapper - { - public bool IsOn { get; set; } - public string Name { get; set; } - } - /// /// 调用 MainWindow 中的 ComboBox 事件处理方法 /// diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml index 196732e6..a530fc2e 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml @@ -169,12 +169,12 @@ - - - - - - + + + + + + @@ -182,7 +182,7 @@ - + @@ -201,7 +201,7 @@ - + @@ -252,11 +252,11 @@ - - - - - + + + + + @@ -299,11 +299,11 @@ - - - - - + + + + + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml.cs index c58b51eb..be535ad7 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml.cs @@ -261,7 +261,7 @@ namespace Ink_Canvas.Windows.SettingsViews if (toggleSwitch == null) return; toggleSwitch.Background = isOn ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) - : ThemeHelper.GetButtonBackgroundBrush(); + : new SolidColorBrush(Color.FromRgb(225, 225, 225)); var innerBorder = toggleSwitch.Child as Border; if (innerBorder != null) { @@ -497,7 +497,7 @@ namespace Ink_Canvas.Windows.SettingsViews } MainWindowSettingsHelper.UpdateSettingDirectly(() => { - pptSettings.PPTTimeCapsulePosition = position; + pptSettings.PPTTimeCapsulePosition = position; }, "PPTTimeCapsulePosition"); break; } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/SettingsPanelBase.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/SettingsPanelBase.cs index 01e9d926..6f4db549 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/SettingsPanelBase.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/SettingsPanelBase.cs @@ -182,7 +182,7 @@ namespace Ink_Canvas.Windows.SettingsViews if (toggleSwitch == null) return; toggleSwitch.Background = isOn ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) - : ThemeHelper.GetButtonBackgroundBrush(); + : new SolidColorBrush(Color.FromRgb(225, 225, 225)); var innerBorder = toggleSwitch.Child as Border; if (innerBorder != null) { diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/SnapshotPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/SnapshotPanel.xaml index 16d9cbb3..00dfc551 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/SnapshotPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/SnapshotPanel.xaml @@ -119,78 +119,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/SnapshotPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/SnapshotPanel.xaml.cs index 7ee1c8f8..6d7f0dc8 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/SnapshotPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/SnapshotPanel.xaml.cs @@ -135,36 +135,6 @@ namespace Ink_Canvas.Windows.SettingsViews { SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoSaveScreenShotInPowerPoint"), MainWindow.Settings.PowerPointSettings.IsAutoSaveScreenShotInPowerPoint); } - - // 墨迹设置 - if (MainWindow.Settings.Canvas != null) - { - var canvas = MainWindow.Settings.Canvas; - - // 绘制圆时显示圆心位置 - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchShowCircleCenter"), canvas.ShowCircleCenter); - - // 使用WPF默认贝塞尔曲线平滑 - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchFitToCurve"), canvas.FitToCurve && !canvas.UseAdvancedBezierSmoothing); - - // 使用高级贝塞尔曲线平滑 - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAdvancedBezierSmoothing"), canvas.UseAdvancedBezierSmoothing); - - // 启用墨迹渐隐功能 - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableInkFade"), canvas.EnableInkFade); - if (InkFadeTimePanel != null) - { - InkFadeTimePanel.Visibility = canvas.EnableInkFade ? Visibility.Visible : Visibility.Collapsed; - } - if (InkFadeTimeSlider != null) - { - InkFadeTimeSlider.Value = canvas.InkFadeTime; - if (InkFadeTimeText != null) - { - InkFadeTimeText.Text = $"{canvas.InkFadeTime}ms"; - } - } - } } catch (Exception ex) { @@ -190,7 +160,7 @@ namespace Ink_Canvas.Windows.SettingsViews if (toggleSwitch == null) return; toggleSwitch.Background = isOn ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) - : ThemeHelper.GetButtonBackgroundBrush(); + : new SolidColorBrush(Color.FromRgb(225, 225, 225)); var innerBorder = toggleSwitch.Child as Border; if (innerBorder != null) { @@ -246,43 +216,6 @@ namespace Ink_Canvas.Windows.SettingsViews AutoDelIntervalPanel.Visibility = newState ? Visibility.Visible : Visibility.Collapsed; } break; - - case "ShowCircleCenter": - // 调用 MainWindow 中的方法 - MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchShowCircleCenter", newState); - break; - - case "FitToCurve": - // 调用 MainWindow 中的方法 - MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchFitToCurve", newState); - // 处理互斥逻辑 - if (newState) - { - MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAdvancedBezierSmoothing", false); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAdvancedBezierSmoothing"), false); - } - break; - - case "AdvancedBezierSmoothing": - // 调用 MainWindow 中的方法 - MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAdvancedBezierSmoothing", newState); - // 处理互斥逻辑 - if (newState) - { - MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchFitToCurve", false); - SetToggleSwitchState(FindToggleSwitch("ToggleSwitchFitToCurve"), false); - } - break; - - case "EnableInkFade": - // 调用 MainWindow 中的方法 - MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableInkFade", newState); - // 更新UI状态 - if (InkFadeTimePanel != null) - { - InkFadeTimePanel.Visibility = newState ? Visibility.Visible : Visibility.Collapsed; - } - break; } } @@ -326,10 +259,10 @@ namespace Ink_Canvas.Windows.SettingsViews { var mainWindow = Application.Current.MainWindow as MainWindow; if (mainWindow != null) - { + { var textBox = mainWindow.FindName("AutoSavedStrokesLocation") as System.Windows.Controls.TextBox; if (textBox != null) - { + { AutoSavedStrokesLocation.Text = textBox.Text; } } @@ -370,21 +303,6 @@ namespace Ink_Canvas.Windows.SettingsViews } } - /// - /// 墨迹渐隐时间滑块值变化事件处理 - /// - private void InkFadeTimeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) - { - if (!_isLoaded) return; - if (InkFadeTimeSlider != null && InkFadeTimeText != null) - { - int value = (int)InkFadeTimeSlider.Value; - InkFadeTimeText.Text = $"{value}ms"; - // 调用 MainWindow 中的方法 - MainWindowSettingsHelper.InvokeSliderValueChanged("InkFadeTimeSlider", value); - } - } - /// /// ComboBox选择变化事件处理 /// @@ -419,17 +337,17 @@ namespace Ink_Canvas.Windows.SettingsViews else { // 如果找不到控件,直接更新设置 - string tag = selectedItem.Tag?.ToString(); - if (!string.IsNullOrEmpty(tag) && tag.StartsWith("AutoDelSavedFilesDaysThreshold_")) - { - string daysStr = tag.Replace("AutoDelSavedFilesDaysThreshold_", ""); - if (int.TryParse(daysStr, out int days)) + string tag = selectedItem.Tag?.ToString(); + if (!string.IsNullOrEmpty(tag) && tag.StartsWith("AutoDelSavedFilesDaysThreshold_")) + { + string daysStr = tag.Replace("AutoDelSavedFilesDaysThreshold_", ""); + if (int.TryParse(daysStr, out int days)) { MainWindowSettingsHelper.UpdateSettingDirectly(() => - { - if (MainWindow.Settings.Automation != null) - { - MainWindow.Settings.Automation.AutoDelSavedFilesDaysThreshold = days; + { + if (MainWindow.Settings.Automation != null) + { + MainWindow.Settings.Automation.AutoDelSavedFilesDaysThreshold = days; } }, "ComboBoxAutoDelSavedFilesDaysThreshold"); } @@ -447,43 +365,12 @@ namespace Ink_Canvas.Windows.SettingsViews try { ThemeHelper.ApplyThemeToControl(this); - - // 为所有 ComboBox 添加 DropDownOpened 事件处理,以便在下拉菜单打开时更新颜色 - UpdateComboBoxDropdownTheme(ComboBoxAutoDelSavedFilesDaysThreshold); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"SnapshotPanel 应用主题时出错: {ex.Message}"); } } - - /// - /// 为 ComboBox 添加下拉菜单主题更新 - /// - private void UpdateComboBoxDropdownTheme(System.Windows.Controls.ComboBox comboBox) - { - if (comboBox == null) return; - - // 移除旧的事件处理(如果存在) - comboBox.DropDownOpened -= ComboBox_DropDownOpened; - // 添加新的事件处理 - comboBox.DropDownOpened += ComboBox_DropDownOpened; - } - - /// - /// ComboBox 下拉菜单打开事件处理 - /// - private void ComboBox_DropDownOpened(object sender, EventArgs e) - { - if (sender is System.Windows.Controls.ComboBox comboBox) - { - // 延迟更新,确保 Popup 已经完全创建 - Dispatcher.BeginInvoke(new Action(() => - { - ThemeHelper.UpdateComboBoxDropdownColors(comboBox); - }), System.Windows.Threading.DispatcherPriority.Loaded); - } - } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/StartupPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/StartupPanel.xaml.cs index 0a725ce6..488c49cf 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 - ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) - : ThemeHelper.GetButtonBackgroundBrush(); + 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) { @@ -511,44 +509,12 @@ namespace Ink_Canvas.Windows.SettingsViews // 使用 ThemeHelper 递归更新其他元素 ThemeHelper.ApplyThemeToControl(this); - - // 为所有 ComboBox 添加 DropDownOpened 事件处理,以便在下拉菜单打开时更新颜色 - UpdateComboBoxDropdownTheme(AutoUpdateWithSilenceStartTimeComboBox); - UpdateComboBoxDropdownTheme(AutoUpdateWithSilenceEndTimeComboBox); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"StartupPanel 应用主题时出错: {ex.Message}"); } } - - /// - /// 为 ComboBox 添加下拉菜单主题更新 - /// - private void UpdateComboBoxDropdownTheme(System.Windows.Controls.ComboBox comboBox) - { - if (comboBox == null) return; - - // 移除旧的事件处理(如果存在) - comboBox.DropDownOpened -= ComboBox_DropDownOpened; - // 添加新的事件处理 - comboBox.DropDownOpened += ComboBox_DropDownOpened; - } - - /// - /// ComboBox 下拉菜单打开事件处理 - /// - private void ComboBox_DropDownOpened(object sender, EventArgs e) - { - if (sender is System.Windows.Controls.ComboBox comboBox) - { - // 延迟更新,确保 Popup 已经完全创建 - Dispatcher.BeginInvoke(new Action(() => - { - ThemeHelper.UpdateComboBoxDropdownColors(comboBox); - }), System.Windows.Threading.DispatcherPriority.Loaded); - } - } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemeHelper.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemeHelper.cs index 8459e72d..7bcedb6e 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemeHelper.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemeHelper.cs @@ -1,5 +1,3 @@ -using System; -using System.Windows; using System.Windows.Media; using Ink_Canvas; @@ -278,28 +276,6 @@ namespace Ink_Canvas.Windows.SettingsViews comboBox.Foreground = GetTextPrimaryBrush(); } } - // 更新 ComboBox 背景色 - var background = comboBox.Background as SolidColorBrush; - if (background != null) - { - var color = background.Color; - if (color.R == 255 && color.G == 255 && color.B == 255) // 白色背景 - { - comboBox.Background = GetTextBoxBackgroundBrush(); - } - } - // 更新 ComboBox 边框颜色 - var borderBrush = comboBox.BorderBrush as SolidColorBrush; - if (borderBrush != null) - { - var color = borderBrush.Color; - if (color.R == 230 && color.G == 230 && color.B == 230) // #e6e6e6 - { - comboBox.BorderBrush = GetBorderPrimaryBrush(); - } - } - // 更新 ComboBoxItem 颜色 - UpdateComboBoxItemColors(comboBox); } UpdateInputControlsColors(child); } @@ -477,396 +453,6 @@ namespace Ink_Canvas.Windows.SettingsViews }; } - /// - /// 更新 ComboBoxItem 的颜色 - /// - private static void UpdateComboBoxItemColors(System.Windows.Controls.ComboBox comboBox) - { - try - { - // 更新下拉菜单中的 ComboBoxItem - if (comboBox.Items.Count > 0) - { - foreach (var item in comboBox.Items) - { - if (item is System.Windows.Controls.ComboBoxItem comboBoxItem) - { - var foreground = comboBoxItem.Foreground as SolidColorBrush; - if (foreground != null) - { - var color = foreground.Color; - if (color.R == 46 && color.G == 52 && color.B == 54) // #2e3436 - { - comboBoxItem.Foreground = GetTextPrimaryBrush(); - } - } - var background = comboBoxItem.Background as SolidColorBrush; - if (background != null) - { - var color = background.Color; - if (color.R == 255 && color.G == 255 && color.B == 255) // 白色背景 - { - comboBoxItem.Background = GetTextBoxBackgroundBrush(); - } - } - } - } - } - } - catch - { - // 忽略错误 - } - } - - /// - /// 更新 ComboBox 下拉菜单的颜色(在 ComboBox 打开时调用) - /// - public static void UpdateComboBoxDropdownColors(System.Windows.Controls.ComboBox comboBox) - { - try - { - if (comboBox == null || !comboBox.IsDropDownOpen) return; - - // 通过 VisualTreeHelper 查找 Popup - System.Windows.Controls.Primitives.Popup popup = null; - for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(comboBox); i++) - { - var child = System.Windows.Media.VisualTreeHelper.GetChild(comboBox, i); - if (child is System.Windows.Controls.Primitives.Popup foundPopup) - { - popup = foundPopup; - break; - } - // 递归查找 - popup = FindPopupInVisualTree(child); - if (popup != null) break; - } - - if (popup == null) - { - // 如果找不到,尝试通过模板查找 - if (comboBox.Template != null) - { - popup = comboBox.Template.FindName("Popup", comboBox) as System.Windows.Controls.Primitives.Popup; - } - } - - if (popup != null && popup.Child is System.Windows.Controls.Border popupBorder) - { - // 更新下拉菜单背景色 - var background = popupBorder.Background as SolidColorBrush; - if (background != null) - { - var color = background.Color; - if (color.R == 255 && color.G == 255 && color.B == 255) // 白色背景 - { - popupBorder.Background = GetTextBoxBackgroundBrush(); - } - } - // 更新下拉菜单边框颜色 - var borderBrush = popupBorder.BorderBrush as SolidColorBrush; - if (borderBrush != null) - { - var color = borderBrush.Color; - if (color.R == 230 && color.G == 230 && color.B == 230) // #e6e6e6 - { - popupBorder.BorderBrush = GetBorderPrimaryBrush(); - } - } - // 更新下拉菜单中的 ComboBoxItem - UpdateComboBoxItemColorsInPopup(popupBorder); - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine($"更新 ComboBox 下拉菜单颜色时出错: {ex.Message}"); - } - } - - /// - /// 在可视化树中查找 Popup - /// - private static System.Windows.Controls.Primitives.Popup FindPopupInVisualTree(System.Windows.DependencyObject parent) - { - if (parent == null) return null; - - if (parent is System.Windows.Controls.Primitives.Popup popup) - { - return popup; - } - - for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(parent); i++) - { - var child = System.Windows.Media.VisualTreeHelper.GetChild(parent, i); - var found = FindPopupInVisualTree(child); - if (found != null) return found; - } - - return null; - } - - /// - /// 更新 ComboBox 下拉菜单的背景色(通过 Popup) - /// - public static void UpdateComboBoxPopupColors(System.Windows.DependencyObject parent) - { - for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(parent); i++) - { - var child = System.Windows.Media.VisualTreeHelper.GetChild(parent, i); - if (child is System.Windows.Controls.Primitives.Popup popup) - { - // 查找 Popup 中的 Border(下拉菜单容器) - if (popup.Child is System.Windows.Controls.Border popupBorder) - { - var background = popupBorder.Background as SolidColorBrush; - if (background != null) - { - var color = background.Color; - if (color.R == 255 && color.G == 255 && color.B == 255) // 白色背景 - { - popupBorder.Background = GetTextBoxBackgroundBrush(); - } - } - var borderBrush = popupBorder.BorderBrush as SolidColorBrush; - if (borderBrush != null) - { - var color = borderBrush.Color; - if (color.R == 230 && color.G == 230 && color.B == 230) // #e6e6e6 - { - popupBorder.BorderBrush = GetBorderPrimaryBrush(); - } - } - // 递归更新 Popup 内部的 ComboBoxItem - UpdateComboBoxItemColorsInPopup(popupBorder); - } - } - UpdateComboBoxPopupColors(child); - } - } - - /// - /// 更新 Popup 内部的 ComboBoxItem 颜色 - /// - private static void UpdateComboBoxItemColorsInPopup(System.Windows.DependencyObject parent) - { - for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(parent); i++) - { - var child = System.Windows.Media.VisualTreeHelper.GetChild(parent, i); - if (child is System.Windows.Controls.ComboBoxItem comboBoxItem) - { - var foreground = comboBoxItem.Foreground as SolidColorBrush; - if (foreground != null) - { - var color = foreground.Color; - if (color.R == 46 && color.G == 52 && color.B == 54) // #2e3436 - { - comboBoxItem.Foreground = GetTextPrimaryBrush(); - } - } - // 更新默认背景 - var background = comboBoxItem.Background as SolidColorBrush; - if (background != null) - { - var color = background.Color; - if (color.R == 255 && color.G == 255 && color.B == 255) // 白色背景 - { - comboBoxItem.Background = GetTextBoxBackgroundBrush(); - } - } - // 更新样式触发器中的颜色 - UpdateComboBoxItemStyleTriggers(comboBoxItem); - // 更新模板中的 Border 背景色 - UpdateComboBoxItemTemplateBorder(comboBoxItem); - // 为 ComboBoxItem 添加状态变化监听 - AttachComboBoxItemStateHandlers(comboBoxItem); - } - UpdateComboBoxItemColorsInPopup(child); - } - } - - /// - /// 更新 ComboBoxItem 模板中的 Border 背景色 - /// - private static void UpdateComboBoxItemTemplateBorder(System.Windows.Controls.ComboBoxItem comboBoxItem) - { - try - { - if (comboBoxItem.Template == null) return; - - // 查找模板中的 Border - var border = comboBoxItem.Template.FindName("Border", comboBoxItem) as System.Windows.Controls.Border; - if (border != null) - { - var background = border.Background as SolidColorBrush; - if (background != null) - { - var color = background.Color; - // 根据当前状态更新背景色 - if (comboBoxItem.IsSelected) - { - border.Background = GetSelectedBackgroundBrush(); - } - else if (comboBoxItem.IsMouseOver) - { - border.Background = GetHoverBackgroundBrush(); - } - else if (color.R == 255 && color.G == 255 && color.B == 255) // 白色背景 - { - border.Background = GetTextBoxBackgroundBrush(); - } - else if (color.R == 245 && color.G == 245 && color.B == 245) // #f5f5f5 悬停背景 - { - border.Background = GetHoverBackgroundBrush(); - } - else if (color.R == 225 && color.G == 225 && color.B == 225) // #e1e1e1 选中背景 - { - border.Background = GetSelectedBackgroundBrush(); - } - } - } - } - catch - { - // 忽略错误 - } - } - - /// - /// 为 ComboBoxItem 添加状态变化监听 - /// - private static void AttachComboBoxItemStateHandlers(System.Windows.Controls.ComboBoxItem comboBoxItem) - { - try - { - // 移除旧的事件处理(如果存在) - comboBoxItem.MouseEnter -= ComboBoxItem_MouseEnter; - comboBoxItem.MouseLeave -= ComboBoxItem_MouseLeave; - comboBoxItem.Selected -= ComboBoxItem_Selected; - comboBoxItem.Unselected -= ComboBoxItem_Unselected; - - // 添加新的事件处理 - comboBoxItem.MouseEnter += ComboBoxItem_MouseEnter; - comboBoxItem.MouseLeave += ComboBoxItem_MouseLeave; - comboBoxItem.Selected += ComboBoxItem_Selected; - comboBoxItem.Unselected += ComboBoxItem_Unselected; - } - catch - { - // 忽略错误 - } - } - - /// - /// ComboBoxItem 鼠标进入事件处理 - /// - private static void ComboBoxItem_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) - { - if (sender is System.Windows.Controls.ComboBoxItem comboBoxItem && !comboBoxItem.IsSelected) - { - var border = comboBoxItem.Template?.FindName("Border", comboBoxItem) as System.Windows.Controls.Border; - if (border != null) - { - border.Background = GetHoverBackgroundBrush(); - } - } - } - - /// - /// ComboBoxItem 鼠标离开事件处理 - /// - private static void ComboBoxItem_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) - { - if (sender is System.Windows.Controls.ComboBoxItem comboBoxItem && !comboBoxItem.IsSelected) - { - var border = comboBoxItem.Template?.FindName("Border", comboBoxItem) as System.Windows.Controls.Border; - if (border != null) - { - border.Background = GetTextBoxBackgroundBrush(); - } - } - } - - /// - /// ComboBoxItem 选中事件处理 - /// - private static void ComboBoxItem_Selected(object sender, RoutedEventArgs e) - { - if (sender is System.Windows.Controls.ComboBoxItem comboBoxItem) - { - var border = comboBoxItem.Template?.FindName("Border", comboBoxItem) as System.Windows.Controls.Border; - if (border != null) - { - border.Background = GetSelectedBackgroundBrush(); - } - } - } - - /// - /// ComboBoxItem 取消选中事件处理 - /// - private static void ComboBoxItem_Unselected(object sender, RoutedEventArgs e) - { - if (sender is System.Windows.Controls.ComboBoxItem comboBoxItem) - { - var border = comboBoxItem.Template?.FindName("Border", comboBoxItem) as System.Windows.Controls.Border; - if (border != null) - { - if (comboBoxItem.IsMouseOver) - { - border.Background = GetHoverBackgroundBrush(); - } - else - { - border.Background = GetTextBoxBackgroundBrush(); - } - } - } - } - - /// - /// 更新 ComboBoxItem 样式触发器中的颜色 - /// - private static void UpdateComboBoxItemStyleTriggers(System.Windows.Controls.ComboBoxItem comboBoxItem) - { - try - { - if (comboBoxItem.Style == null) return; - - // 更新样式触发器中的颜色 - foreach (var trigger in comboBoxItem.Style.Triggers) - { - if (trigger is System.Windows.Trigger baseTrigger) - { - foreach (var setter in baseTrigger.Setters) - { - if (setter is System.Windows.Setter setterBase) - { - // 更新悬停背景色 - if (setterBase.Property == System.Windows.Controls.Control.BackgroundProperty && - setterBase.Value is SolidColorBrush brush) - { - var color = brush.Color; - if (color.R == 245 && color.G == 245 && color.B == 245) // #f5f5f5 悬停背景 - { - setterBase.Value = GetHoverBackgroundBrush(); - } - else if (color.R == 225 && color.G == 225 && color.B == 225) // #e1e1e1 选中背景 - { - setterBase.Value = GetSelectedBackgroundBrush(); - } - } - } - } - } - } - } - catch - { - // 忽略错误 - } - } - /// /// 应用主题到整个控件树 /// @@ -878,7 +464,6 @@ namespace Ink_Canvas.Windows.SettingsViews UpdateInputControlsColors(control); UpdateButtonColors(control); UpdateImageIconColors(control); - UpdateComboBoxPopupColors(control); } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemePanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemePanel.xaml.cs index 93ab079a..55b071f4 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemePanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/ThemePanel.xaml.cs @@ -230,7 +230,7 @@ namespace Ink_Canvas.Windows.SettingsViews if (toggleSwitch == null) return; toggleSwitch.Background = isOn ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) - : ThemeHelper.GetButtonBackgroundBrush(); + : new SolidColorBrush(Color.FromRgb(225, 225, 225)); var innerBorder = toggleSwitch.Child as Border; if (innerBorder != null) { @@ -563,22 +563,22 @@ namespace Ink_Canvas.Windows.SettingsViews if (comboBox != null) { // 根据 value 找到对应的 ComboBoxItem - int themeIndex; - switch (value) - { - case "Light": - themeIndex = 0; - break; - case "Dark": - themeIndex = 1; - break; - case "System": - themeIndex = 2; - break; - default: - themeIndex = 2; - break; - } + int themeIndex; + switch (value) + { + case "Light": + themeIndex = 0; + break; + case "Dark": + themeIndex = 1; + break; + case "System": + themeIndex = 2; + break; + default: + themeIndex = 2; + break; + } if (comboBox.Items.Count > themeIndex) { @@ -586,7 +586,7 @@ namespace Ink_Canvas.Windows.SettingsViews MainWindowSettingsHelper.InvokeComboBoxSelectionChangedWithThemeCheck("ComboBoxTheme", selectedItem); } else - { + { // 如果找不到控件,直接更新设置并通知主题更新 MainWindowSettingsHelper.UpdateSettingSafely(() => { @@ -622,9 +622,9 @@ namespace Ink_Canvas.Windows.SettingsViews appearance.Theme = themeIndex; }, "ComboBoxTheme_SelectionChanged", "ComboBoxTheme"); MainWindowSettingsHelper.NotifyThemeUpdateIfNeeded("ComboBoxTheme"); - - // 触发主题变化事件,通知设置窗口更新主题 - ThemeChanged?.Invoke(this, new RoutedEventArgs()); + + // 触发主题变化事件,通知设置窗口更新主题 + ThemeChanged?.Invoke(this, new RoutedEventArgs()); } } } @@ -669,7 +669,7 @@ namespace Ink_Canvas.Windows.SettingsViews // 如果找不到控件,直接更新设置 MainWindowSettingsHelper.UpdateSettingDirectly(() => { - appearance.ChickenSoupSource = sourceIndex; + appearance.ChickenSoupSource = sourceIndex; }, "ComboBoxChickenSoupSource"); } } @@ -704,7 +704,7 @@ namespace Ink_Canvas.Windows.SettingsViews // 如果找不到控件,直接更新设置并通知主题更新 MainWindowSettingsHelper.UpdateSettingSafely(() => { - appearance.UnFoldButtonImageType = imgType; + appearance.UnFoldButtonImageType = imgType; }, "ComboBoxUnFoldBtnImg_SelectionChanged", "ComboBoxUnFoldBtnImg"); MainWindowSettingsHelper.NotifyThemeUpdateIfNeeded("ComboBoxUnFoldBtnImg"); } @@ -740,7 +740,7 @@ namespace Ink_Canvas.Windows.SettingsViews // 如果找不到控件,直接更新设置 MainWindowSettingsHelper.UpdateSettingDirectly(() => { - appearance.QuickColorPaletteDisplayMode = displayMode; + appearance.QuickColorPaletteDisplayMode = displayMode; }, "ComboBoxQuickColorPaletteDisplayMode"); } } @@ -781,7 +781,7 @@ namespace Ink_Canvas.Windows.SettingsViews // 如果找不到控件,直接更新设置 MainWindowSettingsHelper.UpdateSettingDirectly(() => { - appearance.EraserDisplayOption = eraserOption; + appearance.EraserDisplayOption = eraserOption; }, "ComboBoxEraserDisplayOption"); } } @@ -797,44 +797,12 @@ namespace Ink_Canvas.Windows.SettingsViews try { ThemeHelper.ApplyThemeToControl(this); - - // 为所有 ComboBox 添加 DropDownOpened 事件处理,以便在下拉菜单打开时更新颜色 - UpdateComboBoxDropdownTheme(ComboBoxSplashScreenStyle); - UpdateComboBoxDropdownTheme(ComboBoxFloatingBarImg); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"ThemePanel 应用主题时出错: {ex.Message}"); } } - - /// - /// 为 ComboBox 添加下拉菜单主题更新 - /// - private void UpdateComboBoxDropdownTheme(System.Windows.Controls.ComboBox comboBox) - { - if (comboBox == null) return; - - // 移除旧的事件处理(如果存在) - comboBox.DropDownOpened -= ComboBox_DropDownOpened; - // 添加新的事件处理 - comboBox.DropDownOpened += ComboBox_DropDownOpened; - } - - /// - /// ComboBox 下拉菜单打开事件处理 - /// - private void ComboBox_DropDownOpened(object sender, EventArgs e) - { - if (sender is System.Windows.Controls.ComboBox comboBox) - { - // 延迟更新,确保 Popup 已经完全创建 - Dispatcher.BeginInvoke(new Action(() => - { - ThemeHelper.UpdateComboBoxDropdownColors(comboBox); - }), System.Windows.Threading.DispatcherPriority.Loaded); - } - } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/TimerPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/TimerPanel.xaml index 3060ba1a..b58b2401 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/TimerPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/TimerPanel.xaml @@ -94,7 +94,7 @@ - + @@ -125,7 +125,7 @@ - + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/TimerPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/TimerPanel.xaml.cs index 98f6b223..1d0ee8c6 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/TimerPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/TimerPanel.xaml.cs @@ -1,5 +1,3 @@ -using Ink_Canvas; -using iNKORE.UI.WPF.Helpers; using System; using System.Windows; using System.Windows.Controls; @@ -11,87 +9,9 @@ namespace Ink_Canvas.Windows.SettingsViews /// public partial class TimerPanel : UserControl { - private bool _isLoaded = false; - public TimerPanel() { InitializeComponent(); - Loaded += TimerPanel_Loaded; - } - - private void TimerPanel_Loaded(object sender, RoutedEventArgs e) - { - LoadSettings(); - // 添加触摸支持 - MainWindowSettingsHelper.EnableTouchSupportForControls(this); - // 应用主题 - ApplyTheme(); - _isLoaded = true; - } - - /// - /// 加载设置 - /// - public void LoadSettings() - { - if (MainWindow.Settings == null || MainWindow.Settings.RandSettings == null) return; - - _isLoaded = false; - - try - { - var randSettings = MainWindow.Settings.RandSettings; - - // 定时器音量 - if (TimerVolumeSlider != null) - { - TimerVolumeSlider.Value = randSettings.TimerVolume; - if (TimerVolumeText != null) - { - TimerVolumeText.Text = (randSettings.TimerVolume * 100).ToString("F0") + "%"; - } - } - - // 渐进提醒 - var toggleSwitchEnableProgressiveReminder = this.FindDescendantByName("ToggleSwitchEnableProgressiveReminder") as Border; - if (toggleSwitchEnableProgressiveReminder != null) - { - bool isOn = randSettings.EnableProgressiveReminder; - toggleSwitchEnableProgressiveReminder.Background = isOn - ? new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(53, 132, 228)) - : ThemeHelper.GetButtonBackgroundBrush(); - var innerBorder = toggleSwitchEnableProgressiveReminder.Child as Border; - if (innerBorder != null) - { - innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left; - } - } - - // 渐进提醒音量面板可见性 - var progressiveReminderVolumePanel = this.FindDescendantByName("ProgressiveReminderVolumePanel") as Grid; - if (progressiveReminderVolumePanel != null) - { - progressiveReminderVolumePanel.Visibility = randSettings.EnableProgressiveReminder - ? Visibility.Visible - : Visibility.Collapsed; - } - - // 渐进提醒音量 - if (ProgressiveReminderVolumeSlider != null) - { - ProgressiveReminderVolumeSlider.Value = randSettings.ProgressiveReminderVolume; - if (ProgressiveReminderVolumeText != null) - { - ProgressiveReminderVolumeText.Text = (randSettings.ProgressiveReminderVolume * 100).ToString("F0") + "%"; - } - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine($"加载定时器设置时出错: {ex.Message}"); - } - - _isLoaded = true; } public event EventHandler IsTopBarNeedShadowEffect; @@ -124,31 +44,6 @@ namespace Ink_Canvas.Windows.SettingsViews System.Diagnostics.Debug.WriteLine($"TimerPanel 应用主题时出错: {ex.Message}"); } } - - /// - /// Slider值变化事件处理 - /// - private void TimerVolumeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) - { - if (!_isLoaded) return; - if (TimerVolumeSlider != null && TimerVolumeText != null) - { - double val = TimerVolumeSlider.Value; - TimerVolumeText.Text = (val * 100).ToString("F0") + "%"; - MainWindowSettingsHelper.InvokeSliderValueChanged("TimerVolumeSlider", val); - } - } - - private void ProgressiveReminderVolumeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) - { - if (!_isLoaded) return; - if (ProgressiveReminderVolumeSlider != null && ProgressiveReminderVolumeText != null) - { - double val = ProgressiveReminderVolumeSlider.Value; - ProgressiveReminderVolumeText.Text = (val * 100).ToString("F0") + "%"; - MainWindowSettingsHelper.InvokeSliderValueChanged("ProgressiveReminderVolumeSlider", val); - } - } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml.cs index 73b1e816..c66b303b 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml.cs @@ -982,7 +982,7 @@ namespace Ink_Canvas.Windows if (SnapshotPane != null) SnapshotPane.Visibility = _selectedSidebarItemName == "SnapshotItem" ? Visibility.Visible : Visibility.Collapsed; if (AdvancedPane != null) AdvancedPane.Visibility = _selectedSidebarItemName == "AdvancedItem" ? Visibility.Visible : Visibility.Collapsed; - // 为新显示的面板加载设置并应用主题 + // 为新显示的面板应用主题(延迟执行,确保面板已完全显示) if (panelMappings.ContainsKey(_selectedSidebarItemName)) { var selectedPanel = panelMappings[_selectedSidebarItemName]; @@ -992,15 +992,6 @@ namespace Ink_Canvas.Windows { try { - // 先加载设置,确保显示的状态与实际一致 - var loadSettingsMethod = selectedPanel.GetType().GetMethod("LoadSettings", - System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); - if (loadSettingsMethod != null) - { - loadSettingsMethod.Invoke(selectedPanel, null); - } - - // 然后应用主题 var applyThemeMethod = selectedPanel.GetType().GetMethod("ApplyTheme", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); if (applyThemeMethod != null) @@ -1010,7 +1001,7 @@ namespace Ink_Canvas.Windows } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine($"切换面板时加载设置和应用主题到 {selectedPanel.GetType().Name} 时出错: {ex.Message}"); + System.Diagnostics.Debug.WriteLine($"切换面板时应用主题到 {selectedPanel.GetType().Name} 时出错: {ex.Message}"); } }), System.Windows.Threading.DispatcherPriority.Loaded); }