diff --git a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs index 7ef88b97..08d3f55b 100644 --- a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs +++ b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs @@ -1,4 +1,6 @@ using Ink_Canvas.Helpers; +using Ink_Canvas.Windows; +using Ink_Canvas.Windows.SettingsViews; using iNKORE.UI.WPF.Modern; using System; using System.Diagnostics; @@ -2874,46 +2876,64 @@ namespace Ink_Canvas private void BtnSettings_Click(object sender, RoutedEventArgs e) { - if (BorderSettings.Visibility == Visibility.Visible) + if (isOpeningOrHidingSettingsPane) return; + HideSubPanels(); { - HideSubPanels(); + var settingsWindow = new SettingsWindow(); + settingsWindow.Owner = this; + settingsWindow.ShowDialog(); } - else + } + + /// + /// 显示老设置面板 + /// + public void ShowOldSettingsPanel() + { + if (isOpeningOrHidingSettingsPane) return; + HideSubPanels(); + + // 关闭新设置窗口 + foreach (Window window in Application.Current.Windows) { - BorderSettings.Visibility = Visibility.Visible; - wasNoFocusModeBeforeSettings = Settings.Advanced.IsNoFocusMode; - userChangedNoFocusModeInSettings = false; // 重置用户修改标志 - if (wasNoFocusModeBeforeSettings) + if (window is SettingsWindow) { - isTemporarilyDisablingNoFocusMode = true; - ApplyNoFocusMode(); + window.Close(); + break; } - - // 设置蒙版为可点击,并添加半透明背景 + } + + // 显示老设置面板 + if (BorderSettings.Visibility != Visibility.Visible) + { + isOpeningOrHidingSettingsPane = true; + BorderSettings.Visibility = Visibility.Visible; + BorderSettingsMask.Visibility = Visibility.Visible; BorderSettingsMask.IsHitTestVisible = true; - BorderSettingsMask.Background = new SolidColorBrush(Color.FromArgb(1, 0, 0, 0)); - SettingsPanelScrollViewer.ScrollToTop(); + BorderSettingsMask.Background = new SolidColorBrush(Color.FromArgb(128, 0, 0, 0)); + + // 设置初始位置 + BorderSettings.RenderTransform = new TranslateTransform(490, 0); + var sb = new Storyboard(); - - // 滑动动画 var slideAnimation = new DoubleAnimation { - From = BorderSettings.RenderTransform.Value.OffsetX - 490, // 滑动距离 + From = 490, To = 0, Duration = TimeSpan.FromSeconds(0.6), EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut } }; Storyboard.SetTargetProperty(slideAnimation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)")); - + Storyboard.SetTarget(slideAnimation, BorderSettings); + sb.Children.Add(slideAnimation); - - sb.Completed += (s, _) => { isOpeningOrHidingSettingsPane = false; }; - - BorderSettings.RenderTransform = new TranslateTransform(); - - isOpeningOrHidingSettingsPane = true; - sb.Begin(BorderSettings); + sb.Completed += (s, _) => + { + isOpeningOrHidingSettingsPane = false; + }; + + sb.Begin(); } } diff --git a/Ink Canvas/MainWindow_cs/MW_Settings.cs b/Ink Canvas/MainWindow_cs/MW_Settings.cs index 312076e7..a9644fdf 100644 --- a/Ink Canvas/MainWindow_cs/MW_Settings.cs +++ b/Ink Canvas/MainWindow_cs/MW_Settings.cs @@ -2750,7 +2750,7 @@ namespace Ink_Canvas Settings.Startup.IsFoldAtStartup = false; } - private void BtnResetToSuggestion_Click(object sender, RoutedEventArgs e) + public void BtnResetToSuggestion_Click(object sender, RoutedEventArgs e) { try { diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml.cs index 3eef3a4a..ec925479 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AboutPanel.xaml.cs @@ -259,5 +259,20 @@ namespace Ink_Canvas.Windows.SettingsViews var border = thumb.Template.FindName("ScrollbarThumbEx", thumb); ((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138)); } + + /// + /// 应用主题 + /// + public void ApplyTheme() + { + try + { + ThemeHelper.ApplyThemeToControl(this); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"AboutPanel 应用主题时出错: {ex.Message}"); + } + } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml index 36ca62eb..f5a51a09 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml @@ -37,7 +37,7 @@ - + @@ -52,7 +52,7 @@ - + @@ -62,7 +62,7 @@ - + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml.cs index 1269c359..cd0757df 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AdvancedPanel.xaml.cs @@ -1,6 +1,11 @@ +using Ink_Canvas; +using iNKORE.UI.WPF.Helpers; using System; +using System.Collections.Generic; using System.Windows; using System.Windows.Controls; +using System.Windows.Media; +using Application = System.Windows.Application; namespace Ink_Canvas.Windows.SettingsViews { @@ -9,9 +14,41 @@ namespace Ink_Canvas.Windows.SettingsViews /// public partial class AdvancedPanel : UserControl { + private bool _isLoaded = false; + public AdvancedPanel() { InitializeComponent(); + Loaded += AdvancedPanel_Loaded; + } + + private void AdvancedPanel_Loaded(object sender, RoutedEventArgs e) + { + LoadSettings(); + // 添加触摸支持 + EnableTouchSupport(); + // 应用主题 + ApplyTheme(); + _isLoaded = true; + } + + /// + /// 为面板中的所有交互控件启用触摸支持 + /// + private void EnableTouchSupport() + { + try + { + // 延迟执行,确保所有控件都已加载 + Dispatcher.BeginInvoke(new Action(() => + { + MainWindowSettingsHelper.EnableTouchSupportForControls(this); + }), System.Windows.Threading.DispatcherPriority.Loaded); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"AdvancedPanel 启用触摸支持时出错: {ex.Message}"); + } } public event EventHandler IsTopBarNeedShadowEffect; @@ -29,6 +66,442 @@ namespace Ink_Canvas.Windows.SettingsViews IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs()); } } + + /// + /// 加载设置到UI + /// + public void LoadSettings() + { + if (MainWindow.Settings == null || MainWindow.Settings.Advanced == null) return; + + _isLoaded = false; + + try + { + var advanced = MainWindow.Settings.Advanced; + + // 特殊屏幕模式 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchIsSpecialScreen"), advanced.IsSpecialScreen); + + // 触摸倍数 + if (TouchMultiplierSlider != null) + { + TouchMultiplierSlider.Value = advanced.TouchMultiplier; + if (TouchMultiplierText != null) + { + TouchMultiplierText.Text = advanced.TouchMultiplier.ToString("F2"); + } + } + + // 橡皮擦绑定触摸大小倍数 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEraserBindTouchMultiplier"), advanced.EraserBindTouchMultiplier); + + // 笔尖模式 BoundsWidth + if (NibModeBoundsWidthSlider != null) + { + NibModeBoundsWidthSlider.Value = advanced.NibModeBoundsWidth; + if (NibModeBoundsWidthText != null) + { + NibModeBoundsWidthText.Text = advanced.NibModeBoundsWidth.ToString(); + } + } + + // 手指模式 BoundsWidth + if (FingerModeBoundsWidthSlider != null) + { + FingerModeBoundsWidthSlider.Value = advanced.FingerModeBoundsWidth; + if (FingerModeBoundsWidthText != null) + { + FingerModeBoundsWidthText.Text = advanced.FingerModeBoundsWidth.ToString(); + } + } + + // 四边红外模式 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchIsQuadIR"), advanced.IsQuadIR); + + // 记录日志 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchIsLogEnabled"), advanced.IsLogEnabled); + + // 日志以日期保存 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchIsSaveLogByDate"), advanced.IsSaveLogByDate); + + // 关闭软件时二次弹窗确认 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchIsSecondConfimeWhenShutdownApp"), advanced.IsSecondConfirmWhenShutdownApp); + + // 实验性功能 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchIsEnableFullScreenHelper"), advanced.IsEnableFullScreenHelper); + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchIsEnableAvoidFullScreenHelper"), advanced.IsEnableAvoidFullScreenHelper); + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchIsEnableEdgeGestureUtil"), advanced.IsEnableEdgeGestureUtil); + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchIsEnableForceFullScreen"), advanced.IsEnableForceFullScreen); + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchIsEnableDPIChangeDetection"), advanced.IsEnableDPIChangeDetection); + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchIsEnableResolutionChangeDetection"), advanced.IsEnableResolutionChangeDetection); + + // 备份设置 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchIsAutoBackupBeforeUpdate"), advanced.IsAutoBackupBeforeUpdate); + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchIsAutoBackupEnabled"), advanced.IsAutoBackupEnabled); + SetOptionButtonState("AutoBackupInterval", advanced.AutoBackupIntervalDays); + + // 悬浮窗拦截 + // 注意:IsEnableFloatingWindowInterception 可能不在 Advanced 类中,需要确认 + // 这里先假设它在 Advanced 类中,如果不在,需要调整 + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"加载高级设置时出错: {ex.Message}"); + } + + _isLoaded = true; + } + + /// + /// 查找ToggleSwitch控件 + /// + private Border FindToggleSwitch(string name) + { + return this.FindDescendantByName(name) as Border; + } + + /// + /// 设置ToggleSwitch状态 + /// + private void SetToggleSwitchState(Border toggleSwitch, bool isOn) + { + if (toggleSwitch == null) return; + 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) + { + innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left; + } + } + + /// + /// 设置选项按钮状态 + /// + private void SetOptionButtonState(string group, int selectedValue) + { + var buttons = new Dictionary> + { + { "AutoBackupInterval", new Dictionary { { 1, "1Day" }, { 3, "3Days" }, { 7, "7Days" }, { 14, "14Days" }, { 30, "30Days" } } } + }; + + if (!buttons.ContainsKey(group)) return; + + var buttonNames = buttons[group]; + if (!buttonNames.ContainsKey(selectedValue)) return; + + string buttonName = buttonNames[selectedValue]; + var button = this.FindDescendantByName($"{group}{buttonName}Border") as Border; + if (button != null) + { + // 清除同组其他按钮的选中状态 + var parent = button.Parent as Panel; + if (parent != null) + { + foreach (var child in parent.Children) + { + if (child is Border childBorder && childBorder != button) + { + string childTag = childBorder.Tag?.ToString(); + if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) + { + childBorder.Background = new SolidColorBrush(Colors.Transparent); + var textBlock = childBorder.Child as TextBlock; + if (textBlock != null) + { + textBlock.FontWeight = FontWeights.Normal; + } + } + } + } + } + + // 设置当前按钮为选中状态 + button.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); + var currentTextBlock = button.Child as TextBlock; + if (currentTextBlock != null) + { + currentTextBlock.FontWeight = FontWeights.Bold; + } + } + } + + /// + /// ToggleSwitch点击事件处理 + /// + private void ToggleSwitch_Click(object sender, RoutedEventArgs e) + { + if (!_isLoaded) return; + + var border = sender as Border; + if (border == null) return; + + bool isOn = border.Background.ToString() == "#FF3584E4"; + bool newState = !isOn; + SetToggleSwitchState(border, newState); + + string tag = border.Tag?.ToString(); + if (string.IsNullOrEmpty(tag)) return; + + var advanced = MainWindow.Settings.Advanced; + if (advanced == null) return; + + switch (tag) + { + case "IsSpecialScreen": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsSpecialScreen", newState); + break; + + case "EraserBindTouchMultiplier": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEraserBindTouchMultiplier", newState); + break; + + case "IsQuadIR": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsQuadIR", newState); + break; + + case "IsLogEnabled": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsLogEnabled", newState); + break; + + case "IsSaveLogByDate": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsSaveLogByDate", newState); + break; + + case "IsSecondConfirmWhenShutdownApp": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsSecondConfimeWhenShutdownApp", newState); + break; + + case "IsEnableFullScreenHelper": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsEnableFullScreenHelper", newState); + break; + + case "IsEnableAvoidFullScreenHelper": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsEnableAvoidFullScreenHelper", newState); + break; + + case "IsEnableEdgeGestureUtil": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsEnableEdgeGestureUtil", newState); + break; + + case "IsEnableForceFullScreen": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsEnableForceFullScreen", newState); + break; + + case "IsEnableDPIChangeDetection": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsEnableDPIChangeDetection", newState); + break; + + case "IsEnableResolutionChangeDetection": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsEnableResolutionChangeDetection", newState); + break; + + case "IsAutoBackupBeforeUpdate": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsAutoBackupBeforeUpdate", newState); + break; + + case "IsAutoBackupEnabled": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsAutoBackupEnabled", newState); + break; + } + } + + /// + /// Slider值变化事件处理 + /// + private void TouchMultiplierSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + if (!_isLoaded) return; + if (TouchMultiplierSlider != null && TouchMultiplierText != null) + { + double value = TouchMultiplierSlider.Value; + TouchMultiplierText.Text = value.ToString("F2"); + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("TouchMultiplierSlider", value); + } + } + + private void NibModeBoundsWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + if (!_isLoaded) return; + if (NibModeBoundsWidthSlider != null && NibModeBoundsWidthText != null) + { + double value = NibModeBoundsWidthSlider.Value; + NibModeBoundsWidthText.Text = ((int)value).ToString(); + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("NibModeBoundsWidthSlider", value); + } + } + + private void FingerModeBoundsWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + if (!_isLoaded) return; + if (FingerModeBoundsWidthSlider != null && FingerModeBoundsWidthText != null) + { + double value = FingerModeBoundsWidthSlider.Value; + FingerModeBoundsWidthText.Text = ((int)value).ToString(); + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("FingerModeBoundsWidthSlider", value); + } + } + + /// + /// 选项按钮点击事件处理 + /// + private void OptionButton_Click(object sender, RoutedEventArgs e) + { + if (!_isLoaded) return; + + var border = sender as Border; + if (border == null) return; + + string tag = border.Tag?.ToString(); + if (string.IsNullOrEmpty(tag)) return; + + string[] parts = tag.Split('_'); + if (parts.Length < 2) return; + + string group = parts[0]; + string value = parts[1]; + + // 清除同组其他按钮的选中状态 + var parent = border.Parent as Panel; + if (parent != null) + { + foreach (var child in parent.Children) + { + if (child is Border childBorder && childBorder != border) + { + string childTag = childBorder.Tag?.ToString(); + if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) + { + childBorder.Background = new SolidColorBrush(Colors.Transparent); + var textBlock = childBorder.Child as TextBlock; + if (textBlock != null) + { + textBlock.FontWeight = FontWeights.Normal; + } + } + } + } + } + + // 设置当前按钮为选中状态 + border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); + var currentTextBlock = border.Child as TextBlock; + if (currentTextBlock != null) + { + currentTextBlock.FontWeight = FontWeights.Bold; + } + + if (MainWindow.Settings.Advanced == null) return; + + switch (group) + { + case "AutoBackupInterval": + int days; + if (int.TryParse(value, out days)) + { + // 尝试调用 MainWindow 中的方法 + var mainWindow = Application.Current.MainWindow as MainWindow; + if (mainWindow != null) + { + var comboBox = mainWindow.FindName("ComboBoxAutoBackupInterval") as System.Windows.Controls.ComboBox; + if (comboBox != null) + { + // 找到对应的选项并设置 + foreach (ComboBoxItem item in comboBox.Items) + { + if (item.Tag != null && int.TryParse(item.Tag.ToString(), out int tagValue) && tagValue == days) + { + comboBox.SelectedItem = item; + MainWindowSettingsHelper.InvokeComboBoxSelectionChanged("ComboBoxAutoBackupInterval", item); + break; + } + } + } + else + { + // 如果找不到控件,直接更新设置 + MainWindowSettingsHelper.UpdateSettingDirectly(() => + { + MainWindow.Settings.Advanced.AutoBackupIntervalDays = days; + }, "ComboBoxAutoBackupInterval"); + } + } + } + break; + } + } + + /// + /// 按钮点击事件处理(备份还原、文件关联等) + /// + private void Button_Click(object sender, RoutedEventArgs e) + { + var button = sender as Button; + if (button == null) return; + + string name = button.Name; + // 这些按钮的功能可能需要调用 MainWindow 中的方法 + // 暂时先留空,后续可以根据需要实现 + switch (name) + { + case "BtnManualBackup": + // TODO: 调用 MainWindow 的备份方法 + break; + + case "BtnRestoreBackup": + // TODO: 调用 MainWindow 的还原方法 + break; + + case "BtnUnregisterFileAssociation": + // TODO: 调用 MainWindow 的取消文件关联方法 + break; + + case "BtnCheckFileAssociation": + // TODO: 调用 MainWindow 的检查文件关联方法 + break; + + case "BtnRegisterFileAssociation": + // TODO: 调用 MainWindow 的注册文件关联方法 + break; + + case "BtnDlassSettingsManage": + // TODO: 调用 MainWindow 的 Dlass 设置管理方法 + break; + } + } + + /// + /// 应用主题 + /// + public void ApplyTheme() + { + try + { + ThemeHelper.ApplyThemeToControl(this); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"AdvancedPanel 应用主题时出错: {ex.Message}"); + } + } } } - diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml.cs index 0a3cefd7..9e331498 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AppearancePanel.xaml.cs @@ -29,5 +29,20 @@ namespace Ink_Canvas.Windows.SettingsViews IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs()); } } + + /// + /// 应用主题 + /// + public void ApplyTheme() + { + try + { + ThemeHelper.ApplyThemeToControl(this); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"AppearancePanel 应用主题时出错: {ex.Message}"); + } + } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml index 9a6e26c3..d5999941 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml @@ -43,7 +43,7 @@ - + @@ -54,7 +54,7 @@ - + @@ -65,7 +65,7 @@ - + @@ -76,7 +76,7 @@ - + @@ -88,7 +88,7 @@ - + @@ -99,7 +99,7 @@ - + @@ -110,7 +110,7 @@ - + @@ -121,7 +121,7 @@ - + @@ -133,7 +133,7 @@ - + @@ -144,7 +144,7 @@ - + @@ -155,7 +155,7 @@ - + @@ -166,7 +166,7 @@ - + @@ -178,7 +178,7 @@ - + @@ -189,7 +189,7 @@ - + @@ -200,7 +200,7 @@ - + @@ -211,7 +211,7 @@ - + @@ -226,7 +226,7 @@ - + @@ -240,7 +240,7 @@ - + @@ -254,7 +254,7 @@ - + @@ -268,7 +268,7 @@ - + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml.cs index fc0258e7..775be208 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/AutomationPanel.xaml.cs @@ -1,6 +1,7 @@ using System; using System.Windows; using System.Windows.Controls; +using Ink_Canvas.Windows.SettingsViews; namespace Ink_Canvas.Windows.SettingsViews { @@ -9,9 +10,129 @@ namespace Ink_Canvas.Windows.SettingsViews /// public partial class AutomationPanel : UserControl { + private bool _isLoaded = false; + public AutomationPanel() { InitializeComponent(); + Loaded += AutomationPanel_Loaded; + } + + private void AutomationPanel_Loaded(object sender, RoutedEventArgs e) + { + LoadSettings(); + // 添加触摸支持 + EnableTouchSupport(); + // 应用主题 + ApplyTheme(); + _isLoaded = true; + } + + /// + /// 加载设置 + /// + private void LoadSettings() + { + try + { + if (MainWindow.Settings == null || MainWindow.Settings.Automation == null) return; + + _isLoaded = false; + + var automation = MainWindow.Settings.Automation; + + // 设置所有 ToggleSwitch 的状态 + 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}"); + } + } + + /// + /// 设置 ToggleSwitch 状态 + /// + private void SetToggleSwitchState(string name, bool isOn) + { + try + { + 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}"); + } + } + + /// + /// ToggleSwitch 点击事件处理 + /// + private void ToggleSwitch_Click(object sender, RoutedEventArgs e) + { + if (!_isLoaded) return; + + var border = sender as System.Windows.Controls.Border; + if (border == null) return; + + bool currentState = border.Background.ToString().Contains("3584e4"); + bool newState = !currentState; + SetToggleSwitchState(border.Name, newState); + + // 通过 MainWindowSettingsHelper 调用 MainWindow 中的方法 + string toggleSwitchName = border.Name; + MainWindowSettingsHelper.InvokeToggleSwitchToggled(toggleSwitchName, newState); + } + + /// + /// 为面板中的所有交互控件启用触摸支持 + /// + private void EnableTouchSupport() + { + try + { + // 延迟执行,确保所有控件都已加载 + Dispatcher.BeginInvoke(new Action(() => + { + MainWindowSettingsHelper.EnableTouchSupportForControls(this); + }), System.Windows.Threading.DispatcherPriority.Loaded); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"AutomationPanel 启用触摸支持时出错: {ex.Message}"); + } } public event EventHandler IsTopBarNeedShadowEffect; @@ -29,6 +150,21 @@ namespace Ink_Canvas.Windows.SettingsViews IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs()); } } + + /// + /// 应用主题 + /// + public void ApplyTheme() + { + try + { + ThemeHelper.ApplyThemeToControl(this); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"AutomationPanel 应用主题时出错: {ex.Message}"); + } + } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml index a7207026..5201d4e1 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml @@ -35,7 +35,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -77,19 +77,19 @@ - + - + - + - + - + @@ -105,7 +105,7 @@ - + @@ -119,7 +119,7 @@ - + @@ -133,7 +133,7 @@ - + @@ -147,7 +147,7 @@ - + @@ -166,13 +166,13 @@ - + - + - + @@ -183,7 +183,7 @@ - + @@ -197,7 +197,7 @@ - + @@ -211,7 +211,7 @@ - + @@ -230,7 +230,7 @@ - + @@ -245,7 +245,7 @@ - + @@ -261,7 +261,7 @@ - + @@ -276,25 +276,25 @@ - + - + - + - + - + - + - + @@ -309,7 +309,7 @@ - + @@ -323,7 +323,7 @@ - + @@ -341,7 +341,7 @@ - + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml.cs index ee6180c8..63db2229 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/CanvasAndInkPanel.xaml.cs @@ -1,10 +1,12 @@ +using Ink_Canvas; +using iNKORE.UI.WPF.Helpers; using System; +using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows.Media; -using iNKORE.UI.WPF.Helpers; namespace Ink_Canvas.Windows.SettingsViews { @@ -13,9 +15,41 @@ namespace Ink_Canvas.Windows.SettingsViews /// public partial class CanvasAndInkPanel : UserControl { + private bool _isLoaded = false; + public CanvasAndInkPanel() { InitializeComponent(); + Loaded += CanvasAndInkPanel_Loaded; + } + + private void CanvasAndInkPanel_Loaded(object sender, RoutedEventArgs e) + { + LoadSettings(); + // 添加触摸支持 + EnableTouchSupport(); + // 应用主题 + ApplyTheme(); + _isLoaded = true; + } + + /// + /// 为面板中的所有交互控件启用触摸支持 + /// + private void EnableTouchSupport() + { + try + { + // 延迟执行,确保所有控件都已加载 + Dispatcher.BeginInvoke(new Action(() => + { + MainWindowSettingsHelper.EnableTouchSupportForControls(this); + }), System.Windows.Threading.DispatcherPriority.Loaded); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"CanvasAndInkPanel 启用触摸支持时出错: {ex.Message}"); + } } public event EventHandler IsTopBarNeedShadowEffect; @@ -33,6 +67,541 @@ namespace Ink_Canvas.Windows.SettingsViews IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs()); } } + + /// + /// 加载设置到UI + /// + public void LoadSettings() + { + if (MainWindow.Settings == null || MainWindow.Settings.Canvas == null) return; + + _isLoaded = false; + + try + { + var canvas = MainWindow.Settings.Canvas; + + // 显示画笔光标 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchShowCursor"), canvas.IsShowCursor); + + // 启用压感触屏模式 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnablePressureTouchMode"), canvas.EnablePressureTouchMode); + + // 屏蔽压感 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchDisablePressure"), canvas.DisablePressure); + + // 板擦橡皮大小 + SetOptionButtonState("EraserSize", canvas.EraserSize); + + // 退出画板模式后隐藏墨迹 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchHideStrokeWhenSelecting"), canvas.HideStrokeWhenSelecting); + + // 清空墨迹时删除墨迹历史记录 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchClearCanvasAndClearTimeMachine"), canvas.ClearCanvasAndClearTimeMachine); + + // 清空画布时同时清空图片 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchClearCanvasAlsoClearImages"), canvas.ClearCanvasAlsoClearImages); + + // 插入图片时自动压缩 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchCompressPicturesUploaded"), canvas.IsCompressPicturesUploaded); + + // 保留双曲线渐近线 + 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); + + // 启用硬件加速 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchUseHardwareAcceleration"), canvas.UseHardwareAcceleration); + + // 启用直线自动拉直 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoStraightenLine"), canvas.AutoStraightenLine); + + // 启用高精度直线拉直 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchHighPrecisionLineStraighten"), canvas.HighPrecisionLineStraighten); + + // 启用直线端点吸附 + 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"), ...); + + // 墨迹全页面保存 + // SetToggleSwitchState(FindToggleSwitch("ToggleSwitchSaveFullPageStrokes"), ...); + + // 保存为XML格式 + // SetToggleSwitchState(FindToggleSwitch("ToggleSwitchSaveStrokesAsXML"), ...); + + // 自动保存幻灯片墨迹 + if (MainWindow.Settings.PowerPointSettings != null) + { + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoSaveStrokesInPowerPoint"), + MainWindow.Settings.PowerPointSettings.IsAutoSaveStrokesInPowerPoint); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"加载画板和墨迹设置时出错: {ex.Message}"); + } + + _isLoaded = true; + } + + /// + /// 查找ToggleSwitch控件 + /// + private Border FindToggleSwitch(string name) + { + return this.FindDescendantByName(name) as Border; + } + + /// + /// 设置ToggleSwitch状态 + /// + private void SetToggleSwitchState(Border toggleSwitch, bool isOn) + { + if (toggleSwitch == null) return; + 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) + { + innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left; + } + } + + /// + /// 设置选项按钮状态 + /// + private void SetOptionButtonState(string group, int selectedIndex) + { + var buttons = new[] { "VerySmall", "Small", "Medium", "Large", "VeryLarge" }; + var hyperbolaButtons = new[] { "Yes", "No", "Ask" }; + + string[] buttonNames = group == "EraserSize" ? buttons : hyperbolaButtons; + + for (int i = 0; i < buttonNames.Length && i <= selectedIndex; i++) + { + var button = this.FindDescendantByName($"{group}{buttonNames[i]}") as Border; + if (button != null) + { + if (i == selectedIndex) + { + 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; + } + } + } + } + } + + /// + /// ToggleSwitch点击事件处理 + /// + private void ToggleSwitch_Click(object sender, RoutedEventArgs e) + { + if (!_isLoaded) return; + + var border = sender as Border; + if (border == null) return; + + bool isOn = border.Background.ToString() == "#FF3584E4"; + bool newState = !isOn; + SetToggleSwitchState(border, newState); + + string tag = border.Tag?.ToString(); + if (string.IsNullOrEmpty(tag)) return; + + var canvas = MainWindow.Settings.Canvas; + if (canvas == null) return; + + switch (tag) + { + case "ShowCursor": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchShowCursor", newState); + break; + + case "EnablePressureTouchMode": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnablePressureTouchMode", newState); + // 处理互斥逻辑 + if (newState && canvas.DisablePressure) + { + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchDisablePressure", false); + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchDisablePressure"), false); + } + break; + + case "DisablePressure": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchDisablePressure", newState); + // 处理互斥逻辑 + if (newState && canvas.EnablePressureTouchMode) + { + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnablePressureTouchMode", false); + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnablePressureTouchMode"), false); + } + break; + + case "HideStrokeWhenSelecting": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchHideStrokeWhenSelecting", newState); + break; + + case "ClearCanvasAndClearTimeMachine": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchClearCanvasAndClearTimeMachine", newState); + break; + + case "ClearCanvasAlsoClearImages": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchClearCanvasAlsoClearImages", newState); + break; + + case "CompressPicturesUploaded": + // 调用 MainWindow 中的方法 + 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); + break; + + case "UseHardwareAcceleration": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchHardwareAcceleration", newState); + break; + + case "AutoStraightenLine": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAutoStraightenLine", newState); + break; + + case "HighPrecisionLineStraighten": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchHighPrecisionLineStraighten", newState); + break; + + case "LineEndpointSnapping": + // 调用 MainWindow 中的方法 + 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); + break; + + case "SaveFullPageStrokes": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchSaveFullPageStrokes", newState); + break; + + case "SaveStrokesAsXML": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchSaveStrokesAsXML", newState); + break; + + case "AutoSaveStrokesInPowerPoint": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAutoSaveStrokesInPowerPoint", newState); + break; + } + } + + /// + /// 选项按钮点击事件处理 + /// + private void OptionButton_Click(object sender, RoutedEventArgs e) + { + if (!_isLoaded) return; + + var border = sender as Border; + if (border == null) return; + + string tag = border.Tag?.ToString(); + if (string.IsNullOrEmpty(tag)) return; + + string[] parts = tag.Split('_'); + if (parts.Length < 2) return; + + string group = parts[0]; + string value = parts[1]; + + // 清除同组其他按钮的选中状态 + var parent = border.Parent as Panel; + if (parent != null) + { + foreach (var child in parent.Children) + { + if (child is Border childBorder && childBorder != border) + { + string childTag = childBorder.Tag?.ToString(); + if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) + { + childBorder.Background = new SolidColorBrush(Colors.Transparent); + var textBlock = childBorder.Child as TextBlock; + if (textBlock != null) + { + textBlock.FontWeight = FontWeights.Normal; + } + } + } + } + } + + // 设置当前按钮为选中状态 + border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); + var currentTextBlock = border.Child as TextBlock; + if (currentTextBlock != null) + { + currentTextBlock.FontWeight = FontWeights.Bold; + } + + var canvas = MainWindow.Settings.Canvas; + if (canvas == null) return; + + switch (group) + { + case "EraserSize": + int eraserSize; + switch (value) + { + case "VerySmall": + eraserSize = 0; + break; + case "Small": + eraserSize = 1; + break; + case "Medium": + eraserSize = 2; + break; + case "Large": + eraserSize = 3; + break; + case "VeryLarge": + eraserSize = 4; + break; + default: + eraserSize = 2; + break; + } + // 调用 MainWindow 中的方法 + var mainWindow = Application.Current.MainWindow as MainWindow; + if (mainWindow != null) + { + var comboBox = mainWindow.FindName("ComboBoxEraserSize") as System.Windows.Controls.ComboBox; + if (comboBox != null && comboBox.Items.Count > eraserSize) + { + comboBox.SelectedIndex = eraserSize; + MainWindowSettingsHelper.InvokeComboBoxSelectionChanged("ComboBoxEraserSize", comboBox.Items[eraserSize]); + } + else + { + // 如果找不到控件,直接更新设置 + MainWindowSettingsHelper.UpdateSettingDirectly(() => + { + canvas.EraserSize = eraserSize; + }, "ComboBoxEraserSize"); + } + } + break; + + case "HyperbolaAsymptote": + OptionalOperation option; + switch (value) + { + case "Yes": + option = OptionalOperation.Yes; + break; + case "No": + option = OptionalOperation.No; + break; + case "Ask": + option = OptionalOperation.Ask; + break; + default: + option = OptionalOperation.Ask; + break; + } + // 调用 MainWindow 中的方法 + var mainWindow2 = Application.Current.MainWindow as MainWindow; + if (mainWindow2 != null) + { + var comboBox = mainWindow2.FindName("ComboBoxHyperbolaAsymptoteOption") as System.Windows.Controls.ComboBox; + if (comboBox != null) + { + int optionIndex = (int)option; + if (comboBox.Items.Count > optionIndex) + { + comboBox.SelectedIndex = optionIndex; + MainWindowSettingsHelper.InvokeComboBoxSelectionChanged("ComboBoxHyperbolaAsymptoteOption", comboBox.Items[optionIndex]); + } + } + else + { + // 如果找不到控件,直接更新设置 + MainWindowSettingsHelper.UpdateSettingDirectly(() => + { + canvas.HyperbolaAsymptoteOption = option; + }, "ComboBoxHyperbolaAsymptoteOption"); + } + } + break; + + case "AutoSaveStrokesInterval": + // 调用 MainWindow 中的方法 + int interval = int.Parse(value); + var mainWindow3 = Application.Current.MainWindow as MainWindow; + if (mainWindow3 != null) + { + var comboBox = mainWindow3.FindName("ComboBoxAutoSaveStrokesInterval") as System.Windows.Controls.ComboBox; + if (comboBox != null) + { + // 查找对应的选项(根据 Tag 或 Content 匹配) + foreach (System.Windows.Controls.ComboBoxItem item in comboBox.Items) + { + if (item.Tag != null && int.TryParse(item.Tag.ToString(), out int tagValue) && tagValue == interval) + { + comboBox.SelectedItem = item; + MainWindowSettingsHelper.InvokeComboBoxSelectionChanged("ComboBoxAutoSaveStrokesInterval", item); + break; + } + else if (item.Content != null && item.Content.ToString().Contains(interval.ToString())) + { + comboBox.SelectedItem = item; + MainWindowSettingsHelper.InvokeComboBoxSelectionChanged("ComboBoxAutoSaveStrokesInterval", item); + break; + } + } + } + else + { + // 如果找不到控件,直接更新设置 + MainWindowSettingsHelper.UpdateSettingDirectly(() => + { + if (MainWindow.Settings.Automation != null) + { + MainWindow.Settings.Automation.AutoSaveStrokesIntervalMinutes = interval; + } + }, "ComboBoxAutoSaveStrokesInterval"); + } + } + break; + } + } + + /// + /// 自动保存间隔选项按钮点击事件处理 + /// + private void AutoSaveIntervalButton_Click(object sender, RoutedEventArgs e) + { + if (!_isLoaded) return; + OptionButton_Click(sender, e); + } + + /// + /// 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); + } + } + + /// + /// 应用主题 + /// + public void ApplyTheme() + { + try + { + ThemeHelper.ApplyThemeToControl(this); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"CanvasAndInkPanel 应用主题时出错: {ex.Message}"); + } + } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/CrashActionPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/CrashActionPanel.xaml.cs index e7a52197..84768d37 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/CrashActionPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/CrashActionPanel.xaml.cs @@ -29,6 +29,21 @@ namespace Ink_Canvas.Windows.SettingsViews IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs()); } } + + /// + /// 应用主题 + /// + public void ApplyTheme() + { + try + { + ThemeHelper.ApplyThemeToControl(this); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"CrashActionPanel 应用主题时出错: {ex.Message}"); + } + } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/FloatingBarDnDSettingsPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/FloatingBarDnDSettingsPanel.xaml.cs index 724b52b1..8e3f26ce 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/FloatingBarDnDSettingsPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/FloatingBarDnDSettingsPanel.xaml.cs @@ -1,4 +1,5 @@ using iNKORE.UI.WPF.DragDrop; +using System; using System.Collections.ObjectModel; using System.Diagnostics; using System.Windows; @@ -143,5 +144,20 @@ namespace Ink_Canvas.Windows.SettingsViews IconSource = FindResource("PenIcon") as DrawingImage, }); } + + /// + /// 应用主题 + /// + public void ApplyTheme() + { + try + { + ThemeHelper.ApplyThemeToControl(this); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"FloatingBarDnDSettingsPanel 应用主题时出错: {ex.Message}"); + } + } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/GesturesPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/GesturesPanel.xaml index 9798e852..a9955fb4 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/GesturesPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/GesturesPanel.xaml @@ -35,7 +35,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -68,7 +68,7 @@ - + @@ -77,23 +77,23 @@ - - - - + + + + - - + + - + - + - + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/GesturesPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/GesturesPanel.xaml.cs index d90fc785..5e71f8c2 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/GesturesPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/GesturesPanel.xaml.cs @@ -1,6 +1,11 @@ +using Ink_Canvas; +using iNKORE.UI.WPF.Helpers; using System; +using System.Collections.Generic; using System.Windows; using System.Windows.Controls; +using System.Windows.Media; +using Application = System.Windows.Application; namespace Ink_Canvas.Windows.SettingsViews { @@ -9,9 +14,41 @@ namespace Ink_Canvas.Windows.SettingsViews /// public partial class GesturesPanel : UserControl { + private bool _isLoaded = false; + public GesturesPanel() { InitializeComponent(); + Loaded += GesturesPanel_Loaded; + } + + private void GesturesPanel_Loaded(object sender, RoutedEventArgs e) + { + LoadSettings(); + // 添加触摸支持 + EnableTouchSupport(); + // 应用主题 + ApplyTheme(); + _isLoaded = true; + } + + /// + /// 为面板中的所有交互控件启用触摸支持 + /// + private void EnableTouchSupport() + { + try + { + // 延迟执行,确保所有控件都已加载 + Dispatcher.BeginInvoke(new Action(() => + { + MainWindowSettingsHelper.EnableTouchSupportForControls(this); + }), System.Windows.Threading.DispatcherPriority.Loaded); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"GesturesPanel 启用触摸支持时出错: {ex.Message}"); + } } public event EventHandler IsTopBarNeedShadowEffect; @@ -29,6 +66,261 @@ namespace Ink_Canvas.Windows.SettingsViews IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs()); } } + + /// + /// 加载设置到UI + /// + public void LoadSettings() + { + if (MainWindow.Settings == null) return; + + _isLoaded = false; + + try + { + // 进退白板模式自动开关双指移动功能 + if (MainWindow.Settings.Gesture != null) + { + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoSwitchTwoFingerGesture"), MainWindow.Settings.Gesture.AutoSwitchTwoFingerGesture); + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableTwoFingerRotationOnSelection"), MainWindow.Settings.Gesture.IsEnableTwoFingerRotationOnSelection); + } + + // 启用手掌擦 + if (MainWindow.Settings.Canvas != null) + { + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnablePalmEraser"), MainWindow.Settings.Canvas.EnablePalmEraser); + if (PalmEraserSensitivityPanel != null) + { + PalmEraserSensitivityPanel.Visibility = MainWindow.Settings.Canvas.EnablePalmEraser ? Visibility.Visible : Visibility.Collapsed; + } + + // 手掌擦敏感度 + SetOptionButtonState("PalmEraserSensitivity", MainWindow.Settings.Canvas.PalmEraserSensitivity); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"加载手势操作设置时出错: {ex.Message}"); + } + + _isLoaded = true; + } + + /// + /// 查找ToggleSwitch控件 + /// + private Border FindToggleSwitch(string name) + { + return this.FindDescendantByName(name) as Border; + } + + /// + /// 设置ToggleSwitch状态 + /// + private void SetToggleSwitchState(Border toggleSwitch, bool isOn) + { + if (toggleSwitch == null) return; + 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) + { + innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left; + } + } + + /// + /// 设置选项按钮状态 + /// + private void SetOptionButtonState(string group, int selectedIndex) + { + var buttons = new Dictionary + { + { "PalmEraserSensitivity", new[] { "Low", "Medium", "High" } } + }; + + if (!buttons.ContainsKey(group)) return; + + string[] buttonNames = buttons[group]; + + for (int i = 0; i < buttonNames.Length; i++) + { + var button = this.FindDescendantByName($"{group}{buttonNames[i]}Border") as Border; + if (button != null) + { + if (i == selectedIndex) + { + 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; + } + } + } + } + } + + /// + /// ToggleSwitch点击事件处理 + /// + private void ToggleSwitch_Click(object sender, RoutedEventArgs e) + { + if (!_isLoaded) return; + + var border = sender as Border; + if (border == null) return; + + bool isOn = border.Background.ToString() == "#FF3584E4"; + bool newState = !isOn; + SetToggleSwitchState(border, newState); + + string tag = border.Tag?.ToString(); + if (string.IsNullOrEmpty(tag)) return; + + switch (tag) + { + case "AutoSwitchTwoFingerGesture": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAutoSwitchTwoFingerGesture", newState); + break; + + case "EnableTwoFingerRotationOnSelection": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableTwoFingerRotationOnSelection", newState); + break; + + case "EnablePalmEraser": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnablePalmEraser", newState); + // 更新UI状态 + if (PalmEraserSensitivityPanel != null) + { + PalmEraserSensitivityPanel.Visibility = newState ? Visibility.Visible : Visibility.Collapsed; + } + break; + } + } + + /// + /// 选项按钮点击事件处理 + /// + private void OptionButton_Click(object sender, RoutedEventArgs e) + { + if (!_isLoaded) return; + + var border = sender as Border; + if (border == null) return; + + string tag = border.Tag?.ToString(); + if (string.IsNullOrEmpty(tag)) return; + + string[] parts = tag.Split('_'); + if (parts.Length < 2) return; + + string group = parts[0]; + string value = parts[1]; + + // 清除同组其他按钮的选中状态 + var parent = border.Parent as Panel; + if (parent != null) + { + foreach (var child in parent.Children) + { + if (child is Border childBorder && childBorder != border) + { + string childTag = childBorder.Tag?.ToString(); + if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) + { + childBorder.Background = new SolidColorBrush(Colors.Transparent); + var textBlock = childBorder.Child as TextBlock; + if (textBlock != null) + { + textBlock.FontWeight = FontWeights.Normal; + } + } + } + } + } + + // 设置当前按钮为选中状态 + border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); + var currentTextBlock = border.Child as TextBlock; + if (currentTextBlock != null) + { + currentTextBlock.FontWeight = FontWeights.Bold; + } + + switch (group) + { + case "PalmEraserSensitivity": + int sensitivity; + switch (value) + { + case "Low": + sensitivity = 0; + break; + case "Medium": + sensitivity = 1; + break; + case "High": + sensitivity = 2; + break; + default: + sensitivity = 0; + break; + } + // 调用 MainWindow 中的方法(通过设置 ComboBox 的 SelectedIndex) + var mainWindow = Application.Current.MainWindow as MainWindow; + if (mainWindow != null) + { + var comboBox = mainWindow.FindName("ComboBoxPalmEraserSensitivity") as System.Windows.Controls.ComboBox; + if (comboBox != null && comboBox.Items.Count > sensitivity) + { + comboBox.SelectedIndex = sensitivity; + // 触发 SelectionChanged 事件 + MainWindowSettingsHelper.InvokeComboBoxSelectionChanged("ComboBoxPalmEraserSensitivity", comboBox.Items[sensitivity]); + } + else + { + // 如果找不到控件,直接更新设置 + MainWindowSettingsHelper.UpdateSettingDirectly(() => + { + if (MainWindow.Settings.Canvas != null) + { + MainWindow.Settings.Canvas.PalmEraserSensitivity = sensitivity; + } + }, "ComboBoxPalmEraserSensitivity"); + } + } + break; + } + } + + /// + /// 应用主题 + /// + public void ApplyTheme() + { + try + { + ThemeHelper.ApplyThemeToControl(this); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"GesturesPanel 应用主题时出错: {ex.Message}"); + } + } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/InkRecognitionPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/InkRecognitionPanel.xaml.cs index ade1a9b5..9ec8aa82 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/InkRecognitionPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/InkRecognitionPanel.xaml.cs @@ -29,6 +29,21 @@ namespace Ink_Canvas.Windows.SettingsViews IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs()); } } + + /// + /// 应用主题 + /// + public void ApplyTheme() + { + try + { + ThemeHelper.ApplyThemeToControl(this); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"InkRecognitionPanel 应用主题时出错: {ex.Message}"); + } + } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/LuckyRandomPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/LuckyRandomPanel.xaml index 98b519e6..09c14af5 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/LuckyRandomPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/LuckyRandomPanel.xaml @@ -35,7 +35,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -77,7 +77,7 @@ - + @@ -92,13 +92,13 @@ - + - + - + @@ -115,7 +115,7 @@ - + @@ -126,7 +126,7 @@ - + @@ -142,7 +142,7 @@ - + @@ -156,7 +156,7 @@ - + @@ -171,7 +171,7 @@ - + @@ -182,7 +182,7 @@ - + @@ -201,7 +201,7 @@ - + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/LuckyRandomPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/LuckyRandomPanel.xaml.cs index eca7d4c4..64cdb4bc 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/LuckyRandomPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/LuckyRandomPanel.xaml.cs @@ -1,6 +1,12 @@ +using Ink_Canvas; +using iNKORE.UI.WPF.Helpers; using System; +using System.Collections.Generic; +using System.Linq; using System.Windows; using System.Windows.Controls; +using System.Windows.Media; +using Application = System.Windows.Application; namespace Ink_Canvas.Windows.SettingsViews { @@ -9,9 +15,41 @@ namespace Ink_Canvas.Windows.SettingsViews /// public partial class LuckyRandomPanel : UserControl { + private bool _isLoaded = false; + public LuckyRandomPanel() { InitializeComponent(); + Loaded += LuckyRandomPanel_Loaded; + } + + private void LuckyRandomPanel_Loaded(object sender, RoutedEventArgs e) + { + LoadSettings(); + // 添加触摸支持 + EnableTouchSupport(); + // 应用主题 + ApplyTheme(); + _isLoaded = true; + } + + /// + /// 为面板中的所有交互控件启用触摸支持 + /// + private void EnableTouchSupport() + { + try + { + // 延迟执行,确保所有控件都已加载 + Dispatcher.BeginInvoke(new Action(() => + { + MainWindowSettingsHelper.EnableTouchSupportForControls(this); + }), System.Windows.Threading.DispatcherPriority.Loaded); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"LuckyRandomPanel 启用触摸支持时出错: {ex.Message}"); + } } public event EventHandler IsTopBarNeedShadowEffect; @@ -29,6 +67,379 @@ namespace Ink_Canvas.Windows.SettingsViews IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs()); } } + + /// + /// 加载设置到UI + /// + public void LoadSettings() + { + if (MainWindow.Settings == null || MainWindow.Settings.RandSettings == null) return; + + _isLoaded = false; + + try + { + var randSettings = MainWindow.Settings.RandSettings; + + // 显示修改随机点名名单的按钮 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchDisplayRandWindowNamesInputBtn"), randSettings.DisplayRandWindowNamesInputBtn); + + // 启用随机抽和单次抽按钮 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchShowRandomAndSingleDraw"), randSettings.ShowRandomAndSingleDraw); + + // 启用快抽悬浮按钮 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableQuickDraw"), randSettings.EnableQuickDraw); + + // 直接调用外部点名 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchExternalCaller"), randSettings.DirectCallCiRand); + + // 点名类型 + SetOptionButtonState("ExternalCallerType", randSettings.ExternalCallerType); + + // 单次抽人窗口关闭延迟 + if (RandWindowOnceCloseLatencySlider != null) + { + RandWindowOnceCloseLatencySlider.Value = randSettings.RandWindowOnceCloseLatency; + if (RandWindowOnceCloseLatencyText != null) + { + RandWindowOnceCloseLatencyText.Text = $"{randSettings.RandWindowOnceCloseLatency:F1}s"; + } + } + + // 单次随机点名人数上限 + if (RandWindowOnceMaxStudentsSlider != null) + { + RandWindowOnceMaxStudentsSlider.Value = randSettings.RandWindowOnceMaxStudents; + if (RandWindowOnceMaxStudentsText != null) + { + RandWindowOnceMaxStudentsText.Text = randSettings.RandWindowOnceMaxStudents.ToString(); + } + } + + // 启用新点名UI + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchUseNewRollCallUI"), randSettings.UseNewRollCallUI); + + // 启用机器学习避免重复 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableMLAvoidance"), randSettings.EnableMLAvoidance); + + // 避免重复历史记录数量 + if (MLAvoidanceHistorySlider != null) + { + MLAvoidanceHistorySlider.Value = randSettings.MLAvoidanceHistoryCount; + if (MLAvoidanceHistoryText != null) + { + MLAvoidanceHistoryText.Text = randSettings.MLAvoidanceHistoryCount.ToString(); + } + } + + // 避免重复权重 + if (MLAvoidanceWeightSlider != null) + { + MLAvoidanceWeightSlider.Value = randSettings.MLAvoidanceWeight; + if (MLAvoidanceWeightText != null) + { + MLAvoidanceWeightText.Text = $"{(randSettings.MLAvoidanceWeight * 100):F0}%"; + } + } + + // 背景选择 + SetOptionButtonState("PickNameBackground", randSettings.SelectedBackgroundIndex); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"加载幸运随机设置时出错: {ex.Message}"); + } + + _isLoaded = true; + } + + /// + /// 查找ToggleSwitch控件 + /// + private Border FindToggleSwitch(string name) + { + return this.FindDescendantByName(name) as Border; + } + + /// + /// 设置ToggleSwitch状态 + /// + private void SetToggleSwitchState(Border toggleSwitch, bool isOn) + { + if (toggleSwitch == null) return; + 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) + { + innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left; + } + } + + /// + /// 设置选项按钮状态 + /// + private void SetOptionButtonState(string group, int selectedIndex) + { + var buttons = new Dictionary + { + { "ExternalCallerType", new[] { "ClassIsland", "SecRandom", "NamePicker" } }, + { "PickNameBackground", new[] { "Default" } } + }; + + if (!buttons.ContainsKey(group)) return; + + string[] buttonNames = buttons[group]; + + for (int i = 0; i < buttonNames.Length; i++) + { + var button = this.FindDescendantByName($"{group}{buttonNames[i]}Border") as Border; + if (button != null) + { + if (i == selectedIndex) + { + 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; + } + } + } + } + } + + /// + /// ToggleSwitch点击事件处理 + /// + private void ToggleSwitch_Click(object sender, RoutedEventArgs e) + { + if (!_isLoaded) return; + + var border = sender as Border; + if (border == null) return; + + bool isOn = border.Background.ToString() == "#FF3584E4"; + bool newState = !isOn; + SetToggleSwitchState(border, newState); + + string tag = border.Tag?.ToString(); + if (string.IsNullOrEmpty(tag)) return; + + var randSettings = MainWindow.Settings.RandSettings; + if (randSettings == null) return; + + switch (tag) + { + case "DisplayRandWindowNamesInputBtn": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchDisplayRandWindowNamesInputBtn", newState); + break; + + case "ShowRandomAndSingleDraw": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchShowRandomAndSingleDraw", newState); + break; + + case "EnableQuickDraw": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableQuickDraw", newState); + break; + + case "ExternalCaller": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchExternalCaller", newState); + break; + + case "UseNewRollCallUI": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchUseNewRollCallUI", newState); + break; + + case "EnableMLAvoidance": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableMLAvoidance", newState); + break; + } + } + + /// + /// 选项按钮点击事件处理 + /// + private void OptionButton_Click(object sender, RoutedEventArgs e) + { + if (!_isLoaded) return; + + var border = sender as Border; + if (border == null) return; + + string tag = border.Tag?.ToString(); + if (string.IsNullOrEmpty(tag)) return; + + string[] parts = tag.Split('_'); + if (parts.Length < 2) return; + + string group = parts[0]; + string value = parts[1]; + + // 清除同组其他按钮的选中状态 + var parent = border.Parent as Panel; + if (parent != null) + { + foreach (var child in parent.Children) + { + if (child is Border childBorder && childBorder != border) + { + string childTag = childBorder.Tag?.ToString(); + if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) + { + childBorder.Background = new SolidColorBrush(Colors.Transparent); + var textBlock = childBorder.Child as TextBlock; + if (textBlock != null) + { + textBlock.FontWeight = FontWeights.Normal; + } + } + } + } + } + + // 设置当前按钮为选中状态 + border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); + var currentTextBlock = border.Child as TextBlock; + if (currentTextBlock != null) + { + currentTextBlock.FontWeight = FontWeights.Bold; + } + + var randSettings = MainWindow.Settings.RandSettings; + if (randSettings == null) return; + + switch (group) + { + case "ExternalCallerType": + int callerType; + switch (value) + { + case "ClassIsland": + callerType = 0; + break; + case "SecRandom": + callerType = 1; + break; + case "NamePicker": + callerType = 2; + break; + default: + callerType = 0; + break; + } + // 调用 MainWindow 中的方法 + var mainWindow = Application.Current.MainWindow as MainWindow; + if (mainWindow != null) + { + var comboBox = mainWindow.FindName("ComboBoxExternalCallerType") as System.Windows.Controls.ComboBox; + if (comboBox != null && comboBox.Items.Count > callerType) + { + comboBox.SelectedIndex = callerType; + MainWindowSettingsHelper.InvokeComboBoxSelectionChanged("ComboBoxExternalCallerType", comboBox.Items[callerType]); + } + else + { + // 如果找不到控件,直接更新设置 + MainWindowSettingsHelper.UpdateSettingDirectly(() => + { + randSettings.ExternalCallerType = callerType; + }, "ComboBoxExternalCallerType"); + } + } + break; + + case "PickNameBackground": + // 背景选择逻辑 - 这个设置可能没有对应的方法,直接更新 + MainWindowSettingsHelper.UpdateSettingDirectly(() => + { + randSettings.SelectedBackgroundIndex = 0; // 默认背景 + }, "PickNameBackground"); + break; + } + } + + /// + /// Slider值变化事件处理 + /// + private void RandWindowOnceCloseLatencySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + if (!_isLoaded) return; + if (RandWindowOnceCloseLatencySlider != null && RandWindowOnceCloseLatencyText != null) + { + double value = RandWindowOnceCloseLatencySlider.Value; + RandWindowOnceCloseLatencyText.Text = $"{value:F1}s"; + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("RandWindowOnceCloseLatencySlider", value); + } + } + + private void RandWindowOnceMaxStudentsSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + if (!_isLoaded) return; + if (RandWindowOnceMaxStudentsSlider != null && RandWindowOnceMaxStudentsText != null) + { + double value = RandWindowOnceMaxStudentsSlider.Value; + RandWindowOnceMaxStudentsText.Text = ((int)value).ToString(); + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("RandWindowOnceMaxStudentsSlider", value); + } + } + + private void MLAvoidanceHistorySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + if (!_isLoaded) return; + if (MLAvoidanceHistorySlider != null && MLAvoidanceHistoryText != null) + { + double value = MLAvoidanceHistorySlider.Value; + MLAvoidanceHistoryText.Text = ((int)value).ToString(); + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("MLAvoidanceHistorySlider", value); + } + } + + private void MLAvoidanceWeightSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + if (!_isLoaded) return; + if (MLAvoidanceWeightSlider != null && MLAvoidanceWeightText != null) + { + double value = MLAvoidanceWeightSlider.Value; + MLAvoidanceWeightText.Text = $"{(value * 100):F0}%"; + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("MLAvoidanceWeightSlider", value); + } + } + + /// + /// 应用主题 + /// + public void ApplyTheme() + { + try + { + ThemeHelper.ApplyThemeToControl(this); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"LuckyRandomPanel 应用主题时出错: {ex.Message}"); + } + } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/MainWindowSettingsHelper.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/MainWindowSettingsHelper.cs new file mode 100644 index 00000000..a88b64f5 --- /dev/null +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/MainWindowSettingsHelper.cs @@ -0,0 +1,719 @@ +using Ink_Canvas; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using Media = System.Windows.Media; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; + +namespace Ink_Canvas.Windows.SettingsViews +{ + /// + /// 辅助类:用于在新设置面板中调用 MainWindow 中已有的设置处理方法 + /// + public static class MainWindowSettingsHelper + { + private static MainWindow GetMainWindow() + { + return Application.Current.MainWindow as MainWindow; + } + + /// + /// 调用 MainWindow 中的方法 + /// + public static void InvokeMainWindowMethod(string methodName, params object[] parameters) + { + try + { + var mainWindow = GetMainWindow(); + if (mainWindow == null) return; + + var method = mainWindow.GetType().GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); + if (method != null) + { + method.Invoke(mainWindow, parameters); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"调用 MainWindow 方法 {methodName} 失败: {ex.Message}"); + } + } + + /// + /// 调用 MainWindow 中的 ToggleSwitch 事件处理方法 + /// + public static void InvokeToggleSwitchToggled(string toggleSwitchName, bool isOn) + { + try + { + var mainWindow = GetMainWindow(); + if (mainWindow == null) return; + + // 获取 MainWindow 中的 ToggleSwitch 控件 + var toggleSwitch = mainWindow.FindName(toggleSwitchName); + if (toggleSwitch == null) + { + // 如果找不到控件,尝试通过反射设置属性 + var property = mainWindow.GetType().GetProperty(toggleSwitchName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); + if (property != null && property.PropertyType.Name.Contains("ToggleSwitch")) + { + var isOnProperty = property.PropertyType.GetProperty("IsOn"); + if (isOnProperty != null) + { + var toggleSwitchInstance = property.GetValue(mainWindow); + if (toggleSwitchInstance != null) + { + isOnProperty.SetValue(toggleSwitchInstance, isOn); + } + } + } + // 即使找不到控件,也尝试触发事件(可能通过反射调用) + var toggledMethodName = toggleSwitchName + "_Toggled"; + InvokeMainWindowMethod(toggledMethodName, null, new RoutedEventArgs()); + + // 通知新设置面板同步状态 + NotifySettingsPanelsSyncState(toggleSwitchName); + return; + } + + // 设置 ToggleSwitch 的 IsOn 属性 + var toggleSwitchType = toggleSwitch.GetType(); + var isOnProp = toggleSwitchType.GetProperty("IsOn"); + if (isOnProp != null) + { + isOnProp.SetValue(toggleSwitch, isOn); + } + + // 触发 Toggled 事件 + var toggledMethodName2 = toggleSwitchName + "_Toggled"; + InvokeMainWindowMethod(toggledMethodName2, toggleSwitch, new RoutedEventArgs()); + + // 通知新设置面板同步状态 + NotifySettingsPanelsSyncState(toggleSwitchName); + + // 检查是否需要更新主题 + NotifyThemeUpdateIfNeeded(toggleSwitchName); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"调用 ToggleSwitch {toggleSwitchName} 失败: {ex.Message}"); + } + } + + /// + /// 调用 MainWindow 中的 ComboBox 事件处理方法 + /// + public static void InvokeComboBoxSelectionChanged(string comboBoxName, object selectedItem) + { + try + { + var mainWindow = GetMainWindow(); + if (mainWindow == null) return; + + // 获取 MainWindow 中的 ComboBox 控件 + var comboBox = mainWindow.FindName(comboBoxName) as System.Windows.Controls.ComboBox; + if (comboBox != null) + { + comboBox.SelectedItem = selectedItem; + + // 触发 SelectionChanged 事件 + var selectionChangedMethodName = comboBoxName + "_SelectionChanged"; + InvokeMainWindowMethod(selectionChangedMethodName, comboBox, new System.Windows.Controls.SelectionChangedEventArgs( + System.Windows.Controls.Primitives.Selector.SelectionChangedEvent, + new System.Collections.IList[0], + new System.Collections.IList[0])); + } + + // 通知新设置面板同步状态 + NotifySettingsPanelsSyncState(comboBoxName); + + // 检查是否需要更新主题 + NotifyThemeUpdateIfNeeded(comboBoxName); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"调用 ComboBox {comboBoxName} 失败: {ex.Message}"); + } + } + + /// + /// 调用 MainWindow 中的 Slider 事件处理方法 + /// + public static void InvokeSliderValueChanged(string sliderName, double value) + { + try + { + var mainWindow = GetMainWindow(); + if (mainWindow == null) return; + + // 获取 MainWindow 中的 Slider 控件 + var slider = mainWindow.FindName(sliderName) as System.Windows.Controls.Slider; + if (slider != null) + { + var oldValue = slider.Value; + slider.Value = value; + + // 触发 ValueChanged 事件 + var valueChangedMethodName = sliderName + "_ValueChanged"; + InvokeMainWindowMethod(valueChangedMethodName, slider, + new System.Windows.RoutedPropertyChangedEventArgs(oldValue, value)); + } + + // 通知新设置面板同步状态 + NotifySettingsPanelsSyncState(sliderName); + + // 检查是否需要更新主题(某些Slider可能影响UI外观) + NotifyThemeUpdateIfNeeded(sliderName); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"调用 Slider {sliderName} 失败: {ex.Message}"); + } + } + + /// + /// 调用 MainWindow 中的 CheckBox 事件处理方法 + /// + public static void InvokeCheckBoxCheckedChanged(string checkBoxName, bool isChecked) + { + try + { + var mainWindow = GetMainWindow(); + if (mainWindow == null) return; + + // 获取 MainWindow 中的 CheckBox 控件 + var checkBox = mainWindow.FindName(checkBoxName) as System.Windows.Controls.CheckBox; + if (checkBox != null) + { + checkBox.IsChecked = isChecked; + + // 尝试多种可能的方法名 + var methodNames = new[] + { + checkBoxName + "_IsCheckChanged", + checkBoxName + "_IsCheckChange", + checkBoxName + "_Checked", + checkBoxName + "_Unchecked" + }; + + foreach (var methodName in methodNames) + { + var method = mainWindow.GetType().GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); + if (method != null) + { + InvokeMainWindowMethod(methodName, checkBox, new RoutedEventArgs()); + break; + } + } + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"调用 CheckBox {checkBoxName} 失败: {ex.Message}"); + } + } + + /// + /// 安全地修改设置并保存,优先调用 MainWindow 中的事件处理方法 + /// 如果找不到对应的事件处理方法,则直接修改设置并保存 + /// + /// 设置修改的 Action,例如:() => MainWindow.Settings.Startup.IsAutoUpdate = true + /// 可选:要调用的 MainWindow 事件处理方法名(如 "ToggleSwitchIsAutoUpdate_Toggled") + /// 可选:控件名称,用于状态同步(如 "ToggleSwitchIsAutoUpdate") + /// 可选:事件处理方法的参数 + public static void UpdateSettingSafely(Action action, string eventHandlerName = null, string controlName = null, params object[] eventHandlerParams) + { + try + { + // 如果提供了事件处理方法名,优先调用 + if (!string.IsNullOrEmpty(eventHandlerName)) + { + var mainWindow = GetMainWindow(); + if (mainWindow != null) + { + var method = mainWindow.GetType().GetMethod(eventHandlerName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); + if (method != null) + { + // 调用事件处理方法(它会自动保存设置并触发状态同步) + method.Invoke(mainWindow, eventHandlerParams); + + // 如果提供了控件名称,确保状态同步 + if (!string.IsNullOrEmpty(controlName)) + { + NotifySettingsPanelsSyncState(controlName); + } + return; + } + } + } + + // 如果没有事件处理方法或调用失败,直接修改设置并保存 + action?.Invoke(); + MainWindow.SaveSettingsToFile(); + + // 如果提供了控件名称,通知面板同步状态 + if (!string.IsNullOrEmpty(controlName)) + { + NotifySettingsPanelsSyncState(controlName); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"更新设置失败: {ex.Message}"); + } + } + + /// + /// 直接修改设置属性并保存(用于没有对应事件处理方法的设置项) + /// + /// 设置修改的 Action + /// 可选:控件名称,用于状态同步(如 "ToggleSwitchIsAutoUpdate") + public static void UpdateSettingDirectly(Action action, string controlName = null) + { + try + { + action?.Invoke(); + MainWindow.SaveSettingsToFile(); + + // 如果提供了控件名称,通知面板同步状态 + if (!string.IsNullOrEmpty(controlName)) + { + NotifySettingsPanelsSyncState(controlName); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"直接更新设置失败: {ex.Message}"); + } + } + + /// + /// 调用 MainWindow 中的 TextBox 事件处理方法 + /// + public static void InvokeTextBoxTextChanged(string textBoxName, string text) + { + try + { + var mainWindow = GetMainWindow(); + if (mainWindow == null) return; + + // 获取 MainWindow 中的 TextBox 控件 + var textBox = mainWindow.FindName(textBoxName) as System.Windows.Controls.TextBox; + if (textBox != null) + { + textBox.Text = text; + + // 触发 TextChanged 事件 + var textChangedMethodName = textBoxName + "_TextChanged"; + InvokeMainWindowMethod(textChangedMethodName, textBox, new System.Windows.Controls.TextChangedEventArgs( + System.Windows.Controls.Primitives.TextBoxBase.TextChangedEvent, + System.Windows.Controls.UndoAction.None)); + } + + // 通知新设置面板同步状态 + NotifySettingsPanelsSyncState(textBoxName); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"调用 TextBox {textBoxName} 失败: {ex.Message}"); + } + } + + /// + /// 通知所有新设置面板同步指定控件的状态 + /// + public static void NotifySettingsPanelsSyncState(string controlName) + { + try + { + // 延迟执行,确保设置已经保存 + Application.Current.Dispatcher.BeginInvoke(new Action(() => + { + // 查找所有打开的设置窗口 + foreach (Window window in Application.Current.Windows) + { + if (window.GetType().Name == "SettingsWindow") + { + // 根据控件名称确定需要同步的面板 + var panelToSync = GetPanelForControl(controlName); + + if (panelToSync != null) + { + // 获取对应的面板属性 + var panelProp = window.GetType().GetProperty(panelToSync, BindingFlags.Public | BindingFlags.Instance); + if (panelProp != null) + { + var panel = panelProp.GetValue(window) as System.Windows.Controls.UserControl; + if (panel != null) + { + // 调用 LoadSettings 方法重新加载设置 + var loadMethod = panel.GetType().GetMethod("LoadSettings", + BindingFlags.Public | BindingFlags.Instance); + if (loadMethod != null) + { + loadMethod.Invoke(panel, null); + } + } + } + } + else + { + // 如果无法确定具体面板,则同步所有面板(保守策略) + SyncAllPanels(window); + } + break; // 通常只有一个设置窗口 + } + } + }), System.Windows.Threading.DispatcherPriority.Background); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"通知设置面板同步状态失败: {ex.Message}"); + } + } + + /// + /// 根据控件名称获取对应的面板名称 + /// + private static string GetPanelForControl(string controlName) + { + // 定义控件名称到面板名称的映射 + var controlToPanel = new Dictionary + { + // StartupPanel + { "ToggleSwitchIsAutoUpdate", "StartupPanel" }, + { "ToggleSwitchIsAutoUpdateWithSilence", "StartupPanel" }, + { "ToggleSwitchRunAtStartup", "StartupPanel" }, + { "ToggleSwitchFoldAtStartup", "StartupPanel" }, + { "AutoUpdateWithSilenceStartTimeComboBox", "StartupPanel" }, + { "AutoUpdateWithSilenceEndTimeComboBox", "StartupPanel" }, + + // ThemePanel + { "ComboBoxTheme", "ThemePanel" }, + { "ToggleSwitchEnableSplashScreen", "ThemePanel" }, + { "ComboBoxSplashScreenStyle", "ThemePanel" }, + { "ToggleSwitchEnableTrayIcon", "ThemePanel" }, + { "ComboBoxFloatingBarImg", "ThemePanel" }, + { "ComboBoxUnFoldBtnImg", "ThemePanel" }, + { "ComboBoxChickenSoupSource", "ThemePanel" }, + { "ComboBoxQuickColorPaletteDisplayMode", "ThemePanel" }, + { "ComboBoxEraserDisplayOption", "ThemePanel" }, + { "ToggleSwitchEnableQuickPanel", "ThemePanel" }, + { "ViewboxFloatingBarScaleTransformValueSlider", "ThemePanel" }, + { "ViewboxFloatingBarOpacityValueSlider", "ThemePanel" }, + { "ViewboxFloatingBarOpacityInPPTValueSlider", "ThemePanel" }, + + // PowerPointPanel + { "ToggleSwitchSupportPowerPoint", "PowerPointPanel" }, + { "ToggleSwitchShowPPTButton", "PowerPointPanel" }, + { "ToggleSwitchEnablePPTButtonPageClickable", "PowerPointPanel" }, + { "ToggleSwitchShowCanvasAtNewSlideShow", "PowerPointPanel" }, + { "PPTButtonLeftPositionValueSlider", "PowerPointPanel" }, + { "PPTButtonRightPositionValueSlider", "PowerPointPanel" }, + + // GesturesPanel + { "ToggleSwitchEnableTwoFingerRotationOnSelection", "GesturesPanel" }, + { "ToggleSwitchEnablePalmEraser", "GesturesPanel" }, + { "ComboBoxPalmEraserSensitivity", "GesturesPanel" }, + + // CanvasAndInkPanel + { "ToggleSwitchShowCursor", "CanvasAndInkPanel" }, + { "ToggleSwitchDisablePressure", "CanvasAndInkPanel" }, + { "ToggleSwitchEnablePressureTouchMode", "CanvasAndInkPanel" }, + { "ComboBoxEraserSize", "CanvasAndInkPanel" }, + { "ComboBoxHyperbolaAsymptoteOption", "CanvasAndInkPanel" }, + { "ComboBoxAutoSaveStrokesInterval", "CanvasAndInkPanel" }, + + // SnapshotPanel + { "AutoSavedStrokesLocation", "SnapshotPanel" }, + { "ComboBoxAutoDelSavedFilesDaysThreshold", "SnapshotPanel" }, + { "ToggleSwitchAutoDelSavedFiles", "SnapshotPanel" }, + + // AdvancedPanel + { "ComboBoxAutoBackupInterval", "AdvancedPanel" }, + { "ToggleSwitchIsQuadIR", "AdvancedPanel" }, + { "ToggleSwitchIsLogEnabled", "AdvancedPanel" }, + { "ToggleSwitchIsSaveLogByDate", "AdvancedPanel" }, + { "ToggleSwitchIsSecondConfimeWhenShutdownApp", "AdvancedPanel" }, + { "ToggleSwitchIsEnableFullScreenHelper", "AdvancedPanel" }, + { "ToggleSwitchIsEnableAvoidFullScreenHelper", "AdvancedPanel" }, + { "ToggleSwitchIsEnableEdgeGestureUtil", "AdvancedPanel" }, + { "ToggleSwitchIsEnableForceFullScreen", "AdvancedPanel" }, + { "ToggleSwitchIsEnableDPIChangeDetection", "AdvancedPanel" }, + { "ToggleSwitchIsEnableResolutionChangeDetection", "AdvancedPanel" }, + { "ToggleSwitchIsAutoBackupBeforeUpdate", "AdvancedPanel" }, + { "ToggleSwitchIsAutoBackupEnabled", "AdvancedPanel" }, + + // LuckyRandomPanel + { "ToggleSwitchDisplayRandWindowNamesInputBtn", "LuckyRandomPanel" }, + { "ToggleSwitchShowRandomAndSingleDraw", "LuckyRandomPanel" }, + { "ToggleSwitchEnableQuickDraw", "LuckyRandomPanel" }, + { "ToggleSwitchExternalCaller", "LuckyRandomPanel" }, + { "ComboBoxExternalCallerType", "LuckyRandomPanel" }, + { "RandWindowOnceCloseLatencySlider", "LuckyRandomPanel" }, + { "RandWindowOnceMaxStudentsSlider", "LuckyRandomPanel" }, + }; + + // 查找匹配的面板 + foreach (var kvp in controlToPanel) + { + if (controlName.Contains(kvp.Key) || kvp.Key.Contains(controlName)) + { + return kvp.Value; + } + } + + return null; + } + + /// + /// 同步所有面板的状态(保守策略) + /// + private static void SyncAllPanels(Window settingsWindow) + { + try + { + // 获取所有面板属性 + var panelProperties = settingsWindow.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance) + .Where(p => p.PropertyType.Name.EndsWith("Panel") && + p.PropertyType.IsSubclassOf(typeof(System.Windows.Controls.UserControl))); + + foreach (var panelProp in panelProperties) + { + try + { + var panel = panelProp.GetValue(settingsWindow) as System.Windows.Controls.UserControl; + if (panel != null) + { + // 调用 LoadSettings 方法 + var loadMethod = panel.GetType().GetMethod("LoadSettings", + BindingFlags.Public | BindingFlags.Instance); + if (loadMethod != null) + { + loadMethod.Invoke(panel, null); + } + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"同步面板 {panelProp.Name} 状态失败: {ex.Message}"); + } + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"同步所有面板状态失败: {ex.Message}"); + } + } + + /// + /// 检查并通知设置窗口更新主题(如果设置变化可能影响主题) + /// + /// 控件名称,用于判断是否是主题相关的设置 + public static void NotifyThemeUpdateIfNeeded(string controlName) + { + try + { + if (string.IsNullOrEmpty(controlName)) return; + + // 定义可能影响主题的控件名称列表(扩展版) + var themeRelatedControls = new[] + { + "ComboBoxTheme", // 主题选择 + "ToggleSwitchEnableTrayIcon", // 托盘图标(可能影响图标颜色) + "ComboBoxFloatingBarImg", // 浮动栏图标 + "ComboBoxUnFoldBtnImg", // 展开按钮图标 + "ComboBoxSplashScreenStyle", // 启动画面样式 + "ToggleSwitchEnableSplashScreen", // 启动画面开关 + "ViewboxFloatingBarScaleTransformValueSlider", // 浮动栏缩放(可能影响UI) + "ViewboxFloatingBarOpacityValueSlider", // 浮动栏透明度 + "ViewboxFloatingBarOpacityInPPTValueSlider", // PPT中浮动栏透明度 + "UnFoldBtnImg", // 展开按钮图标(选项按钮) + "FloatingBarImg", // 浮动栏图标(选项按钮) + "Theme" // 主题(选项按钮) + }; + + // 检查是否是主题相关的设置(使用更灵活的匹配) + bool isThemeRelated = false; + string controlNameLower = controlName.ToLower(); + + foreach (var themeControl in themeRelatedControls) + { + string themeControlLower = themeControl.ToLower(); + // 检查是否包含或匹配 + if (controlNameLower.Contains(themeControlLower) || + themeControlLower.Contains(controlNameLower) || + controlNameLower == themeControlLower) + { + isThemeRelated = true; + break; + } + } + + if (isThemeRelated) + { + // 延迟通知,确保设置已保存 + Application.Current.Dispatcher.BeginInvoke(new Action(() => + { + // 通知设置窗口更新主题 + NotifySettingsWindowThemeUpdate(); + }), System.Windows.Threading.DispatcherPriority.Background); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"通知主题更新失败: {ex.Message}"); + } + } + + /// + /// 通知设置窗口更新所有面板的主题 + /// + private static void NotifySettingsWindowThemeUpdate() + { + try + { + // 查找所有打开的设置窗口 + foreach (Window window in Application.Current.Windows) + { + // 使用类型名称匹配,因为 SettingsWindow 在不同的命名空间中 + if (window.GetType().Name == "SettingsWindow") + { + // 使用反射调用 ApplyThemeToAllPanels 方法 + var method = window.GetType().GetMethod("ApplyThemeToAllPanels", + BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); + if (method != null) + { + method.Invoke(window, null); + } + + // 同时调用 ApplyTheme 方法更新窗口本身 + var applyThemeMethod = window.GetType().GetMethod("ApplyTheme", + BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); + if (applyThemeMethod != null) + { + applyThemeMethod.Invoke(window, null); + } + + break; // 通常只有一个设置窗口 + } + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"通知设置窗口主题更新失败: {ex.Message}"); + } + } + + /// + /// 强制更新所有设置面板的主题(公共方法,可在外部调用) + /// + public static void ForceUpdateAllPanelsTheme() + { + NotifySettingsWindowThemeUpdate(); + } + + /// + /// 调用 MainWindow 中的 ComboBox 事件处理方法(增强版,支持主题更新通知) + /// + public static void InvokeComboBoxSelectionChangedWithThemeCheck(string comboBoxName, object selectedItem) + { + InvokeComboBoxSelectionChanged(comboBoxName, selectedItem); + NotifyThemeUpdateIfNeeded(comboBoxName); + } + + /// + /// 调用 MainWindow 中的 ToggleSwitch 事件处理方法(增强版,支持主题更新通知) + /// + public static void InvokeToggleSwitchToggledWithThemeCheck(string toggleSwitchName, bool isOn) + { + InvokeToggleSwitchToggled(toggleSwitchName, isOn); + NotifyThemeUpdateIfNeeded(toggleSwitchName); + } + + /// + /// 为控件树中的所有交互控件启用触摸支持(公共方法,可在外部调用) + /// + /// 父控件 + public static void EnableTouchSupportForControls(DependencyObject parent) + { + if (parent == null) return; + + for (int i = 0; i < Media.VisualTreeHelper.GetChildrenCount(parent); i++) + { + var child = Media.VisualTreeHelper.GetChild(parent, i); + + // 为 Border 控件(ToggleSwitch、选项按钮等)启用触摸支持 + if (child is Border border) + { + // 检查是否是交互控件(有 Tag 或 Cursor 为 Hand) + if (border.Tag != null || border.Cursor == Cursors.Hand) + { + border.IsManipulationEnabled = true; + + // 添加触摸事件支持,将触摸事件转换为鼠标事件 + border.TouchDown += (s, e) => + { + var touchPoint = e.GetTouchPoint(border); + var mouseEvent = new MouseButtonEventArgs(Mouse.PrimaryDevice, Environment.TickCount, MouseButton.Left) + { + RoutedEvent = UIElement.MouseLeftButtonDownEvent, + Source = border + }; + border.RaiseEvent(mouseEvent); + border.CaptureTouch(e.TouchDevice); + e.Handled = true; + }; + + // 添加触摸释放事件 + border.TouchUp += (s, e) => + { + border.ReleaseTouchCapture(e.TouchDevice); + e.Handled = true; + }; + } + } + // 为 Button 控件启用触摸支持 + else if (child is Button button) + { + button.IsManipulationEnabled = true; + } + // 为 ComboBox 启用触摸支持 + else if (child is ComboBox comboBox) + { + comboBox.IsManipulationEnabled = true; + } + // 为 Slider 启用触摸支持 + else if (child is Slider slider) + { + slider.IsManipulationEnabled = true; + } + // 为 TextBox 启用触摸支持 + else if (child is TextBox textBox) + { + textBox.IsManipulationEnabled = true; + } + // 为 CheckBox 启用触摸支持 + else if (child is CheckBox checkBox) + { + checkBox.IsManipulationEnabled = true; + } + // 为 RadioButton 启用触摸支持 + else if (child is RadioButton radioButton) + { + radioButton.IsManipulationEnabled = true; + } + + // 递归处理子元素 + EnableTouchSupportForControls(child); + } + } + } +} + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml index 46b7278b..a530fc2e 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml @@ -37,7 +37,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -65,7 +65,7 @@ - + @@ -79,7 +79,7 @@ - + @@ -160,7 +160,7 @@ - + @@ -170,114 +170,178 @@ - - - - + + + + - + + + + + - - - - + + + + + + + + - + + + + + - - - - + + + + + + + + - + + + + + - - - - + + + + + + + + - + + + + + - - - - + + + + + + + + - - - + + + - + + + + + - - - - + + + + + + + + - + + + + + - - - - + + + + + + + + - - - + + + - + + + + + - - - - + + + + + + + + - + + + + + - - - - + + + + + + + + @@ -290,7 +354,7 @@ - + @@ -308,7 +372,7 @@ - + @@ -326,7 +390,7 @@ - + @@ -346,7 +410,7 @@ - + @@ -378,7 +442,7 @@ - + @@ -392,7 +456,7 @@ - + @@ -406,7 +470,7 @@ - + @@ -425,7 +489,7 @@ - + @@ -440,13 +504,13 @@ - + - + - + @@ -462,7 +526,7 @@ - + @@ -476,7 +540,7 @@ - + @@ -490,7 +554,7 @@ - + @@ -504,7 +568,7 @@ - + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml.cs index 0deccedd..be535ad7 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/PowerPointPanel.xaml.cs @@ -1,6 +1,11 @@ +using Ink_Canvas; +using iNKORE.UI.WPF.Helpers; using System; +using System.Collections.Generic; +using System.Linq; using System.Windows; using System.Windows.Controls; +using System.Windows.Media; namespace Ink_Canvas.Windows.SettingsViews { @@ -9,9 +14,41 @@ namespace Ink_Canvas.Windows.SettingsViews /// public partial class PowerPointPanel : UserControl { + private bool _isLoaded = false; + public PowerPointPanel() { InitializeComponent(); + Loaded += PowerPointPanel_Loaded; + } + + private void PowerPointPanel_Loaded(object sender, RoutedEventArgs e) + { + LoadSettings(); + // 添加触摸支持 + EnableTouchSupport(); + // 应用主题 + ApplyTheme(); + _isLoaded = true; + } + + /// + /// 为面板中的所有交互控件启用触摸支持 + /// + private void EnableTouchSupport() + { + try + { + // 延迟执行,确保所有控件都已加载 + Dispatcher.BeginInvoke(new Action(() => + { + MainWindowSettingsHelper.EnableTouchSupportForControls(this); + }), System.Windows.Threading.DispatcherPriority.Loaded); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"PowerPointPanel 启用触摸支持时出错: {ex.Message}"); + } } public event EventHandler IsTopBarNeedShadowEffect; @@ -29,6 +66,583 @@ namespace Ink_Canvas.Windows.SettingsViews IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs()); } } + + /// + /// 加载设置到UI + /// + public void LoadSettings() + { + if (MainWindow.Settings == null || MainWindow.Settings.PowerPointSettings == null) return; + + _isLoaded = false; + + try + { + var pptSettings = MainWindow.Settings.PowerPointSettings; + + // Microsoft PowerPoint 支持 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchSupportPowerPoint"), pptSettings.PowerPointSupport); + + // PowerPoint 联动增强 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchPowerPointEnhancement"), pptSettings.EnablePowerPointEnhancement); + + // WPS 支持 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchSupportWPS"), pptSettings.IsSupportWPS); + + // WPP进程查杀 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableWppProcessKill"), pptSettings.EnableWppProcessKill); + + // 在 PPT 模式下显示翻页按钮 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchShowPPTButton"), pptSettings.ShowPPTButton); + if (PPTButtonSettingsPanel != null) + { + PPTButtonSettingsPanel.Visibility = pptSettings.ShowPPTButton ? Visibility.Visible : Visibility.Collapsed; + } + + // PPT按钮显示选项 + var dops = pptSettings.PPTButtonsDisplayOption.ToString(); + var dopsc = dops.ToCharArray(); + if (dopsc.Length >= 4) + { + if (CheckboxEnableLBPPTButton != null) CheckboxEnableLBPPTButton.IsChecked = dopsc[0] == '2'; + if (CheckboxEnableRBPPTButton != null) CheckboxEnableRBPPTButton.IsChecked = dopsc[1] == '2'; + if (CheckboxEnableLSPPTButton != null) CheckboxEnableLSPPTButton.IsChecked = dopsc[2] == '2'; + if (CheckboxEnableRSPPTButton != null) CheckboxEnableRSPPTButton.IsChecked = dopsc[3] == '2'; + } + + // 按钮位置 + if (PPTButtonLeftPositionValueSlider != null) + { + PPTButtonLeftPositionValueSlider.Value = pptSettings.PPTLSButtonPosition; + if (PPTButtonLeftPositionValueText != null) + { + PPTButtonLeftPositionValueText.Text = pptSettings.PPTLSButtonPosition.ToString(); + } + } + if (PPTButtonRightPositionValueSlider != null) + { + PPTButtonRightPositionValueSlider.Value = pptSettings.PPTRSButtonPosition; + if (PPTButtonRightPositionValueText != null) + { + PPTButtonRightPositionValueText.Text = pptSettings.PPTRSButtonPosition.ToString(); + } + } + if (PPTButtonLBPositionValueSlider != null) + { + PPTButtonLBPositionValueSlider.Value = pptSettings.PPTLBButtonPosition; + if (PPTButtonLBPositionValueText != null) + { + PPTButtonLBPositionValueText.Text = pptSettings.PPTLBButtonPosition.ToString(); + } + } + if (PPTButtonRBPositionValueSlider != null) + { + PPTButtonRBPositionValueSlider.Value = pptSettings.PPTRBButtonPosition; + if (PPTButtonRBPositionValueText != null) + { + PPTButtonRBPositionValueText.Text = pptSettings.PPTRBButtonPosition.ToString(); + } + } + + // 两侧按钮选项 + var sops = pptSettings.PPTSButtonsOption.ToString(); + var sopsc = sops.ToCharArray(); + if (sopsc.Length >= 3) + { + if (CheckboxSPPTDisplayPage != null) CheckboxSPPTDisplayPage.IsChecked = sopsc[0] == '2'; + if (CheckboxSPPTHalfOpacity != null) CheckboxSPPTHalfOpacity.IsChecked = sopsc[1] == '2'; + if (CheckboxSPPTBlackBackground != null) CheckboxSPPTBlackBackground.IsChecked = sopsc[2] == '2'; + } + + // 左下右下按钮选项 + var bops = pptSettings.PPTBButtonsOption.ToString(); + var bopsc = bops.ToCharArray(); + if (bopsc.Length >= 3) + { + if (CheckboxBPPTDisplayPage != null) CheckboxBPPTDisplayPage.IsChecked = bopsc[0] == '2'; + if (CheckboxBPPTHalfOpacity != null) CheckboxBPPTHalfOpacity.IsChecked = bopsc[1] == '2'; + if (CheckboxBPPTBlackBackground != null) CheckboxBPPTBlackBackground.IsChecked = bopsc[2] == '2'; + } + + // 按钮透明度 + if (PPTLSButtonOpacityValueSlider != null) + { + PPTLSButtonOpacityValueSlider.Value = pptSettings.PPTLSButtonOpacity > 0 ? pptSettings.PPTLSButtonOpacity : 0.5; + if (PPTLSButtonOpacityValueText != null) + { + PPTLSButtonOpacityValueText.Text = PPTLSButtonOpacityValueSlider.Value.ToString("F1"); + } + } + if (PPTRSButtonOpacityValueSlider != null) + { + PPTRSButtonOpacityValueSlider.Value = pptSettings.PPTRSButtonOpacity > 0 ? pptSettings.PPTRSButtonOpacity : 0.5; + if (PPTRSButtonOpacityValueText != null) + { + PPTRSButtonOpacityValueText.Text = PPTRSButtonOpacityValueSlider.Value.ToString("F1"); + } + } + if (PPTLBButtonOpacityValueSlider != null) + { + PPTLBButtonOpacityValueSlider.Value = pptSettings.PPTLBButtonOpacity > 0 ? pptSettings.PPTLBButtonOpacity : 0.5; + if (PPTLBButtonOpacityValueText != null) + { + PPTLBButtonOpacityValueText.Text = PPTLBButtonOpacityValueSlider.Value.ToString("F1"); + } + } + if (PPTRBButtonOpacityValueSlider != null) + { + PPTRBButtonOpacityValueSlider.Value = pptSettings.PPTRBButtonOpacity > 0 ? pptSettings.PPTRBButtonOpacity : 0.5; + if (PPTRBButtonOpacityValueText != null) + { + PPTRBButtonOpacityValueText.Text = PPTRBButtonOpacityValueSlider.Value.ToString("F1"); + } + } + + // PPT 页码按钮可点击 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnablePPTButtonPageClickable"), pptSettings.EnablePPTButtonPageClickable); + + // PPT 翻页按钮长按翻页 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnablePPTButtonLongPressPageTurn"), pptSettings.EnablePPTButtonLongPressPageTurn); + + // 点击翻页时跳过转场动画 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchSkipAnimationsWhenGoNext"), pptSettings.SkipAnimationsWhenGoNext); + + // 进入 PPT 放映时自动进入批注模式 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchShowCanvasAtNewSlideShow"), pptSettings.IsShowCanvasAtNewSlideShow); + + // 允许幻灯片模式下的双指手势 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableTwoFingerGestureInPresentationMode"), pptSettings.IsEnableTwoFingerGestureInPresentationMode); + + // 允许使用手指手势进行幻灯片翻页 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableFingerGestureSlideShowControl"), pptSettings.IsEnableFingerGestureSlideShowControl); + + // PPT 放映模式显示手势按钮 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchShowGestureButtonInSlideShow"), pptSettings.ShowGestureButtonInSlideShow); + + // PPT时间显示胶囊 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnablePPTTimeCapsule"), pptSettings.EnablePPTTimeCapsule); + + // 时间胶囊位置 + SetOptionButtonState("PPTTimeCapsulePosition", pptSettings.PPTTimeCapsulePosition); + + // 记忆并提示上次播放位置 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchNotifyPreviousPage"), pptSettings.IsNotifyPreviousPage); + + // 进入放映时回到首页 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAlwaysGoToFirstPageOnReenter"), pptSettings.IsAlwaysGoToFirstPageOnReenter); + + // 提示隐藏幻灯片 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchNotifyHiddenPage"), pptSettings.IsNotifyHiddenPage); + + // 提示是否已启用自动播放 + SetToggleSwitchState(FindToggleSwitch("ToggleSwitchNotifyAutoPlayPresentation"), pptSettings.IsNotifyAutoPlayPresentation); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"加载PowerPoint设置时出错: {ex.Message}"); + } + + _isLoaded = true; + } + + /// + /// 查找ToggleSwitch控件 + /// + private Border FindToggleSwitch(string name) + { + return this.FindDescendantByName(name) as Border; + } + + /// + /// 设置ToggleSwitch状态 + /// + private void SetToggleSwitchState(Border toggleSwitch, bool isOn) + { + if (toggleSwitch == null) return; + 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) + { + innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left; + } + } + + /// + /// 设置选项按钮状态 + /// + private void SetOptionButtonState(string group, int selectedIndex) + { + var buttons = new Dictionary + { + { "PPTTimeCapsulePosition", new[] { "TopLeft", "TopRight", "TopCenter" } } + }; + + if (!buttons.ContainsKey(group)) return; + + string[] buttonNames = buttons[group]; + + for (int i = 0; i < buttonNames.Length; i++) + { + var button = this.FindDescendantByName($"{group}{buttonNames[i]}Border") as Border; + if (button != null) + { + if (i == selectedIndex) + { + 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; + } + } + } + } + } + + /// + /// ToggleSwitch点击事件处理 + /// + private void ToggleSwitch_Click(object sender, RoutedEventArgs e) + { + if (!_isLoaded) return; + + var border = sender as Border; + if (border == null) return; + + bool isOn = border.Background.ToString() == "#FF3584E4"; + bool newState = !isOn; + SetToggleSwitchState(border, newState); + + string tag = border.Tag?.ToString(); + if (string.IsNullOrEmpty(tag)) return; + + var pptSettings = MainWindow.Settings.PowerPointSettings; + if (pptSettings == null) return; + + switch (tag) + { + case "SupportPowerPoint": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchSupportPowerPoint", newState); + break; + + case "PowerPointEnhancement": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchPowerPointEnhancement", newState); + break; + + case "SupportWPS": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchSupportWPS", newState); + break; + + case "EnableWppProcessKill": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableWppProcessKill", newState); + break; + + case "ShowPPTButton": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchShowPPTButton", newState); + // 更新UI状态 + if (PPTButtonSettingsPanel != null) + { + PPTButtonSettingsPanel.Visibility = newState ? Visibility.Visible : Visibility.Collapsed; + } + break; + + case "EnablePPTButtonPageClickable": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnablePPTButtonPageClickable", newState); + break; + + case "EnablePPTButtonLongPressPageTurn": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnablePPTButtonLongPressPageTurn", newState); + break; + + case "SkipAnimationsWhenGoNext": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchSkipAnimationsWhenGoNext", newState); + break; + + case "ShowCanvasAtNewSlideShow": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchShowCanvasAtNewSlideShow", newState); + break; + + case "EnableTwoFingerGestureInPresentationMode": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableTwoFingerGestureInPresentationMode", newState); + break; + + case "EnableFingerGestureSlideShowControl": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableFingerGestureSlideShowControl", newState); + break; + + case "ShowGestureButtonInSlideShow": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchShowGestureButtonInSlideShow", newState); + break; + + case "EnablePPTTimeCapsule": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnablePPTTimeCapsule", newState); + break; + + case "NotifyPreviousPage": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchNotifyPreviousPage", newState); + break; + + case "AlwaysGoToFirstPageOnReenter": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAlwaysGoToFirstPageOnReenter", newState); + break; + + case "NotifyHiddenPage": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchNotifyHiddenPage", newState); + break; + + case "NotifyAutoPlayPresentation": + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchNotifyAutoPlayPresentation", newState); + break; + } + } + + /// + /// 选项按钮点击事件处理 + /// + private void OptionButton_Click(object sender, RoutedEventArgs e) + { + if (!_isLoaded) return; + + var border = sender as Border; + if (border == null) return; + + string tag = border.Tag?.ToString(); + if (string.IsNullOrEmpty(tag)) return; + + string[] parts = tag.Split('_'); + if (parts.Length < 2) return; + + string group = parts[0]; + string value = parts[1]; + + // 清除同组其他按钮的选中状态 + var parent = border.Parent as Panel; + if (parent != null) + { + foreach (var child in parent.Children) + { + if (child is Border childBorder && childBorder != border) + { + string childTag = childBorder.Tag?.ToString(); + if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) + { + childBorder.Background = new SolidColorBrush(Colors.Transparent); + var textBlock = childBorder.Child as TextBlock; + if (textBlock != null) + { + textBlock.FontWeight = FontWeights.Normal; + } + } + } + } + } + + // 设置当前按钮为选中状态 + border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); + var currentTextBlock = border.Child as TextBlock; + if (currentTextBlock != null) + { + currentTextBlock.FontWeight = FontWeights.Bold; + } + + var pptSettings = MainWindow.Settings.PowerPointSettings; + if (pptSettings == null) return; + + switch (group) + { + case "PPTTimeCapsulePosition": + int position; + switch (value) + { + case "TopLeft": + position = 0; + break; + case "TopRight": + position = 1; + break; + case "TopCenter": + position = 2; + break; + default: + position = 1; + break; + } + MainWindowSettingsHelper.UpdateSettingDirectly(() => + { + pptSettings.PPTTimeCapsulePosition = position; + }, "PPTTimeCapsulePosition"); + break; + } + } + + /// + /// CheckBox变化事件处理 + /// + private void CheckBox_CheckedChanged(object sender, RoutedEventArgs e) + { + if (!_isLoaded) return; + + var checkBox = sender as CheckBox; + if (checkBox == null) return; + + string name = checkBox.Name; + var pptSettings = MainWindow.Settings.PowerPointSettings; + if (pptSettings == null) return; + + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged(name, checkBox.IsChecked ?? false); + } + + + /// + /// Slider值变化事件处理 + /// + private void PPTButtonPositionSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + if (!_isLoaded) return; + + var slider = sender as Slider; + if (slider == null) return; + + string name = slider.Name; + double value = slider.Value; + + // 更新文本显示 + switch (name) + { + case "PPTButtonLeftPositionValueSlider": + if (PPTButtonLeftPositionValueText != null) + { + PPTButtonLeftPositionValueText.Text = ((int)value).ToString(); + } + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("PPTButtonLeftPositionValueSlider", value); + break; + + case "PPTButtonRightPositionValueSlider": + if (PPTButtonRightPositionValueText != null) + { + PPTButtonRightPositionValueText.Text = ((int)value).ToString(); + } + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("PPTButtonRightPositionValueSlider", value); + break; + + case "PPTButtonLBPositionValueSlider": + if (PPTButtonLBPositionValueText != null) + { + PPTButtonLBPositionValueText.Text = ((int)value).ToString(); + } + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("PPTButtonLBPositionValueSlider", value); + break; + + case "PPTButtonRBPositionValueSlider": + if (PPTButtonRBPositionValueText != null) + { + PPTButtonRBPositionValueText.Text = ((int)value).ToString(); + } + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("PPTButtonRBPositionValueSlider", value); + break; + } + } + + /// + /// 按钮透明度Slider值变化事件处理 + /// + private void PPTButtonOpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + if (!_isLoaded) return; + + var slider = sender as Slider; + if (slider == null) return; + + string name = slider.Name; + double value = slider.Value; + + // 更新文本显示 + switch (name) + { + case "PPTLSButtonOpacityValueSlider": + if (PPTLSButtonOpacityValueText != null) + { + PPTLSButtonOpacityValueText.Text = value.ToString("F1"); + } + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("PPTLSButtonOpacityValueSlider", value); + break; + + case "PPTRSButtonOpacityValueSlider": + if (PPTRSButtonOpacityValueText != null) + { + PPTRSButtonOpacityValueText.Text = value.ToString("F1"); + } + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("PPTRSButtonOpacityValueSlider", value); + break; + + case "PPTLBButtonOpacityValueSlider": + if (PPTLBButtonOpacityValueText != null) + { + PPTLBButtonOpacityValueText.Text = value.ToString("F1"); + } + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("PPTLBButtonOpacityValueSlider", value); + break; + + case "PPTRBButtonOpacityValueSlider": + if (PPTRBButtonOpacityValueText != null) + { + PPTRBButtonOpacityValueText.Text = value.ToString("F1"); + } + // 调用 MainWindow 中的方法 + MainWindowSettingsHelper.InvokeSliderValueChanged("PPTRBButtonOpacityValueSlider", value); + break; + } + } + + /// + /// 应用主题 + /// + public void ApplyTheme() + { + try + { + ThemeHelper.ApplyThemeToControl(this); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"PowerPointPanel 应用主题时出错: {ex.Message}"); + } + } } } - diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/SearchPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/SearchPanel.xaml index d36e7f85..073bbe38 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/SearchPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/SearchPanel.xaml @@ -6,10 +6,10 @@ xmlns:local="clr-namespace:Ink_Canvas.Windows.SettingsViews" mc:Ignorable="d" d:DesignHeight="691" d:DesignWidth="910"> - + - + @@ -20,7 +20,7 @@ - + @@ -67,7 +67,7 @@ - + @@ -87,7 +87,7 @@ - + @@ -107,7 +107,7 @@ - + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/SearchPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/SearchPanel.xaml.cs index bb551de6..89556004 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/SearchPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/SearchPanel.xaml.cs @@ -380,6 +380,196 @@ namespace Ink_Canvas.Windows.SettingsViews SearchTextBox.Text = text; PerformSearch(text); } + + /// + /// 应用主题 + /// + public void ApplyTheme() + { + try + { + bool isDarkTheme = ThemeHelper.IsDarkTheme; + + // 更新主背景 + if (SearchPanelMainGrid != null) + { + SearchPanelMainGrid.Background = ThemeHelper.GetBackgroundPrimaryBrush(); + } + + // 更新顶部栏背景 + if (SearchPanelTopBarBorder != null) + { + SearchPanelTopBarBorder.Background = ThemeHelper.GetBackgroundPrimaryBrush(); + } + + // 更新搜索输入框 + if (SearchInputBorder != null) + { + SearchInputBorder.Background = ThemeHelper.GetTextBoxBackgroundBrush(); + SearchInputBorder.BorderBrush = ThemeHelper.GetTextBoxBorderBrush(); + } + + // 更新搜索框文字颜色 + if (SearchTextBox != null) + { + SearchTextBox.Foreground = ThemeHelper.GetTextPrimaryBrush(); + } + + // 更新标题文字颜色 + if (ExactMatchTitle != null) + { + ExactMatchTitle.Foreground = ThemeHelper.GetTextPrimaryBrush(); + } + if (FuzzyMatchTitle != null) + { + FuzzyMatchTitle.Foreground = ThemeHelper.GetTextPrimaryBrush(); + } + if (RelatedItemsTitle != null) + { + RelatedItemsTitle.Foreground = ThemeHelper.GetTextPrimaryBrush(); + } + + // 更新无结果提示文字颜色 + if (NoResultsText != null) + { + NoResultsText.Foreground = ThemeHelper.GetTextSecondaryBrush(); + } + + // 更新搜索框中的图标颜色 + UpdateSearchIconColor(isDarkTheme); + + // 使用 ThemeHelper 递归更新其他元素(如搜索结果项) + ThemeHelper.ApplyThemeToControl(this); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"SearchPanel 应用主题时出错: {ex.Message}"); + } + } + + /// + /// 更新搜索框中的图标颜色 + /// + private void UpdateSearchIconColor(bool isDarkTheme) + { + try + { + Color iconColor = isDarkTheme + ? Color.FromRgb(243, 243, 243) // 深色主题使用浅色图标 #F3F3F3 + : Color.FromRgb(34, 34, 34); // 浅色主题使用深色图标 #222222 + + // 查找搜索输入框中的图标 + if (SearchInputBorder != null) + { + var image = FindVisualChild(SearchInputBorder); + if (image != null && image.Source is DrawingImage drawingImage) + { + if (drawingImage.Drawing is DrawingGroup drawingGroup) + { + var clonedDrawing = CloneDrawingGroup(drawingGroup, iconColor); + image.Source = new DrawingImage { Drawing = clonedDrawing }; + } + } + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"更新搜索图标颜色时出错: {ex.Message}"); + } + } + + /// + /// 克隆 DrawingGroup 并更新颜色 + /// + private DrawingGroup CloneDrawingGroup(DrawingGroup source, Color newColor) + { + var cloned = new DrawingGroup(); + cloned.ClipGeometry = source.ClipGeometry?.Clone(); + cloned.Opacity = source.Opacity; + cloned.Transform = source.Transform?.Clone(); + + foreach (var drawing in source.Children) + { + if (drawing is GeometryDrawing geometryDrawing) + { + var clonedGeometry = geometryDrawing.Geometry?.Clone(); + var clonedBrush = CloneBrush(geometryDrawing.Brush, newColor); + var clonedPen = geometryDrawing.Pen != null + ? ClonePen(geometryDrawing.Pen, newColor) + : null; + + cloned.Children.Add(new GeometryDrawing(clonedBrush, clonedPen, clonedGeometry)); + } + else if (drawing is DrawingGroup subGroup) + { + cloned.Children.Add(CloneDrawingGroup(subGroup, newColor)); + } + else + { + cloned.Children.Add(drawing); + } + } + + return cloned; + } + + /// + /// 克隆 Brush 并更新颜色 + /// + private Brush CloneBrush(Brush source, Color newColor) + { + if (source is SolidColorBrush solidBrush) + { + var originalColor = solidBrush.Color; + if (originalColor.R == 34 && originalColor.G == 34 && originalColor.B == 34) // #222222 + { + return new SolidColorBrush(newColor) { Opacity = solidBrush.Opacity }; + } + else if (originalColor.A > 0 && originalColor != Colors.Transparent && + originalColor.R < 50 && originalColor.G < 50 && originalColor.B < 50) // 深色 + { + return new SolidColorBrush(newColor) { Opacity = solidBrush.Opacity }; + } + return new SolidColorBrush(originalColor) { Opacity = solidBrush.Opacity }; + } + return source?.Clone(); + } + + /// + /// 克隆 Pen 并更新颜色 + /// + private Pen ClonePen(Pen source, Color newColor) + { + var clonedBrush = CloneBrush(source.Brush, newColor); + return new Pen(clonedBrush, source.Thickness) + { + StartLineCap = source.StartLineCap, + EndLineCap = source.EndLineCap, + LineJoin = source.LineJoin, + MiterLimit = source.MiterLimit + }; + } + + /// + /// 在视觉树中查找指定类型的子元素 + /// + private T FindVisualChild(DependencyObject parent) where T : DependencyObject + { + for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(parent); i++) + { + var child = System.Windows.Media.VisualTreeHelper.GetChild(parent, i); + if (child is T result) + { + return result; + } + var childOfChild = FindVisualChild(child); + if (childOfChild != null) + { + return childOfChild; + } + } + return null; + } } public class SettingItem diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/SettingsPanelBase.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/SettingsPanelBase.cs new file mode 100644 index 00000000..6f4db549 --- /dev/null +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/SettingsPanelBase.cs @@ -0,0 +1,273 @@ +using Ink_Canvas; +using iNKORE.UI.WPF.Helpers; +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; + +namespace Ink_Canvas.Windows.SettingsViews +{ + /// + /// 设置面板基类,提供通用的辅助方法 + /// + public abstract class SettingsPanelBase : UserControl + { + protected bool _isLoaded = false; + + public SettingsPanelBase() + { + Loaded += SettingsPanelBase_Loaded; + } + + private void SettingsPanelBase_Loaded(object sender, RoutedEventArgs e) + { + LoadSettings(); + // 添加触摸支持 + EnableTouchSupport(); + // 应用主题(如果面板有 ApplyTheme 方法) + try + { + var applyThemeMethod = this.GetType().GetMethod("ApplyTheme", + System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); + if (applyThemeMethod != null) + { + applyThemeMethod.Invoke(this, null); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"SettingsPanelBase 应用主题时出错: {ex.Message}"); + } + _isLoaded = true; + } + + /// + /// 为面板中的所有交互控件启用触摸支持 + /// + protected virtual void EnableTouchSupport() + { + try + { + // 延迟执行,确保所有控件都已加载 + Dispatcher.BeginInvoke(new Action(() => + { + EnableTouchSupportForControls(this); + }), System.Windows.Threading.DispatcherPriority.Loaded); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"启用触摸支持时出错: {ex.Message}"); + } + } + + /// + /// 为控件树中的所有交互控件启用触摸支持 + /// + private void EnableTouchSupportForControls(DependencyObject parent) + { + if (parent == null) return; + + for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++) + { + var child = VisualTreeHelper.GetChild(parent, i); + + // 为 Border 控件(ToggleSwitch、选项按钮等)启用触摸支持 + if (child is Border border) + { + // 检查是否是交互控件(有 Tag 或 Cursor 为 Hand) + if (border.Tag != null || border.Cursor == Cursors.Hand) + { + border.IsManipulationEnabled = true; + + // 添加触摸事件支持,将触摸事件转换为鼠标事件 + border.TouchDown += Border_TouchDown; + border.PreviewTouchDown += Border_PreviewTouchDown; + } + } + // 为 Button 控件启用触摸支持 + else if (child is Button button) + { + button.IsManipulationEnabled = true; + } + // 为 ComboBox 启用触摸支持 + else if (child is ComboBox comboBox) + { + comboBox.IsManipulationEnabled = true; + } + // 为 Slider 启用触摸支持 + else if (child is Slider slider) + { + slider.IsManipulationEnabled = true; + } + // 为 TextBox 启用触摸支持 + else if (child is TextBox textBox) + { + textBox.IsManipulationEnabled = true; + } + + // 递归处理子元素 + EnableTouchSupportForControls(child); + } + } + + /// + /// Border 触摸按下事件处理 + /// + private void Border_TouchDown(object sender, TouchEventArgs e) + { + var border = sender as Border; + if (border == null) return; + + // 获取触摸点位置 + var touchPoint = e.GetTouchPoint(border); + + // 创建模拟的鼠标事件 + var mouseButtonEventArgs = new MouseButtonEventArgs(Mouse.PrimaryDevice, Environment.TickCount, MouseButton.Left) + { + RoutedEvent = UIElement.MouseLeftButtonDownEvent, + Source = border + }; + + // 触发鼠标按下事件 + border.RaiseEvent(mouseButtonEventArgs); + + // 捕获触摸设备 + border.CaptureTouch(e.TouchDevice); + e.Handled = true; + } + + /// + /// Border 预览触摸按下事件处理 + /// + private void Border_PreviewTouchDown(object sender, TouchEventArgs e) + { + var border = sender as Border; + if (border == null) return; + + // 获取触摸点位置 + var touchPoint = e.GetTouchPoint(border); + + // 创建模拟的鼠标事件 + var mouseButtonEventArgs = new MouseButtonEventArgs(Mouse.PrimaryDevice, Environment.TickCount, MouseButton.Left) + { + RoutedEvent = UIElement.PreviewMouseLeftButtonDownEvent, + Source = border + }; + + // 触发预览鼠标按下事件 + border.RaiseEvent(mouseButtonEventArgs); + + e.Handled = true; + } + + /// + /// 加载设置到UI - 子类需要实现 + /// + public abstract void LoadSettings(); + + /// + /// 查找ToggleSwitch控件 + /// + protected Border FindToggleSwitch(string name) + { + return this.FindDescendantByName(name) as Border; + } + + /// + /// 设置ToggleSwitch状态 + /// + protected void SetToggleSwitchState(Border toggleSwitch, bool isOn) + { + if (toggleSwitch == null) return; + 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) + { + innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left; + } + } + + /// + /// 通用的ToggleSwitch点击事件处理 + /// + protected virtual void ToggleSwitch_Click(object sender, RoutedEventArgs e) + { + if (!_isLoaded) return; + + var border = sender as Border; + if (border == null) return; + + bool isOn = border.Background.ToString() == "#FF3584E4"; + bool newState = !isOn; + SetToggleSwitchState(border, newState); + + string tag = border.Tag?.ToString(); + if (string.IsNullOrEmpty(tag)) return; + + HandleToggleSwitchChange(tag, newState); + } + + /// + /// 处理ToggleSwitch变化 - 子类需要实现 + /// + protected abstract void HandleToggleSwitchChange(string tag, bool newState); + + /// + /// 处理选项按钮变化 - 子类可以重写 + /// + protected virtual void HandleOptionButtonChange(object sender, string tag) + { + // 默认实现:清除同组其他按钮的选中状态 + var border = sender as Border; + if (border == null) return; + + string[] parts = tag.Split('_'); + if (parts.Length >= 2) + { + string group = parts[0]; + string value = parts[1]; + + // 清除同组其他按钮的选中状态 + var parent = border.Parent as Panel; + if (parent != null) + { + foreach (var child in parent.Children) + { + if (child is Border childBorder && childBorder != border) + { + string childTag = childBorder.Tag?.ToString(); + if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) + { + childBorder.Background = new SolidColorBrush(Colors.Transparent); + var textBlock = childBorder.Child as TextBlock; + if (textBlock != null) + { + textBlock.FontWeight = FontWeights.Normal; + } + } + } + } + } + + // 设置当前按钮为选中状态 + border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225)); + var currentTextBlock = border.Child as TextBlock; + if (currentTextBlock != null) + { + currentTextBlock.FontWeight = FontWeights.Bold; + } + + HandleOptionChange(group, value); + } + } + + /// + /// 处理选项变化 - 子类需要实现 + /// + protected abstract void HandleOptionChange(string group, string value); + } +} + diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/ShortcutsPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/ShortcutsPanel.xaml.cs index 6bb98663..bd20df56 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/ShortcutsPanel.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/ShortcutsPanel.xaml.cs @@ -29,6 +29,21 @@ namespace Ink_Canvas.Windows.SettingsViews IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs()); } } + + /// + /// 应用主题 + /// + public void ApplyTheme() + { + try + { + ThemeHelper.ApplyThemeToControl(this); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"ShortcutsPanel 应用主题时出错: {ex.Message}"); + } + } } } diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/SnapshotPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/SnapshotPanel.xaml index a5d19a9b..00dfc551 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsViews/SnapshotPanel.xaml +++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/SnapshotPanel.xaml @@ -36,7 +36,7 @@ - + @@ -50,7 +50,7 @@ - + @@ -64,7 +64,7 @@ - + @@ -78,7 +78,7 @@ - + @@ -93,7 +93,7 @@ - + @@ -107,12 +107,12 @@ - -