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.Windows;
@@ -6,6 +6,9 @@ using System.Windows.Controls;
namespace Ink_Canvas.Windows.SettingsViews
{
/// <summary>
/// InkRecognitionPanel.xaml 的交互逻辑
/// </summary>
public partial class InkRecognitionPanel : UserControl
{
private bool _isLoaded = false;
@@ -19,10 +22,16 @@ namespace Ink_Canvas.Windows.SettingsViews
private void InkRecognitionPanel_Loaded(object sender, RoutedEventArgs e)
{
LoadSettings();
// 添加触摸支持
MainWindowSettingsHelper.EnableTouchSupportForControls(this);
// 应用主题
ApplyTheme();
_isLoaded = true;
}
/// <summary>
/// 加载设置
/// </summary>
public void LoadSettings()
{
if (MainWindow.Settings == null || MainWindow.Settings.Canvas == null || MainWindow.Settings.InkToShape == null) return;
@@ -33,12 +42,8 @@ namespace Ink_Canvas.Windows.SettingsViews
{
var canvas = MainWindow.Settings.Canvas;
var inkToShape = MainWindow.Settings.InkToShape;
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableInkToShape"), inkToShape.IsInkToShapeEnabled);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableInkToShapeNoFakePressureRectangle"), inkToShape.IsInkToShapeNoFakePressureRectangle);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableInkToShapeNoFakePressureTriangle"), inkToShape.IsInkToShapeNoFakePressureTriangle);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoStraightenLine"), canvas.AutoStraightenLine);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchHighPrecisionLineStraighten"), canvas.HighPrecisionLineStraighten);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchLineEndpointSnapping"), canvas.LineEndpointSnapping);
// 自动拉直线阈值
if (AutoStraightenLineThresholdSlider != null)
{
AutoStraightenLineThresholdSlider.Value = canvas.AutoStraightenLineThreshold;
@@ -47,6 +52,8 @@ namespace Ink_Canvas.Windows.SettingsViews
AutoStraightenLineThresholdText.Text = ((int)canvas.AutoStraightenLineThreshold).ToString();
}
}
// 灵敏度
if (LineStraightenSensitivitySlider != null)
{
LineStraightenSensitivitySlider.Value = inkToShape.LineStraightenSensitivity;
@@ -55,6 +62,38 @@ namespace Ink_Canvas.Windows.SettingsViews
LineStraightenSensitivityText.Text = inkToShape.LineStraightenSensitivity.ToString("F2");
}
}
// 高精度直线拉直
var toggleSwitchHighPrecisionLineStraighten = this.FindDescendantByName("ToggleSwitchHighPrecisionLineStraighten") as Border;
if (toggleSwitchHighPrecisionLineStraighten != null)
{
bool isOn = canvas.HighPrecisionLineStraighten;
toggleSwitchHighPrecisionLineStraighten.Background = isOn
? new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
var innerBorder = toggleSwitchHighPrecisionLineStraighten.Child as Border;
if (innerBorder != null)
{
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
}
}
// 直线端点吸附
var toggleSwitchLineEndpointSnapping = this.FindDescendantByName("ToggleSwitchLineEndpointSnapping") as Border;
if (toggleSwitchLineEndpointSnapping != null)
{
bool isOn = canvas.LineEndpointSnapping;
toggleSwitchLineEndpointSnapping.Background = isOn
? new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
var innerBorder = toggleSwitchLineEndpointSnapping.Child as Border;
if (innerBorder != null)
{
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
}
}
// 吸附距离
if (LineEndpointSnappingThresholdSlider != null)
{
LineEndpointSnappingThresholdSlider.Value = canvas.LineEndpointSnappingThreshold;
@@ -66,7 +105,7 @@ namespace Ink_Canvas.Windows.SettingsViews
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"加载墨迹识别设置时出? {ex.Message}");
System.Diagnostics.Debug.WriteLine($"加载墨迹识别设置时出错: {ex.Message}");
}
_isLoaded = true;
@@ -87,6 +126,10 @@ namespace Ink_Canvas.Windows.SettingsViews
IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs());
}
}
/// <summary>
/// 应用主题
/// </summary>
public void ApplyTheme()
{
try
@@ -95,66 +138,13 @@ namespace Ink_Canvas.Windows.SettingsViews
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"InkRecognitionPanel 应用主题时出? {ex.Message}");
System.Diagnostics.Debug.WriteLine($"InkRecognitionPanel 应用主题时出错: {ex.Message}");
}
}
private Border FindToggleSwitch(string name)
{
return this.FindDescendantByName(name) as Border;
}
private void SetToggleSwitchState(Border toggleSwitch, bool isOn)
{
if (toggleSwitch == null) return;
toggleSwitch.Background = isOn
? ThemeHelper.GetToggleSwitchOnBackgroundBrush()
: ThemeHelper.GetToggleSwitchOffBackgroundBrush();
var innerBorder = toggleSwitch.Child as Border;
if (innerBorder != null)
{
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
}
}
private void ToggleSwitch_Click(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
e.Handled = true;
var border = sender as Border;
if (border == null) return;
bool isOn = ThemeHelper.IsToggleSwitchOn(border.Background);
bool newState = !isOn;
SetToggleSwitchState(border, newState);
string tag = border.Tag?.ToString();
if (string.IsNullOrEmpty(tag)) return;
switch (tag)
{
case "EnableInkToShape":
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableInkToShape", newState);
break;
case "EnableInkToShapeNoFakePressureRectangle":
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableInkToShapeNoFakePressureRectangle", newState);
break;
case "EnableInkToShapeNoFakePressureTriangle":
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableInkToShapeNoFakePressureTriangle", newState);
break;
case "AutoStraightenLine":
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAutoStraightenLine", newState);
break;
case "HighPrecisionLineStraighten":
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchHighPrecisionLineStraighten", newState);
break;
case "LineEndpointSnapping":
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchLineEndpointSnapping", newState);
break;
}
}
/// <summary>
/// Slider值变化事件处理
/// </summary>
private void AutoStraightenLineThresholdSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;