Revert "add:新设置"

This reverts commit fbfac18ca0.
This commit is contained in:
2026-01-10 17:31:55 +08:00
parent 47885685fe
commit 0fb5c04deb
41 changed files with 2615 additions and 1994 deletions
@@ -1,4 +1,4 @@
using Ink_Canvas;
using Ink_Canvas;
using iNKORE.UI.WPF.Helpers;
using System;
using System.Collections.Generic;
@@ -9,6 +9,9 @@ using Application = System.Windows.Application;
namespace Ink_Canvas.Windows.SettingsViews
{
/// <summary>
/// GesturesPanel.xaml 的交互逻辑
/// </summary>
public partial class GesturesPanel : UserControl
{
private bool _isLoaded = false;
@@ -22,14 +25,21 @@ namespace Ink_Canvas.Windows.SettingsViews
private void GesturesPanel_Loaded(object sender, RoutedEventArgs e)
{
LoadSettings();
// 添加触摸支持
EnableTouchSupport();
// 应用主题
ApplyTheme();
_isLoaded = true;
}
/// <summary>
/// 为面板中的所有交互控件启用触摸支持
/// </summary>
private void EnableTouchSupport()
{
try
{
// 延迟执行,确保所有控件都已加载
Dispatcher.BeginInvoke(new Action(() =>
{
MainWindowSettingsHelper.EnableTouchSupportForControls(this);
@@ -37,7 +47,7 @@ namespace Ink_Canvas.Windows.SettingsViews
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"GesturesPanel 启用触摸支持时出? {ex.Message}");
System.Diagnostics.Debug.WriteLine($"GesturesPanel 启用触摸支持时出错: {ex.Message}");
}
}
@@ -56,6 +66,10 @@ namespace Ink_Canvas.Windows.SettingsViews
IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs());
}
}
/// <summary>
/// 加载设置到UI
/// </summary>
public void LoadSettings()
{
if (MainWindow.Settings == null) return;
@@ -64,36 +78,51 @@ namespace Ink_Canvas.Windows.SettingsViews
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}");
System.Diagnostics.Debug.WriteLine($"加载手势操作设置时出错: {ex.Message}");
}
_isLoaded = true;
}
/// <summary>
/// 查找ToggleSwitch控件
/// </summary>
private Border FindToggleSwitch(string name)
{
return this.FindDescendantByName(name) as Border;
}
/// <summary>
/// 设置ToggleSwitch状态
/// </summary>
private void SetToggleSwitchState(Border toggleSwitch, bool isOn)
{
if (toggleSwitch == null) return;
toggleSwitch.Background = isOn
? ThemeHelper.GetToggleSwitchOnBackgroundBrush()
: ThemeHelper.GetToggleSwitchOffBackgroundBrush();
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
var innerBorder = toggleSwitch.Child as Border;
if (innerBorder != null)
{
@@ -101,6 +130,9 @@ namespace Ink_Canvas.Windows.SettingsViews
}
}
/// <summary>
/// 设置选项按钮状态
/// </summary>
private void SetOptionButtonState(string group, int selectedIndex)
{
var buttons = new Dictionary<string, string[]>
@@ -117,11 +149,31 @@ namespace Ink_Canvas.Windows.SettingsViews
var button = this.FindDescendantByName($"{group}{buttonNames[i]}Border") as Border;
if (button != null)
{
ThemeHelper.SetOptionButtonSelectedState(button, i == selectedIndex);
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;
}
}
}
}
}
/// <summary>
/// ToggleSwitch点击事件处理
/// </summary>
private void ToggleSwitch_Click(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
@@ -129,7 +181,7 @@ namespace Ink_Canvas.Windows.SettingsViews
var border = sender as Border;
if (border == null) return;
bool isOn = ThemeHelper.IsToggleSwitchOn(border.Background);
bool isOn = border.Background.ToString() == "#FF3584E4";
bool newState = !isOn;
SetToggleSwitchState(border, newState);
@@ -139,15 +191,19 @@ namespace Ink_Canvas.Windows.SettingsViews
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;
@@ -156,6 +212,9 @@ namespace Ink_Canvas.Windows.SettingsViews
}
}
/// <summary>
/// 选项按钮点击事件处理
/// </summary>
private void OptionButton_Click(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
@@ -172,6 +231,7 @@ namespace Ink_Canvas.Windows.SettingsViews
string group = parts[0];
string value = parts[1];
// 清除同组其他按钮的选中状态
var parent = border.Parent as Panel;
if (parent != null)
{
@@ -182,13 +242,24 @@ namespace Ink_Canvas.Windows.SettingsViews
string childTag = childBorder.Tag?.ToString();
if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_"))
{
ThemeHelper.SetOptionButtonSelectedState(childBorder, false);
childBorder.Background = new SolidColorBrush(Colors.Transparent);
var textBlock = childBorder.Child as TextBlock;
if (textBlock != null)
{
textBlock.FontWeight = FontWeights.Normal;
}
}
}
}
}
ThemeHelper.SetOptionButtonSelectedState(border, true);
// 设置当前按钮为选中状态
border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
var currentTextBlock = border.Child as TextBlock;
if (currentTextBlock != null)
{
currentTextBlock.FontWeight = FontWeights.Bold;
}
switch (group)
{
@@ -209,6 +280,7 @@ namespace Ink_Canvas.Windows.SettingsViews
sensitivity = 0;
break;
}
// 调用 MainWindow 中的方法(通过设置 ComboBox 的 SelectedIndex
var mainWindow = Application.Current.MainWindow as MainWindow;
if (mainWindow != null)
{
@@ -216,10 +288,12 @@ namespace Ink_Canvas.Windows.SettingsViews
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)
@@ -233,20 +307,18 @@ namespace Ink_Canvas.Windows.SettingsViews
}
}
/// <summary>
/// 应用主题
/// </summary>
public void ApplyTheme()
{
try
{
ThemeHelper.ApplyThemeToControl(this);
if (MainWindow.Settings?.Canvas != null)
{
SetOptionButtonState("PalmEraserSensitivity", MainWindow.Settings.Canvas.PalmEraserSensitivity);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"GesturesPanel 应用主题时出? {ex.Message}");
System.Diagnostics.Debug.WriteLine($"GesturesPanel 应用主题时出错: {ex.Message}");
}
}
}