add:新设置
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Ink_Canvas;
|
||||
using Ink_Canvas;
|
||||
using iNKORE.UI.WPF.Helpers;
|
||||
using System;
|
||||
using System.Windows;
|
||||
@@ -6,9 +6,6 @@ using System.Windows.Controls;
|
||||
|
||||
namespace Ink_Canvas.Windows.SettingsViews
|
||||
{
|
||||
/// <summary>
|
||||
/// InkRecognitionPanel.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class InkRecognitionPanel : UserControl
|
||||
{
|
||||
private bool _isLoaded = false;
|
||||
@@ -22,16 +19,10 @@ 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;
|
||||
@@ -42,8 +33,12 @@ 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;
|
||||
@@ -52,8 +47,6 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
AutoStraightenLineThresholdText.Text = ((int)canvas.AutoStraightenLineThreshold).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
// 灵敏度
|
||||
if (LineStraightenSensitivitySlider != null)
|
||||
{
|
||||
LineStraightenSensitivitySlider.Value = inkToShape.LineStraightenSensitivity;
|
||||
@@ -62,38 +55,6 @@ 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;
|
||||
@@ -105,7 +66,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"加载墨迹识别设置时出错: {ex.Message}");
|
||||
System.Diagnostics.Debug.WriteLine($"加载墨迹识别设置时出�? {ex.Message}");
|
||||
}
|
||||
|
||||
_isLoaded = true;
|
||||
@@ -126,10 +87,6 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应用主题
|
||||
/// </summary>
|
||||
public void ApplyTheme()
|
||||
{
|
||||
try
|
||||
@@ -138,13 +95,66 @@ 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;
|
||||
|
||||
/// <summary>
|
||||
/// Slider值变化事件处理
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
private void AutoStraightenLineThresholdSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||
{
|
||||
if (!_isLoaded) return;
|
||||
|
||||
Reference in New Issue
Block a user