Revert "add:新设置"

This reverts commit 0776071454.
This commit is contained in:
2026-01-10 17:32:14 +08:00
parent 0fb5c04deb
commit 758f414302
24 changed files with 292 additions and 1282 deletions
@@ -77,7 +77,7 @@
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="笔尖模式的接触面积区分界限" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0">
<Slider x:Name="NibModeBoundsWidthSlider" Width="150" Minimum="1" Maximum="50" Value="5" TickFrequency="1" IsSnapToTickEnabled="True" ValueChanged="NibModeBoundsWidthSlider_ValueChanged"/>
<Slider x:Name="NibModeBoundsWidthSlider" Width="150" Minimum="1" Maximum="50" Value="5" TickFrequency="1" IsSnapToTickEnabled="True"/>
<TextBlock x:Name="NibModeBoundsWidthText" Text="5" VerticalAlignment="Center" FontSize="14" Margin="12,0,0,0" Foreground="#2e3436"/>
</StackPanel>
</Grid>
@@ -88,7 +88,7 @@
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="手指模式的接触面积区分界限" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0">
<Slider x:Name="FingerModeBoundsWidthSlider" Width="150" Minimum="1" Maximum="50" Value="20" TickFrequency="1" IsSnapToTickEnabled="True" ValueChanged="FingerModeBoundsWidthSlider_ValueChanged"/>
<Slider x:Name="FingerModeBoundsWidthSlider" Width="150" Minimum="1" Maximum="50" Value="20" TickFrequency="1" IsSnapToTickEnabled="True"/>
<TextBlock x:Name="FingerModeBoundsWidthText" Text="20" VerticalAlignment="Center" FontSize="14" Margin="12,0,0,0" Foreground="#2e3436"/>
</StackPanel>
</Grid>
@@ -169,7 +169,7 @@ namespace Ink_Canvas.Windows.SettingsViews
if (toggleSwitch == null) return;
toggleSwitch.Background = isOn
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
var innerBorder = toggleSwitch.Child as Border;
if (innerBorder != null)
{
@@ -161,7 +161,7 @@
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="调整浮动工具栏的大小" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0">
<Slider x:Name="ViewboxFloatingBarScaleTransformValueSlider" Width="150" Minimum="0.5" Maximum="1.25" Value="1" TickFrequency="0.05" IsSnapToTickEnabled="True" ValueChanged="ViewboxFloatingBarScaleTransformValueSlider_ValueChanged"/>
<Slider x:Name="ViewboxFloatingBarScaleTransformValueSlider" Width="150" Minimum="0.5" Maximum="1.25" Value="1" TickFrequency="0.05" IsSnapToTickEnabled="True"/>
<TextBlock x:Name="ViewboxFloatingBarScaleTransformValueText" Text="1.00" VerticalAlignment="Center" FontSize="14" Margin="12,0,0,0" Foreground="#2e3436"/>
</StackPanel>
</Grid>
@@ -172,7 +172,7 @@
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="调整浮动工具栏的透明度" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0">
<Slider x:Name="ViewboxFloatingBarOpacityValueSlider" Width="150" Minimum="0.3" Maximum="1" Value="1" TickFrequency="0.05" IsSnapToTickEnabled="True" ValueChanged="ViewboxFloatingBarOpacityValueSlider_ValueChanged"/>
<Slider x:Name="ViewboxFloatingBarOpacityValueSlider" Width="150" Minimum="0.3" Maximum="1" Value="1" TickFrequency="0.05" IsSnapToTickEnabled="True"/>
<TextBlock x:Name="ViewboxFloatingBarOpacityValueText" Text="1.00" VerticalAlignment="Center" FontSize="14" Margin="12,0,0,0" Foreground="#2e3436"/>
</StackPanel>
</Grid>
@@ -183,7 +183,7 @@
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="在PPT模式下浮动工具栏的透明度(重新进入PPT放映后生效)" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0">
<Slider x:Name="ViewboxFloatingBarOpacityInPPTValueSlider" Width="150" Minimum="0.3" Maximum="1" Value="1" TickFrequency="0.05" IsSnapToTickEnabled="True" ValueChanged="ViewboxFloatingBarOpacityInPPTValueSlider_ValueChanged"/>
<Slider x:Name="ViewboxFloatingBarOpacityInPPTValueSlider" Width="150" Minimum="0.3" Maximum="1" Value="1" TickFrequency="0.05" IsSnapToTickEnabled="True"/>
<TextBlock x:Name="ViewboxFloatingBarOpacityInPPTValueText" Text="1.00" VerticalAlignment="Center" FontSize="14" Margin="12,0,0,0" Foreground="#2e3436"/>
</StackPanel>
</Grid>
@@ -9,75 +9,9 @@ namespace Ink_Canvas.Windows.SettingsViews
/// </summary>
public partial class AppearancePanel : UserControl
{
private bool _isLoaded = false;
public AppearancePanel()
{
InitializeComponent();
Loaded += AppearancePanel_Loaded;
}
private void AppearancePanel_Loaded(object sender, RoutedEventArgs e)
{
LoadSettings();
// 添加触摸支持
MainWindowSettingsHelper.EnableTouchSupportForControls(this);
// 应用主题
ApplyTheme();
_isLoaded = true;
}
/// <summary>
/// 加载设置
/// </summary>
public void LoadSettings()
{
if (MainWindow.Settings == null || MainWindow.Settings.Appearance == null) return;
_isLoaded = false;
try
{
var appearance = MainWindow.Settings.Appearance;
// 浮动工具栏缩放
if (ViewboxFloatingBarScaleTransformValueSlider != null)
{
double val = appearance.ViewboxFloatingBarScaleTransformValue;
if (val == 0) val = 1.0;
ViewboxFloatingBarScaleTransformValueSlider.Value = val;
if (ViewboxFloatingBarScaleTransformValueText != null)
{
ViewboxFloatingBarScaleTransformValueText.Text = val.ToString("F2");
}
}
// 浮动工具栏透明度
if (ViewboxFloatingBarOpacityValueSlider != null)
{
ViewboxFloatingBarOpacityValueSlider.Value = appearance.ViewboxFloatingBarOpacityValue;
if (ViewboxFloatingBarOpacityValueText != null)
{
ViewboxFloatingBarOpacityValueText.Text = appearance.ViewboxFloatingBarOpacityValue.ToString("F2");
}
}
// 浮栏在PPT下透明度
if (ViewboxFloatingBarOpacityInPPTValueSlider != null)
{
ViewboxFloatingBarOpacityInPPTValueSlider.Value = appearance.ViewboxFloatingBarOpacityInPPTValue;
if (ViewboxFloatingBarOpacityInPPTValueText != null)
{
ViewboxFloatingBarOpacityInPPTValueText.Text = appearance.ViewboxFloatingBarOpacityInPPTValue.ToString("F2");
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"加载外观设置时出错: {ex.Message}");
}
_isLoaded = true;
}
public event EventHandler<RoutedEventArgs> IsTopBarNeedShadowEffect;
@@ -110,41 +44,5 @@ namespace Ink_Canvas.Windows.SettingsViews
System.Diagnostics.Debug.WriteLine($"AppearancePanel 应用主题时出错: {ex.Message}");
}
}
/// <summary>
/// Slider值变化事件处理
/// </summary>
private void ViewboxFloatingBarScaleTransformValueSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
if (ViewboxFloatingBarScaleTransformValueSlider != null && ViewboxFloatingBarScaleTransformValueText != null)
{
double val = ViewboxFloatingBarScaleTransformValueSlider.Value;
ViewboxFloatingBarScaleTransformValueText.Text = val.ToString("F2");
MainWindowSettingsHelper.InvokeSliderValueChanged("ViewboxFloatingBarScaleTransformValueSlider", val);
}
}
private void ViewboxFloatingBarOpacityValueSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
if (ViewboxFloatingBarOpacityValueSlider != null && ViewboxFloatingBarOpacityValueText != null)
{
double val = ViewboxFloatingBarOpacityValueSlider.Value;
ViewboxFloatingBarOpacityValueText.Text = val.ToString("F2");
MainWindowSettingsHelper.InvokeSliderValueChanged("ViewboxFloatingBarOpacityValueSlider", val);
}
}
private void ViewboxFloatingBarOpacityInPPTValueSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
if (ViewboxFloatingBarOpacityInPPTValueSlider != null && ViewboxFloatingBarOpacityInPPTValueText != null)
{
double val = ViewboxFloatingBarOpacityInPPTValueSlider.Value;
ViewboxFloatingBarOpacityInPPTValueText.Text = val.ToString("F2");
MainWindowSettingsHelper.InvokeSliderValueChanged("ViewboxFloatingBarOpacityInPPTValueSlider", val);
}
}
}
}
@@ -288,8 +288,8 @@
<Image Source="/Resources/Icons-png/PPTTools.png" Margin="0,0,6,0" Width="28" Height="28" VerticalAlignment="Center"/>
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="自动查杀希沃&quot;PPT 小工具&quot;" VerticalAlignment="Center"/>
</StackPanel>
<Border x:Name="ToggleSwitchAutoKillPptService" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center" IsHitTestVisible="False">
<Border x:Name="ToggleSwitchAutoKillPptService" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
@@ -304,8 +304,8 @@
<Image Source="/Resources/Icons-png/EasiNote.png" Margin="0,0,6,0" Width="28" Height="28" VerticalAlignment="Center"/>
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="自动查杀 希沃白板5" VerticalAlignment="Center"/>
</StackPanel>
<Border x:Name="ToggleSwitchAutoKillEasiNote" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center" IsHitTestVisible="False">
<Border x:Name="ToggleSwitchAutoKillEasiNote" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
@@ -318,8 +318,8 @@
<Image Source="/Resources/Icons-png/HiteAnnotation.png" Margin="0,0,6,0" Width="28" Height="28" VerticalAlignment="Center"/>
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="自动查杀 鸿合屏幕书写" VerticalAlignment="Center"/>
</StackPanel>
<Border x:Name="ToggleSwitchAutoKillHiteAnnotation" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center" IsHitTestVisible="False">
<Border x:Name="ToggleSwitchAutoKillHiteAnnotation" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
@@ -332,8 +332,8 @@
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="鸿合屏幕书写查杀后自动进入批注" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="查杀鸿合屏幕书写后自动进入批注模式" HorizontalAlignment="Left"/>
</StackPanel>
<Border x:Name="ToggleSwitchAutoEnterAnnotationAfterKillHite" Style="{StaticResource ToggleSwitchStyle}" Background="#e1e1e1" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Left" VerticalAlignment="Center" IsHitTestVisible="False">
<Border x:Name="ToggleSwitchAutoEnterAnnotationAfterKillHite" Style="{StaticResource ToggleSwitchStyle}" Background="#e1e1e1">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Left" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
@@ -346,8 +346,8 @@
<Image Source="/Resources/Icons-png/VComYouJiao.png" Margin="0,0,6,0" Width="28" Height="28" VerticalAlignment="Center"/>
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="自动查杀 优教授课端" VerticalAlignment="Center"/>
</StackPanel>
<Border x:Name="ToggleSwitchAutoKillVComYouJiao" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center" IsHitTestVisible="False">
<Border x:Name="ToggleSwitchAutoKillVComYouJiao" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
@@ -360,8 +360,8 @@
<Image Source="/Resources/Icons-png/Seewo2Annotation.png" Margin="0,0,6,0" Width="28" Height="28" VerticalAlignment="Center"/>
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="自动查杀 希沃桌面2.0 桌面批注" VerticalAlignment="Center"/>
</StackPanel>
<Border x:Name="ToggleSwitchAutoKillSeewoLauncher2DesktopAnnotation" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center" IsHitTestVisible="False">
<Border x:Name="ToggleSwitchAutoKillSeewoLauncher2DesktopAnnotation" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
@@ -377,8 +377,8 @@
<Image Source="/Resources/Icons-png/InkCanvas.png" Margin="0,0,6,0" Width="28" Height="28" VerticalAlignment="Center"/>
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="自动查杀 Ink Canvas 和 IC+" VerticalAlignment="Center"/>
</StackPanel>
<Border x:Name="ToggleSwitchAutoKillInkCanvas" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center" IsHitTestVisible="False">
<Border x:Name="ToggleSwitchAutoKillInkCanvas" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
@@ -391,8 +391,8 @@
<Image Source="/Resources/Icons-png/ica.png" Margin="0,0,6,0" Width="28" Height="28" VerticalAlignment="Center"/>
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="自动查杀ICA(新版旧版通杀)" VerticalAlignment="Center"/>
</StackPanel>
<Border x:Name="ToggleSwitchAutoKillICA" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center" IsHitTestVisible="False">
<Border x:Name="ToggleSwitchAutoKillICA" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
@@ -405,8 +405,8 @@
<Image Source="/Resources/Icons-png/idt.png" Margin="0,0,6,0" Width="28" Height="28" VerticalAlignment="Center"/>
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="自动查杀 智绘教Inkeys(仅限新版)" VerticalAlignment="Center"/>
</StackPanel>
<Border x:Name="ToggleSwitchAutoKillIDT" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center" IsHitTestVisible="False">
<Border x:Name="ToggleSwitchAutoKillIDT" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
@@ -1,10 +1,7 @@
using Ink_Canvas;
using iNKORE.UI.WPF.Helpers;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Application = System.Windows.Application;
using Ink_Canvas.Windows.SettingsViews;
namespace Ink_Canvas.Windows.SettingsViews
{
@@ -34,80 +31,69 @@ namespace Ink_Canvas.Windows.SettingsViews
/// <summary>
/// 加载设置
/// </summary>
public void LoadSettings()
private void LoadSettings()
{
if (MainWindow.Settings == null || MainWindow.Settings.Automation == null)
{
_isLoaded = true;
return;
}
_isLoaded = false;
try
{
if (MainWindow.Settings == null || MainWindow.Settings.Automation == null) return;
_isLoaded = false;
var automation = MainWindow.Settings.Automation;
// 设置所有 ToggleSwitch 的状态
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInEasiNote"), automation.IsAutoFoldInEasiNote);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInEasiCamera"), automation.IsAutoFoldInEasiCamera);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInHiteTouchPro"), automation.IsAutoFoldInHiteTouchPro);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInEasiNote3"), automation.IsAutoFoldInEasiNote3);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInEasiNote3C"), automation.IsAutoFoldInEasiNote3C);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInEasiNote5C"), automation.IsAutoFoldInEasiNote5C);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInSeewoPincoTeacher"), automation.IsAutoFoldInSeewoPincoTeacher);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInHiteCamera"), automation.IsAutoFoldInHiteCamera);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInHiteLightBoard"), automation.IsAutoFoldInHiteLightBoard);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInWxBoardMain"), automation.IsAutoFoldInWxBoardMain);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInMSWhiteboard"), automation.IsAutoFoldInMSWhiteboard);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInAdmoxWhiteboard"), automation.IsAutoFoldInAdmoxWhiteboard);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInAdmoxBooth"), automation.IsAutoFoldInAdmoxBooth);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInQPoint"), automation.IsAutoFoldInQPoint);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInYiYunVisualPresenter"), automation.IsAutoFoldInYiYunVisualPresenter);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInMaxHubWhiteboard"), automation.IsAutoFoldInMaxHubWhiteboard);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInPPTSlideShow"), automation.IsAutoFoldInPPTSlideShow);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInEasiNoteIgnoreDesktopAnno"), automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldInOldZyBoard"), automation.IsAutoFoldInOldZyBoard);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchKeepFoldAfterSoftwareExit"), automation.KeepFoldAfterSoftwareExit);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillPptService"), automation.IsAutoKillPptService);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillEasiNote"), automation.IsAutoKillEasiNote);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillHiteAnnotation"), automation.IsAutoKillHiteAnnotation);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoEnterAnnotationAfterKillHite"), automation.IsAutoEnterAnnotationAfterKillHite);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillVComYouJiao"), automation.IsAutoKillVComYouJiao);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillSeewoLauncher2DesktopAnnotation"), automation.IsAutoKillSeewoLauncher2DesktopAnnotation);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillInkCanvas"), automation.IsAutoKillInkCanvas);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillICA"), automation.IsAutoKillICA);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoKillIDT"), automation.IsAutoKillIDT);
SetToggleSwitchState("ToggleSwitchAutoFoldInEasiNote", automation.IsAutoFoldInEasiNote);
SetToggleSwitchState("ToggleSwitchAutoFoldInEasiCamera", automation.IsAutoFoldInEasiCamera);
SetToggleSwitchState("ToggleSwitchAutoFoldInHiteTouchPro", automation.IsAutoFoldInHiteTouchPro);
SetToggleSwitchState("ToggleSwitchAutoFoldInEasiNote3", automation.IsAutoFoldInEasiNote3);
SetToggleSwitchState("ToggleSwitchAutoFoldInEasiNote3C", automation.IsAutoFoldInEasiNote3C);
SetToggleSwitchState("ToggleSwitchAutoFoldInEasiNote5C", automation.IsAutoFoldInEasiNote5C);
SetToggleSwitchState("ToggleSwitchAutoFoldInSeewoPincoTeacher", automation.IsAutoFoldInSeewoPincoTeacher);
SetToggleSwitchState("ToggleSwitchAutoFoldInHiteCamera", automation.IsAutoFoldInHiteCamera);
SetToggleSwitchState("ToggleSwitchAutoFoldInHiteLightBoard", automation.IsAutoFoldInHiteLightBoard);
SetToggleSwitchState("ToggleSwitchAutoFoldInWxBoardMain", automation.IsAutoFoldInWxBoardMain);
SetToggleSwitchState("ToggleSwitchAutoFoldInMSWhiteboard", automation.IsAutoFoldInMSWhiteboard);
SetToggleSwitchState("ToggleSwitchAutoFoldInAdmoxWhiteboard", automation.IsAutoFoldInAdmoxWhiteboard);
SetToggleSwitchState("ToggleSwitchAutoFoldInAdmoxBooth", automation.IsAutoFoldInAdmoxBooth);
SetToggleSwitchState("ToggleSwitchAutoFoldInQPoint", automation.IsAutoFoldInQPoint);
SetToggleSwitchState("ToggleSwitchAutoFoldInYiYunVisualPresenter", automation.IsAutoFoldInYiYunVisualPresenter);
SetToggleSwitchState("ToggleSwitchAutoFoldInMaxHubWhiteboard", automation.IsAutoFoldInMaxHubWhiteboard);
SetToggleSwitchState("ToggleSwitchAutoFoldInPPTSlideShow", automation.IsAutoFoldInPPTSlideShow);
SetToggleSwitchState("ToggleSwitchAutoFoldInEasiNoteIgnoreDesktopAnno", automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno);
SetToggleSwitchState("ToggleSwitchAutoFoldInOldZyBoard", automation.IsAutoFoldInOldZyBoard);
SetToggleSwitchState("ToggleSwitchKeepFoldAfterSoftwareExit", automation.KeepFoldAfterSoftwareExit);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"AutomationPanel 加载设置时出错: {ex.Message}");
}
_isLoaded = true;
}
/// <summary>
/// 查找ToggleSwitch控件
/// </summary>
private Border FindToggleSwitch(string name)
{
return this.FindDescendantByName(name) as Border;
}
/// <summary>
/// 设置 ToggleSwitch 状态
/// </summary>
private void SetToggleSwitchState(Border toggleSwitch, bool isOn)
private void SetToggleSwitchState(string name, bool isOn)
{
if (toggleSwitch == null) return;
toggleSwitch.Background = isOn
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
var innerBorder = toggleSwitch.Child as Border;
if (innerBorder != null)
try
{
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
var border = FindName(name) as System.Windows.Controls.Border;
if (border != null)
{
bool currentState = border.Background.ToString().Contains("3584e4");
if (currentState != isOn)
{
border.Background = isOn ? new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0x35, 0x84, 0xe4)) : new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0xe1, 0xe1, 0xe1));
var innerBorder = border.Child as System.Windows.Controls.Border;
if (innerBorder != null)
{
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
}
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"AutomationPanel 设置 ToggleSwitch {name} 状态时出错: {ex.Message}");
}
}
@@ -118,15 +104,12 @@ namespace Ink_Canvas.Windows.SettingsViews
{
if (!_isLoaded) return;
// 标记事件已处理,防止事件冒泡
e.Handled = true;
var border = sender as Border;
var border = sender as System.Windows.Controls.Border;
if (border == null) return;
bool isOn = border.Background.ToString() == "#FF3584E4";
bool newState = !isOn;
SetToggleSwitchState(border, newState);
bool currentState = border.Background.ToString().Contains("3584e4");
bool newState = !currentState;
SetToggleSwitchState(border.Name, newState);
// 通过 MainWindowSettingsHelper 调用 MainWindow 中的方法
string toggleSwitchName = border.Name;
@@ -177,6 +177,78 @@
</Border>
</StackPanel>
</Grid>
<Border Height="1" Background="#ebebeb"/>
<Grid Height="54">
<StackPanel Orientation="Vertical" Margin="18,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="绘制圆时显示圆心位置" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="绘制圆形时显示圆心标记" HorizontalAlignment="Left"/>
</StackPanel>
<Border x:Name="ToggleSwitchShowCircleCenter" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4" Tag="ShowCircleCenter" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
</Border>
</Border>
</Grid>
<Border Height="1" Background="#ebebeb"/>
<Grid Height="54">
<StackPanel Orientation="Vertical" Margin="18,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="使用WPF默认贝塞尔曲线平滑" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="使用WPF内置的曲线平滑算法" HorizontalAlignment="Left"/>
</StackPanel>
<Border x:Name="ToggleSwitchFitToCurve" Style="{StaticResource ToggleSwitchStyle}" Background="#e1e1e1" Tag="FitToCurve" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Left" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
</Border>
</Border>
</Grid>
<Border Height="1" Background="#ebebeb"/>
<Grid Height="54">
<StackPanel Orientation="Vertical" Margin="18,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="使用高级曲线平滑(推荐)" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="使用改进的贝塞尔曲线平滑算法,提供更好的绘制效果" HorizontalAlignment="Left"/>
</StackPanel>
<Border x:Name="ToggleSwitchAdvancedBezierSmoothing" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4" Tag="AdvancedBezierSmoothing" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
</Border>
</Border>
</Grid>
</StackPanel>
</Border>
<!-- 墨迹渐隐设置 -->
<Border Margin="0,25,0,0" BorderBrush="#e6e6e6" BorderThickness="1.25,1.25,1.25,4" CornerRadius="8">
<StackPanel Orientation="Vertical">
<Grid Height="54">
<StackPanel Orientation="Vertical" Margin="18,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="启用墨迹渐隐功能" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="开启后墨迹不会绘制到画布上,而是保持湿墨迹状态,根据设置的渐隐时间自动消失" HorizontalAlignment="Left"/>
</StackPanel>
<Border x:Name="ToggleSwitchEnableInkFade" Style="{StaticResource ToggleSwitchStyle}" Background="#e1e1e1" Tag="EnableInkFade" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Left" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
</Border>
</Border>
</Grid>
<Border Height="1" Background="#ebebeb"/>
<Grid Height="54" x:Name="InkFadeTimePanel" Visibility="Collapsed">
<StackPanel Orientation="Vertical" Margin="18,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="墨迹渐隐时间" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="设置墨迹从绘制到完全消失的时间" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0">
<Slider x:Name="InkFadeTimeSlider" Width="150" Minimum="1000" Maximum="10000" Value="3000" TickFrequency="1000" IsSnapToTickEnabled="True" ValueChanged="InkFadeTimeSlider_ValueChanged"/>
<TextBlock x:Name="InkFadeTimeText" Text="3000ms" VerticalAlignment="Center" FontSize="14" Margin="12,0,0,0" Foreground="#2e3436"/>
</StackPanel>
</Grid>
</StackPanel>
</Border>
@@ -108,6 +108,15 @@ namespace Ink_Canvas.Windows.SettingsViews
// 保留双曲线渐近线
SetOptionButtonState("HyperbolaAsymptote", (int)canvas.HyperbolaAsymptoteOption);
// 绘制圆时显示圆心位置
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchShowCircleCenter"), canvas.ShowCircleCenter);
// 使用WPF默认贝塞尔曲线平滑
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchFitToCurve"), canvas.FitToCurve && !canvas.UseAdvancedBezierSmoothing);
// 使用高级贝塞尔曲线平滑
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAdvancedBezierSmoothing"), canvas.UseAdvancedBezierSmoothing);
// 启用异步墨迹平滑
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchUseAsyncInkSmoothing"), canvas.UseAsyncInkSmoothing);
@@ -123,6 +132,17 @@ namespace Ink_Canvas.Windows.SettingsViews
// 启用直线端点吸附
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchLineEndpointSnapping"), canvas.LineEndpointSnapping);
// 启用墨迹渐隐功能
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableInkFade"), canvas.EnableInkFade);
if (InkFadeTimePanel != null)
{
InkFadeTimePanel.Visibility = canvas.EnableInkFade ? Visibility.Visible : Visibility.Collapsed;
}
if (InkFadeTimeSlider != null)
{
InkFadeTimeSlider.Value = canvas.InkFadeTime;
}
// 定时自动保存墨迹
// 注意:这个设置可能在 Automation 或 Canvas 中,需要根据实际情况调整
// SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableAutoSaveStrokes"), ...);
@@ -164,7 +184,7 @@ namespace Ink_Canvas.Windows.SettingsViews
if (toggleSwitch == null) return;
toggleSwitch.Background = isOn
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
var innerBorder = toggleSwitch.Child as Border;
if (innerBorder != null)
{
@@ -278,6 +298,33 @@ namespace Ink_Canvas.Windows.SettingsViews
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchCompressPicturesUploaded", newState);
break;
case "ShowCircleCenter":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchShowCircleCenter", newState);
break;
case "FitToCurve":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchFitToCurve", newState);
// 处理互斥逻辑
if (newState)
{
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAdvancedBezierSmoothing", false);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAdvancedBezierSmoothing"), false);
}
break;
case "AdvancedBezierSmoothing":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAdvancedBezierSmoothing", newState);
// 处理互斥逻辑
if (newState)
{
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchFitToCurve", false);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchFitToCurve"), false);
}
break;
case "UseAsyncInkSmoothing":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAsyncInkSmoothing", newState);
@@ -303,6 +350,16 @@ namespace Ink_Canvas.Windows.SettingsViews
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchLineEndpointSnapping", newState);
break;
case "EnableInkFade":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableInkFade", newState);
// 更新UI状态
if (InkFadeTimePanel != null)
{
InkFadeTimePanel.Visibility = newState ? Visibility.Visible : Visibility.Collapsed;
}
break;
case "EnableAutoSaveStrokes":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableAutoSaveStrokes", newState);
@@ -519,6 +576,17 @@ namespace Ink_Canvas.Windows.SettingsViews
/// <summary>
/// Slider值变化事件处理
/// </summary>
private void InkFadeTimeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
if (InkFadeTimeSlider != null && InkFadeTimeText != null)
{
double value = InkFadeTimeSlider.Value;
InkFadeTimeText.Text = $"{(int)value}ms";
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeSliderValueChanged("InkFadeTimeSlider", value);
}
}
/// <summary>
/// 应用主题
@@ -122,7 +122,7 @@ namespace Ink_Canvas.Windows.SettingsViews
if (toggleSwitch == null) return;
toggleSwitch.Background = isOn
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
var innerBorder = toggleSwitch.Child as Border;
if (innerBorder != null)
{
@@ -297,8 +297,8 @@ namespace Ink_Canvas.Windows.SettingsViews
MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{
if (MainWindow.Settings.Canvas != null)
{
MainWindow.Settings.Canvas.PalmEraserSensitivity = sensitivity;
{
MainWindow.Settings.Canvas.PalmEraserSensitivity = sensitivity;
}
}, "ComboBoxPalmEraserSensitivity");
}
@@ -125,7 +125,7 @@
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" TextWrapping="Wrap" Text="设置直线自动拉直的最小长度" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0">
<Slider x:Name="AutoStraightenLineThresholdSlider" Width="150" Minimum="30" Maximum="300" Value="80" TickFrequency="30" IsSnapToTickEnabled="True" ValueChanged="AutoStraightenLineThresholdSlider_ValueChanged"/>
<Slider x:Name="AutoStraightenLineThresholdSlider" Width="150" Minimum="30" Maximum="300" Value="80" TickFrequency="30" IsSnapToTickEnabled="True"/>
<TextBlock x:Name="AutoStraightenLineThresholdText" Text="80" VerticalAlignment="Center" FontSize="14" Margin="12,0,0,0" Foreground="#2e3436"/>
</StackPanel>
</Grid>
@@ -140,7 +140,7 @@
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" TextWrapping="Wrap" Text="越小要求越严格,越弯曲的线条越不容易被拉直;值越大越容易识别为直线" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0">
<Slider x:Name="LineStraightenSensitivitySlider" Width="150" Minimum="0.05" Maximum="2.0" Value="0.20" TickFrequency="0.05" IsSnapToTickEnabled="True" ValueChanged="LineStraightenSensitivitySlider_ValueChanged"/>
<Slider x:Name="LineStraightenSensitivitySlider" Width="150" Minimum="0.05" Maximum="2.0" Value="0.20" TickFrequency="0.05" IsSnapToTickEnabled="True"/>
<TextBlock x:Name="LineStraightenSensitivityText" Text="0.20" VerticalAlignment="Center" FontSize="14" Margin="12,0,0,0" Foreground="#2e3436"/>
</StackPanel>
</Grid>
@@ -183,7 +183,7 @@
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" TextWrapping="Wrap" Text="设置直线端点自动吸附的最大距离" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0">
<Slider x:Name="LineEndpointSnappingThresholdSlider" Width="150" Minimum="5" Maximum="50" Value="15" TickFrequency="5" IsSnapToTickEnabled="True" ValueChanged="LineEndpointSnappingThresholdSlider_ValueChanged"/>
<Slider x:Name="LineEndpointSnappingThresholdSlider" Width="150" Minimum="5" Maximum="50" Value="15" TickFrequency="5" IsSnapToTickEnabled="True"/>
<TextBlock x:Name="LineEndpointSnappingThresholdText" Text="15" VerticalAlignment="Center" FontSize="14" Margin="12,0,0,0" Foreground="#2e3436"/>
</StackPanel>
</Grid>
@@ -1,5 +1,3 @@
using Ink_Canvas;
using iNKORE.UI.WPF.Helpers;
using System;
using System.Windows;
using System.Windows.Controls;
@@ -11,104 +9,9 @@ namespace Ink_Canvas.Windows.SettingsViews
/// </summary>
public partial class InkRecognitionPanel : UserControl
{
private bool _isLoaded = false;
public InkRecognitionPanel()
{
InitializeComponent();
Loaded += InkRecognitionPanel_Loaded;
}
private void InkRecognitionPanel_Loaded(object sender, RoutedEventArgs e)
{
LoadSettings();
// 添加触摸支持
MainWindowSettingsHelper.EnableTouchSupportForControls(this);
// 应用主题
ApplyTheme();
_isLoaded = true;
}
/// <summary>
/// 加载设置
/// </summary>
public void LoadSettings()
{
if (MainWindow.Settings == null || MainWindow.Settings.Canvas == null || MainWindow.Settings.InkToShape == null) return;
_isLoaded = false;
try
{
var canvas = MainWindow.Settings.Canvas;
var inkToShape = MainWindow.Settings.InkToShape;
// 自动拉直线阈值
if (AutoStraightenLineThresholdSlider != null)
{
AutoStraightenLineThresholdSlider.Value = canvas.AutoStraightenLineThreshold;
if (AutoStraightenLineThresholdText != null)
{
AutoStraightenLineThresholdText.Text = ((int)canvas.AutoStraightenLineThreshold).ToString();
}
}
// 灵敏度
if (LineStraightenSensitivitySlider != null)
{
LineStraightenSensitivitySlider.Value = inkToShape.LineStraightenSensitivity;
if (LineStraightenSensitivityText != null)
{
LineStraightenSensitivityText.Text = inkToShape.LineStraightenSensitivity.ToString("F2");
}
}
// 高精度直线拉直
var toggleSwitchHighPrecisionLineStraighten = this.FindDescendantByName("ToggleSwitchHighPrecisionLineStraighten") as Border;
if (toggleSwitchHighPrecisionLineStraighten != null)
{
bool isOn = canvas.HighPrecisionLineStraighten;
toggleSwitchHighPrecisionLineStraighten.Background = isOn
? new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
var innerBorder = toggleSwitchHighPrecisionLineStraighten.Child as Border;
if (innerBorder != null)
{
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
}
}
// 直线端点吸附
var toggleSwitchLineEndpointSnapping = this.FindDescendantByName("ToggleSwitchLineEndpointSnapping") as Border;
if (toggleSwitchLineEndpointSnapping != null)
{
bool isOn = canvas.LineEndpointSnapping;
toggleSwitchLineEndpointSnapping.Background = isOn
? new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
var innerBorder = toggleSwitchLineEndpointSnapping.Child as Border;
if (innerBorder != null)
{
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
}
}
// 吸附距离
if (LineEndpointSnappingThresholdSlider != null)
{
LineEndpointSnappingThresholdSlider.Value = canvas.LineEndpointSnappingThreshold;
if (LineEndpointSnappingThresholdText != null)
{
LineEndpointSnappingThresholdText.Text = ((int)canvas.LineEndpointSnappingThreshold).ToString();
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"加载墨迹识别设置时出错: {ex.Message}");
}
_isLoaded = true;
}
public event EventHandler<RoutedEventArgs> IsTopBarNeedShadowEffect;
@@ -141,42 +44,6 @@ namespace Ink_Canvas.Windows.SettingsViews
System.Diagnostics.Debug.WriteLine($"InkRecognitionPanel 应用主题时出错: {ex.Message}");
}
}
/// <summary>
/// Slider值变化事件处理
/// </summary>
private void AutoStraightenLineThresholdSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
if (AutoStraightenLineThresholdSlider != null && AutoStraightenLineThresholdText != null)
{
double val = AutoStraightenLineThresholdSlider.Value;
AutoStraightenLineThresholdText.Text = ((int)val).ToString();
MainWindowSettingsHelper.InvokeSliderValueChanged("AutoStraightenLineThresholdSlider", val);
}
}
private void LineStraightenSensitivitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
if (LineStraightenSensitivitySlider != null && LineStraightenSensitivityText != null)
{
double val = LineStraightenSensitivitySlider.Value;
LineStraightenSensitivityText.Text = val.ToString("F2");
MainWindowSettingsHelper.InvokeSliderValueChanged("LineStraightenSensitivitySlider", val);
}
}
private void LineEndpointSnappingThresholdSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
if (LineEndpointSnappingThresholdSlider != null && LineEndpointSnappingThresholdText != null)
{
double val = LineEndpointSnappingThresholdSlider.Value;
LineEndpointSnappingThresholdText.Text = ((int)val).ToString();
MainWindowSettingsHelper.InvokeSliderValueChanged("LineEndpointSnappingThresholdSlider", val);
}
}
}
}
@@ -169,7 +169,7 @@ namespace Ink_Canvas.Windows.SettingsViews
if (toggleSwitch == null) return;
toggleSwitch.Background = isOn
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
var innerBorder = toggleSwitch.Child as Border;
if (innerBorder != null)
{
@@ -199,8 +199,7 @@ namespace Ink_Canvas.Windows.SettingsViews
{
if (i == selectedIndex)
{
// 使用主题适配的选中背景颜色
button.Background = ThemeHelper.GetSelectedBackgroundBrush();
button.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
var textBlock = button.Child as TextBlock;
if (textBlock != null)
{
@@ -315,8 +314,8 @@ namespace Ink_Canvas.Windows.SettingsViews
}
}
// 设置当前按钮为选中状态,使用主题适配的选中背景颜色
border.Background = ThemeHelper.GetSelectedBackgroundBrush();
// 设置当前按钮为选中状态
border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
var currentTextBlock = border.Child as TextBlock;
if (currentTextBlock != null)
{
@@ -360,7 +359,7 @@ namespace Ink_Canvas.Windows.SettingsViews
// 如果找不到控件,直接更新设置
MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{
randSettings.ExternalCallerType = callerType;
randSettings.ExternalCallerType = callerType;
}, "ComboBoxExternalCallerType");
}
}
@@ -370,7 +369,7 @@ namespace Ink_Canvas.Windows.SettingsViews
// 背景选择逻辑 - 这个设置可能没有对应的方法,直接更新
MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{
randSettings.SelectedBackgroundIndex = 0; // 默认背景
randSettings.SelectedBackgroundIndex = 0; // 默认背景
}, "PickNameBackground");
break;
}
@@ -73,51 +73,9 @@ namespace Ink_Canvas.Windows.SettingsViews
}
}
}
else
{
// 如果找不到控件和属性,先更新设置
// 对于自动收纳相关的设置,直接更新 Settings 对象
if (toggleSwitchName.StartsWith("ToggleSwitchAutoFold") || toggleSwitchName == "ToggleSwitchKeepFoldAfterSoftwareExit")
{
UpdateAutoFoldSetting(toggleSwitchName, isOn);
// 对于需要调用 StartOrStoptimerCheckAutoFold 的设置
if (toggleSwitchName.StartsWith("ToggleSwitchAutoFold") &&
!toggleSwitchName.Contains("PPTSlideShow") &&
!toggleSwitchName.Contains("KeepFold") &&
!toggleSwitchName.Contains("IgnoreDesktopAnno"))
{
try
{
InvokeMainWindowMethod("StartOrStoptimerCheckAutoFold");
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"调用 StartOrStoptimerCheckAutoFold 失败: {ex.Message}");
}
}
// 通知新设置面板同步状态
NotifySettingsPanelsSyncState(toggleSwitchName);
return;
}
}
// 尝试触发事件(可能通过反射调用)
// 即使找不到控件,也尝试触发事件(可能通过反射调用)
var toggledMethodName = toggleSwitchName + "_Toggled";
var method = mainWindow.GetType().GetMethod(toggledMethodName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
if (method != null)
{
try
{
// 尝试直接调用方法
InvokeMainWindowMethod(toggledMethodName, null, new RoutedEventArgs());
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"调用 {toggledMethodName} 失败: {ex.Message}");
}
}
InvokeMainWindowMethod(toggledMethodName, null, new RoutedEventArgs());
// 通知新设置面板同步状态
NotifySettingsPanelsSyncState(toggleSwitchName);
@@ -148,61 +106,6 @@ namespace Ink_Canvas.Windows.SettingsViews
}
}
/// <summary>
/// 更新自动收纳相关的设置
/// </summary>
private static void UpdateAutoFoldSetting(string toggleSwitchName, bool isOn)
{
try
{
if (MainWindow.Settings?.Automation == null) return;
// 根据 ToggleSwitch 名称映射到对应的设置属性
var settingMap = new Dictionary<string, Action<bool>>
{
{ "ToggleSwitchAutoFoldInEasiNote", (val) => MainWindow.Settings.Automation.IsAutoFoldInEasiNote = val },
{ "ToggleSwitchAutoFoldInEasiCamera", (val) => MainWindow.Settings.Automation.IsAutoFoldInEasiCamera = val },
{ "ToggleSwitchAutoFoldInHiteTouchPro", (val) => MainWindow.Settings.Automation.IsAutoFoldInHiteTouchPro = val },
{ "ToggleSwitchAutoFoldInEasiNote3", (val) => MainWindow.Settings.Automation.IsAutoFoldInEasiNote3 = val },
{ "ToggleSwitchAutoFoldInEasiNote3C", (val) => MainWindow.Settings.Automation.IsAutoFoldInEasiNote3C = val },
{ "ToggleSwitchAutoFoldInEasiNote5C", (val) => MainWindow.Settings.Automation.IsAutoFoldInEasiNote5C = val },
{ "ToggleSwitchAutoFoldInSeewoPincoTeacher", (val) => MainWindow.Settings.Automation.IsAutoFoldInSeewoPincoTeacher = val },
{ "ToggleSwitchAutoFoldInHiteCamera", (val) => MainWindow.Settings.Automation.IsAutoFoldInHiteCamera = val },
{ "ToggleSwitchAutoFoldInHiteLightBoard", (val) => MainWindow.Settings.Automation.IsAutoFoldInHiteLightBoard = val },
{ "ToggleSwitchAutoFoldInWxBoardMain", (val) => MainWindow.Settings.Automation.IsAutoFoldInWxBoardMain = val },
{ "ToggleSwitchAutoFoldInMSWhiteboard", (val) => MainWindow.Settings.Automation.IsAutoFoldInMSWhiteboard = val },
{ "ToggleSwitchAutoFoldInAdmoxWhiteboard", (val) => MainWindow.Settings.Automation.IsAutoFoldInAdmoxWhiteboard = val },
{ "ToggleSwitchAutoFoldInAdmoxBooth", (val) => MainWindow.Settings.Automation.IsAutoFoldInAdmoxBooth = val },
{ "ToggleSwitchAutoFoldInQPoint", (val) => MainWindow.Settings.Automation.IsAutoFoldInQPoint = val },
{ "ToggleSwitchAutoFoldInYiYunVisualPresenter", (val) => MainWindow.Settings.Automation.IsAutoFoldInYiYunVisualPresenter = val },
{ "ToggleSwitchAutoFoldInMaxHubWhiteboard", (val) => MainWindow.Settings.Automation.IsAutoFoldInMaxHubWhiteboard = val },
{ "ToggleSwitchAutoFoldInPPTSlideShow", (val) => MainWindow.Settings.Automation.IsAutoFoldInPPTSlideShow = val },
{ "ToggleSwitchAutoFoldInEasiNoteIgnoreDesktopAnno", (val) => MainWindow.Settings.Automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno = val },
{ "ToggleSwitchAutoFoldInOldZyBoard", (val) => MainWindow.Settings.Automation.IsAutoFoldInOldZyBoard = val },
{ "ToggleSwitchKeepFoldAfterSoftwareExit", (val) => MainWindow.Settings.Automation.KeepFoldAfterSoftwareExit = val }
};
if (settingMap.ContainsKey(toggleSwitchName))
{
settingMap[toggleSwitchName](isOn);
MainWindow.SaveSettingsToFile();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"更新自动收纳设置失败: {ex.Message}");
}
}
/// <summary>
/// ToggleSwitch 包装类,用于在找不到实际控件时模拟 ToggleSwitch
/// </summary>
private class ToggleSwitchWrapper
{
public bool IsOn { get; set; }
public string Name { get; set; }
}
/// <summary>
/// 调用 MainWindow 中的 ComboBox 事件处理方法
/// </summary>
@@ -169,12 +169,12 @@
</Border>
</Grid>
<StackPanel x:Name="PPTButtonSettingsPanel" Margin="0,12,0,0" Visibility="Visible">
<WrapPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,0,12">
<CheckBox x:Name="CheckboxEnableLBPPTButton" IsChecked="True" Content="左下" Margin="0,0,16,8" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
<CheckBox x:Name="CheckboxEnableRBPPTButton" IsChecked="True" Content="右下" Margin="0,0,16,8" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
<CheckBox x:Name="CheckboxEnableLSPPTButton" IsChecked="True" Content="左侧" Margin="0,0,16,8" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
<CheckBox x:Name="CheckboxEnableRSPPTButton" IsChecked="True" Content="右侧" Margin="0,0,0,8" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
</WrapPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,0,12">
<CheckBox x:Name="CheckboxEnableLBPPTButton" IsChecked="True" Content="左下" Margin="0,0,16,0" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
<CheckBox x:Name="CheckboxEnableRBPPTButton" IsChecked="True" Content="右下" Margin="0,0,16,0" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
<CheckBox x:Name="CheckboxEnableLSPPTButton" IsChecked="True" Content="左侧" Margin="0,0,16,0" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
<CheckBox x:Name="CheckboxEnableRSPPTButton" IsChecked="True" Content="右侧" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
</StackPanel>
<Grid Height="54">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
@@ -182,7 +182,7 @@
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Column="0">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="左侧偏移" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" TextWrapping="Wrap" Text="调大往上偏移,调小往下偏移,修改为0为不偏移,居中放置" HorizontalAlignment="Left" MaxWidth="450"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="调大往上偏移,调小往下偏移,修改为0为不偏移,居中放置" HorizontalAlignment="Left"/>
</StackPanel>
<Grid Grid.Column="1" VerticalAlignment="Center" Margin="0,0,15,0">
<Grid.ColumnDefinitions>
@@ -201,7 +201,7 @@
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Column="0">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="右侧偏移" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" TextWrapping="Wrap" Text="调大往右偏移,调小往左偏移,修改为0为不偏移,居中放置" HorizontalAlignment="Left" MaxWidth="450"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="调大往右偏移,调小往左偏移,修改为0为不偏移,居中放置" HorizontalAlignment="Left"/>
</StackPanel>
<Grid Grid.Column="1" VerticalAlignment="Center" Margin="0,0,15,0">
<Grid.ColumnDefinitions>
@@ -252,11 +252,11 @@
</Grid>
<Border Height="1" Background="#ebebeb" Margin="0,8,0,8"/>
<TextBlock Text="两侧按钮设置" FontWeight="Bold" Foreground="#2e3436" FontSize="16" Margin="0,0,0,8"/>
<WrapPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,0,8">
<CheckBox x:Name="CheckboxSPPTDisplayPage" IsChecked="True" Content="显示页码" Margin="0,0,16,8" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
<CheckBox x:Name="CheckboxSPPTHalfOpacity" IsChecked="True" Content="半透明" Margin="0,0,16,8" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
<CheckBox x:Name="CheckboxSPPTBlackBackground" IsChecked="True" Content="黑色背景" Margin="0,0,0,8" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
</WrapPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,0,8">
<CheckBox x:Name="CheckboxSPPTDisplayPage" IsChecked="True" Content="显示页码" Margin="0,0,16,0" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
<CheckBox x:Name="CheckboxSPPTHalfOpacity" IsChecked="True" Content="半透明" Margin="0,0,16,0" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
<CheckBox x:Name="CheckboxSPPTBlackBackground" IsChecked="True" Content="黑色背景" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
</StackPanel>
<StackPanel x:Name="PPTLSButtonOpacityPanel" Margin="0,8,0,8" Visibility="Visible">
<Grid Height="54">
<Grid.ColumnDefinitions>
@@ -299,11 +299,11 @@
</StackPanel>
<Border Height="1" Background="#ebebeb" Margin="0,8,0,8"/>
<TextBlock Text="左下右下按钮设置" FontWeight="Bold" Foreground="#2e3436" FontSize="16" Margin="0,0,0,8"/>
<WrapPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,0,8">
<CheckBox x:Name="CheckboxBPPTDisplayPage" IsChecked="True" Content="显示页码" Margin="0,0,16,8" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
<CheckBox x:Name="CheckboxBPPTHalfOpacity" IsChecked="True" Content="半透明" Margin="0,0,16,8" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
<CheckBox x:Name="CheckboxBPPTBlackBackground" IsChecked="True" Content="黑色背景" Margin="0,0,0,8" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
</WrapPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,0,8">
<CheckBox x:Name="CheckboxBPPTDisplayPage" IsChecked="True" Content="显示页码" Margin="0,0,16,0" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
<CheckBox x:Name="CheckboxBPPTHalfOpacity" IsChecked="True" Content="半透明" Margin="0,0,16,0" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
<CheckBox x:Name="CheckboxBPPTBlackBackground" IsChecked="True" Content="黑色背景" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged"/>
</StackPanel>
<StackPanel x:Name="PPTLBButtonOpacityPanel" Margin="0,8,0,8" Visibility="Visible">
<Grid Height="54">
<Grid.ColumnDefinitions>
@@ -261,7 +261,7 @@ namespace Ink_Canvas.Windows.SettingsViews
if (toggleSwitch == null) return;
toggleSwitch.Background = isOn
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
var innerBorder = toggleSwitch.Child as Border;
if (innerBorder != null)
{
@@ -497,7 +497,7 @@ namespace Ink_Canvas.Windows.SettingsViews
}
MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{
pptSettings.PPTTimeCapsulePosition = position;
pptSettings.PPTTimeCapsulePosition = position;
}, "PPTTimeCapsulePosition");
break;
}
@@ -182,7 +182,7 @@ namespace Ink_Canvas.Windows.SettingsViews
if (toggleSwitch == null) return;
toggleSwitch.Background = isOn
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
var innerBorder = toggleSwitch.Child as Border;
if (innerBorder != null)
{
@@ -119,78 +119,6 @@
</StackPanel>
</Border>
<!-- 墨迹设置 -->
<Border Margin="0,25,0,0" BorderBrush="#e6e6e6" BorderThickness="1.25,1.25,1.25,4" CornerRadius="8">
<StackPanel Orientation="Vertical">
<Grid Height="54">
<StackPanel Orientation="Vertical" Margin="18,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="绘制圆时显示圆心位置" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="绘制圆形时显示圆心标记" HorizontalAlignment="Left"/>
</StackPanel>
<Border x:Name="ToggleSwitchShowCircleCenter" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4" Tag="ShowCircleCenter" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center" IsHitTestVisible="False">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
</Border>
</Border>
</Grid>
<Border Height="1" Background="#ebebeb"/>
<Grid Height="54">
<StackPanel Orientation="Vertical" Margin="18,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="使用WPF默认贝塞尔曲线平滑" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="使用WPF内置的曲线平滑算法" HorizontalAlignment="Left"/>
</StackPanel>
<Border x:Name="ToggleSwitchFitToCurve" Style="{StaticResource ToggleSwitchStyle}" Background="#e1e1e1" Tag="FitToCurve" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Left" VerticalAlignment="Center" IsHitTestVisible="False">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
</Border>
</Border>
</Grid>
<Border Height="1" Background="#ebebeb"/>
<Grid Height="54">
<StackPanel Orientation="Vertical" Margin="18,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="使用高级曲线平滑(推荐)" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="使用改进的贝塞尔曲线平滑算法,提供更好的绘制效果" HorizontalAlignment="Left"/>
</StackPanel>
<Border x:Name="ToggleSwitchAdvancedBezierSmoothing" Style="{StaticResource ToggleSwitchStyle}" Background="#3584e4" Tag="AdvancedBezierSmoothing" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Right" VerticalAlignment="Center" IsHitTestVisible="False">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
</Border>
</Border>
</Grid>
<Border Height="1" Background="#ebebeb"/>
<Grid Height="54">
<StackPanel Orientation="Vertical" Margin="18,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="启用墨迹渐隐功能" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="开启后墨迹不会绘制到画布上,而是保持湿墨迹状态,根据设置的渐隐时间自动消失" HorizontalAlignment="Left"/>
</StackPanel>
<Border x:Name="ToggleSwitchEnableInkFade" Style="{StaticResource ToggleSwitchStyle}" Background="#e1e1e1" Tag="EnableInkFade" MouseLeftButtonDown="ToggleSwitch_Click">
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Left" VerticalAlignment="Center" IsHitTestVisible="False">
<Border.Effect>
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
</Border.Effect>
</Border>
</Border>
</Grid>
<Border Height="1" Background="#ebebeb"/>
<Grid Height="54" x:Name="InkFadeTimePanel" Visibility="Collapsed">
<StackPanel Orientation="Vertical" Margin="18,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="墨迹渐隐时间" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="设置墨迹从绘制到完全消失的时间" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0">
<Slider x:Name="InkFadeTimeSlider" Width="150" Minimum="1000" Maximum="10000" Value="3000" TickFrequency="1000" IsSnapToTickEnabled="True" ValueChanged="InkFadeTimeSlider_ValueChanged"/>
<TextBlock x:Name="InkFadeTimeText" Text="3000ms" VerticalAlignment="Center" FontSize="14" Margin="12,0,0,0" Foreground="#2e3436"/>
</StackPanel>
</Grid>
</StackPanel>
</Border>
<!-- 自动清理设置 -->
<Border Margin="0,25,0,0" BorderBrush="#e6e6e6" BorderThickness="1.25,1.25,1.25,4" CornerRadius="8">
<StackPanel Orientation="Vertical" Margin="18,18,18,18">
@@ -135,36 +135,6 @@ namespace Ink_Canvas.Windows.SettingsViews
{
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoSaveScreenShotInPowerPoint"), MainWindow.Settings.PowerPointSettings.IsAutoSaveScreenShotInPowerPoint);
}
// 墨迹设置
if (MainWindow.Settings.Canvas != null)
{
var canvas = MainWindow.Settings.Canvas;
// 绘制圆时显示圆心位置
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchShowCircleCenter"), canvas.ShowCircleCenter);
// 使用WPF默认贝塞尔曲线平滑
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchFitToCurve"), canvas.FitToCurve && !canvas.UseAdvancedBezierSmoothing);
// 使用高级贝塞尔曲线平滑
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAdvancedBezierSmoothing"), canvas.UseAdvancedBezierSmoothing);
// 启用墨迹渐隐功能
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableInkFade"), canvas.EnableInkFade);
if (InkFadeTimePanel != null)
{
InkFadeTimePanel.Visibility = canvas.EnableInkFade ? Visibility.Visible : Visibility.Collapsed;
}
if (InkFadeTimeSlider != null)
{
InkFadeTimeSlider.Value = canvas.InkFadeTime;
if (InkFadeTimeText != null)
{
InkFadeTimeText.Text = $"{canvas.InkFadeTime}ms";
}
}
}
}
catch (Exception ex)
{
@@ -190,7 +160,7 @@ namespace Ink_Canvas.Windows.SettingsViews
if (toggleSwitch == null) return;
toggleSwitch.Background = isOn
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
var innerBorder = toggleSwitch.Child as Border;
if (innerBorder != null)
{
@@ -246,43 +216,6 @@ namespace Ink_Canvas.Windows.SettingsViews
AutoDelIntervalPanel.Visibility = newState ? Visibility.Visible : Visibility.Collapsed;
}
break;
case "ShowCircleCenter":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchShowCircleCenter", newState);
break;
case "FitToCurve":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchFitToCurve", newState);
// 处理互斥逻辑
if (newState)
{
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAdvancedBezierSmoothing", false);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAdvancedBezierSmoothing"), false);
}
break;
case "AdvancedBezierSmoothing":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAdvancedBezierSmoothing", newState);
// 处理互斥逻辑
if (newState)
{
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchFitToCurve", false);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchFitToCurve"), false);
}
break;
case "EnableInkFade":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableInkFade", newState);
// 更新UI状态
if (InkFadeTimePanel != null)
{
InkFadeTimePanel.Visibility = newState ? Visibility.Visible : Visibility.Collapsed;
}
break;
}
}
@@ -326,10 +259,10 @@ namespace Ink_Canvas.Windows.SettingsViews
{
var mainWindow = Application.Current.MainWindow as MainWindow;
if (mainWindow != null)
{
{
var textBox = mainWindow.FindName("AutoSavedStrokesLocation") as System.Windows.Controls.TextBox;
if (textBox != null)
{
{
AutoSavedStrokesLocation.Text = textBox.Text;
}
}
@@ -370,21 +303,6 @@ namespace Ink_Canvas.Windows.SettingsViews
}
}
/// <summary>
/// 墨迹渐隐时间滑块值变化事件处理
/// </summary>
private void InkFadeTimeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
if (InkFadeTimeSlider != null && InkFadeTimeText != null)
{
int value = (int)InkFadeTimeSlider.Value;
InkFadeTimeText.Text = $"{value}ms";
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeSliderValueChanged("InkFadeTimeSlider", value);
}
}
/// <summary>
/// ComboBox选择变化事件处理
/// </summary>
@@ -419,17 +337,17 @@ namespace Ink_Canvas.Windows.SettingsViews
else
{
// 如果找不到控件,直接更新设置
string tag = selectedItem.Tag?.ToString();
if (!string.IsNullOrEmpty(tag) && tag.StartsWith("AutoDelSavedFilesDaysThreshold_"))
{
string daysStr = tag.Replace("AutoDelSavedFilesDaysThreshold_", "");
if (int.TryParse(daysStr, out int days))
string tag = selectedItem.Tag?.ToString();
if (!string.IsNullOrEmpty(tag) && tag.StartsWith("AutoDelSavedFilesDaysThreshold_"))
{
string daysStr = tag.Replace("AutoDelSavedFilesDaysThreshold_", "");
if (int.TryParse(daysStr, out int days))
{
MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{
if (MainWindow.Settings.Automation != null)
{
MainWindow.Settings.Automation.AutoDelSavedFilesDaysThreshold = days;
{
if (MainWindow.Settings.Automation != null)
{
MainWindow.Settings.Automation.AutoDelSavedFilesDaysThreshold = days;
}
}, "ComboBoxAutoDelSavedFilesDaysThreshold");
}
@@ -447,43 +365,12 @@ namespace Ink_Canvas.Windows.SettingsViews
try
{
ThemeHelper.ApplyThemeToControl(this);
// 为所有 ComboBox 添加 DropDownOpened 事件处理,以便在下拉菜单打开时更新颜色
UpdateComboBoxDropdownTheme(ComboBoxAutoDelSavedFilesDaysThreshold);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"SnapshotPanel 应用主题时出错: {ex.Message}");
}
}
/// <summary>
/// 为 ComboBox 添加下拉菜单主题更新
/// </summary>
private void UpdateComboBoxDropdownTheme(System.Windows.Controls.ComboBox comboBox)
{
if (comboBox == null) return;
// 移除旧的事件处理(如果存在)
comboBox.DropDownOpened -= ComboBox_DropDownOpened;
// 添加新的事件处理
comboBox.DropDownOpened += ComboBox_DropDownOpened;
}
/// <summary>
/// ComboBox 下拉菜单打开事件处理
/// </summary>
private void ComboBox_DropDownOpened(object sender, EventArgs e)
{
if (sender is System.Windows.Controls.ComboBox comboBox)
{
// 延迟更新,确保 Popup 已经完全创建
Dispatcher.BeginInvoke(new Action(() =>
{
ThemeHelper.UpdateComboBoxDropdownColors(comboBox);
}), System.Windows.Threading.DispatcherPriority.Loaded);
}
}
}
}
@@ -218,9 +218,7 @@ namespace Ink_Canvas.Windows.SettingsViews
private void SetToggleSwitchState(Border toggleSwitch, bool isOn)
{
if (toggleSwitch == null) return;
toggleSwitch.Background = isOn
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
toggleSwitch.Background = isOn ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var innerBorder = toggleSwitch.Child as Border;
if (innerBorder != null)
{
@@ -511,44 +509,12 @@ namespace Ink_Canvas.Windows.SettingsViews
// 使用 ThemeHelper 递归更新其他元素
ThemeHelper.ApplyThemeToControl(this);
// 为所有 ComboBox 添加 DropDownOpened 事件处理,以便在下拉菜单打开时更新颜色
UpdateComboBoxDropdownTheme(AutoUpdateWithSilenceStartTimeComboBox);
UpdateComboBoxDropdownTheme(AutoUpdateWithSilenceEndTimeComboBox);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"StartupPanel 应用主题时出错: {ex.Message}");
}
}
/// <summary>
/// 为 ComboBox 添加下拉菜单主题更新
/// </summary>
private void UpdateComboBoxDropdownTheme(System.Windows.Controls.ComboBox comboBox)
{
if (comboBox == null) return;
// 移除旧的事件处理(如果存在)
comboBox.DropDownOpened -= ComboBox_DropDownOpened;
// 添加新的事件处理
comboBox.DropDownOpened += ComboBox_DropDownOpened;
}
/// <summary>
/// ComboBox 下拉菜单打开事件处理
/// </summary>
private void ComboBox_DropDownOpened(object sender, EventArgs e)
{
if (sender is System.Windows.Controls.ComboBox comboBox)
{
// 延迟更新,确保 Popup 已经完全创建
Dispatcher.BeginInvoke(new Action(() =>
{
ThemeHelper.UpdateComboBoxDropdownColors(comboBox);
}), System.Windows.Threading.DispatcherPriority.Loaded);
}
}
}
}
@@ -1,5 +1,3 @@
using System;
using System.Windows;
using System.Windows.Media;
using Ink_Canvas;
@@ -278,28 +276,6 @@ namespace Ink_Canvas.Windows.SettingsViews
comboBox.Foreground = GetTextPrimaryBrush();
}
}
// 更新 ComboBox 背景色
var background = comboBox.Background as SolidColorBrush;
if (background != null)
{
var color = background.Color;
if (color.R == 255 && color.G == 255 && color.B == 255) // 白色背景
{
comboBox.Background = GetTextBoxBackgroundBrush();
}
}
// 更新 ComboBox 边框颜色
var borderBrush = comboBox.BorderBrush as SolidColorBrush;
if (borderBrush != null)
{
var color = borderBrush.Color;
if (color.R == 230 && color.G == 230 && color.B == 230) // #e6e6e6
{
comboBox.BorderBrush = GetBorderPrimaryBrush();
}
}
// 更新 ComboBoxItem 颜色
UpdateComboBoxItemColors(comboBox);
}
UpdateInputControlsColors(child);
}
@@ -477,396 +453,6 @@ namespace Ink_Canvas.Windows.SettingsViews
};
}
/// <summary>
/// 更新 ComboBoxItem 的颜色
/// </summary>
private static void UpdateComboBoxItemColors(System.Windows.Controls.ComboBox comboBox)
{
try
{
// 更新下拉菜单中的 ComboBoxItem
if (comboBox.Items.Count > 0)
{
foreach (var item in comboBox.Items)
{
if (item is System.Windows.Controls.ComboBoxItem comboBoxItem)
{
var foreground = comboBoxItem.Foreground as SolidColorBrush;
if (foreground != null)
{
var color = foreground.Color;
if (color.R == 46 && color.G == 52 && color.B == 54) // #2e3436
{
comboBoxItem.Foreground = GetTextPrimaryBrush();
}
}
var background = comboBoxItem.Background as SolidColorBrush;
if (background != null)
{
var color = background.Color;
if (color.R == 255 && color.G == 255 && color.B == 255) // 白色背景
{
comboBoxItem.Background = GetTextBoxBackgroundBrush();
}
}
}
}
}
}
catch
{
// 忽略错误
}
}
/// <summary>
/// 更新 ComboBox 下拉菜单的颜色(在 ComboBox 打开时调用)
/// </summary>
public static void UpdateComboBoxDropdownColors(System.Windows.Controls.ComboBox comboBox)
{
try
{
if (comboBox == null || !comboBox.IsDropDownOpen) return;
// 通过 VisualTreeHelper 查找 Popup
System.Windows.Controls.Primitives.Popup popup = null;
for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(comboBox); i++)
{
var child = System.Windows.Media.VisualTreeHelper.GetChild(comboBox, i);
if (child is System.Windows.Controls.Primitives.Popup foundPopup)
{
popup = foundPopup;
break;
}
// 递归查找
popup = FindPopupInVisualTree(child);
if (popup != null) break;
}
if (popup == null)
{
// 如果找不到,尝试通过模板查找
if (comboBox.Template != null)
{
popup = comboBox.Template.FindName("Popup", comboBox) as System.Windows.Controls.Primitives.Popup;
}
}
if (popup != null && popup.Child is System.Windows.Controls.Border popupBorder)
{
// 更新下拉菜单背景色
var background = popupBorder.Background as SolidColorBrush;
if (background != null)
{
var color = background.Color;
if (color.R == 255 && color.G == 255 && color.B == 255) // 白色背景
{
popupBorder.Background = GetTextBoxBackgroundBrush();
}
}
// 更新下拉菜单边框颜色
var borderBrush = popupBorder.BorderBrush as SolidColorBrush;
if (borderBrush != null)
{
var color = borderBrush.Color;
if (color.R == 230 && color.G == 230 && color.B == 230) // #e6e6e6
{
popupBorder.BorderBrush = GetBorderPrimaryBrush();
}
}
// 更新下拉菜单中的 ComboBoxItem
UpdateComboBoxItemColorsInPopup(popupBorder);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"更新 ComboBox 下拉菜单颜色时出错: {ex.Message}");
}
}
/// <summary>
/// 在可视化树中查找 Popup
/// </summary>
private static System.Windows.Controls.Primitives.Popup FindPopupInVisualTree(System.Windows.DependencyObject parent)
{
if (parent == null) return null;
if (parent is System.Windows.Controls.Primitives.Popup popup)
{
return popup;
}
for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(parent); i++)
{
var child = System.Windows.Media.VisualTreeHelper.GetChild(parent, i);
var found = FindPopupInVisualTree(child);
if (found != null) return found;
}
return null;
}
/// <summary>
/// 更新 ComboBox 下拉菜单的背景色(通过 Popup)
/// </summary>
public static void UpdateComboBoxPopupColors(System.Windows.DependencyObject parent)
{
for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(parent); i++)
{
var child = System.Windows.Media.VisualTreeHelper.GetChild(parent, i);
if (child is System.Windows.Controls.Primitives.Popup popup)
{
// 查找 Popup 中的 Border(下拉菜单容器)
if (popup.Child is System.Windows.Controls.Border popupBorder)
{
var background = popupBorder.Background as SolidColorBrush;
if (background != null)
{
var color = background.Color;
if (color.R == 255 && color.G == 255 && color.B == 255) // 白色背景
{
popupBorder.Background = GetTextBoxBackgroundBrush();
}
}
var borderBrush = popupBorder.BorderBrush as SolidColorBrush;
if (borderBrush != null)
{
var color = borderBrush.Color;
if (color.R == 230 && color.G == 230 && color.B == 230) // #e6e6e6
{
popupBorder.BorderBrush = GetBorderPrimaryBrush();
}
}
// 递归更新 Popup 内部的 ComboBoxItem
UpdateComboBoxItemColorsInPopup(popupBorder);
}
}
UpdateComboBoxPopupColors(child);
}
}
/// <summary>
/// 更新 Popup 内部的 ComboBoxItem 颜色
/// </summary>
private static void UpdateComboBoxItemColorsInPopup(System.Windows.DependencyObject parent)
{
for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(parent); i++)
{
var child = System.Windows.Media.VisualTreeHelper.GetChild(parent, i);
if (child is System.Windows.Controls.ComboBoxItem comboBoxItem)
{
var foreground = comboBoxItem.Foreground as SolidColorBrush;
if (foreground != null)
{
var color = foreground.Color;
if (color.R == 46 && color.G == 52 && color.B == 54) // #2e3436
{
comboBoxItem.Foreground = GetTextPrimaryBrush();
}
}
// 更新默认背景
var background = comboBoxItem.Background as SolidColorBrush;
if (background != null)
{
var color = background.Color;
if (color.R == 255 && color.G == 255 && color.B == 255) // 白色背景
{
comboBoxItem.Background = GetTextBoxBackgroundBrush();
}
}
// 更新样式触发器中的颜色
UpdateComboBoxItemStyleTriggers(comboBoxItem);
// 更新模板中的 Border 背景色
UpdateComboBoxItemTemplateBorder(comboBoxItem);
// 为 ComboBoxItem 添加状态变化监听
AttachComboBoxItemStateHandlers(comboBoxItem);
}
UpdateComboBoxItemColorsInPopup(child);
}
}
/// <summary>
/// 更新 ComboBoxItem 模板中的 Border 背景色
/// </summary>
private static void UpdateComboBoxItemTemplateBorder(System.Windows.Controls.ComboBoxItem comboBoxItem)
{
try
{
if (comboBoxItem.Template == null) return;
// 查找模板中的 Border
var border = comboBoxItem.Template.FindName("Border", comboBoxItem) as System.Windows.Controls.Border;
if (border != null)
{
var background = border.Background as SolidColorBrush;
if (background != null)
{
var color = background.Color;
// 根据当前状态更新背景色
if (comboBoxItem.IsSelected)
{
border.Background = GetSelectedBackgroundBrush();
}
else if (comboBoxItem.IsMouseOver)
{
border.Background = GetHoverBackgroundBrush();
}
else if (color.R == 255 && color.G == 255 && color.B == 255) // 白色背景
{
border.Background = GetTextBoxBackgroundBrush();
}
else if (color.R == 245 && color.G == 245 && color.B == 245) // #f5f5f5 悬停背景
{
border.Background = GetHoverBackgroundBrush();
}
else if (color.R == 225 && color.G == 225 && color.B == 225) // #e1e1e1 选中背景
{
border.Background = GetSelectedBackgroundBrush();
}
}
}
}
catch
{
// 忽略错误
}
}
/// <summary>
/// 为 ComboBoxItem 添加状态变化监听
/// </summary>
private static void AttachComboBoxItemStateHandlers(System.Windows.Controls.ComboBoxItem comboBoxItem)
{
try
{
// 移除旧的事件处理(如果存在)
comboBoxItem.MouseEnter -= ComboBoxItem_MouseEnter;
comboBoxItem.MouseLeave -= ComboBoxItem_MouseLeave;
comboBoxItem.Selected -= ComboBoxItem_Selected;
comboBoxItem.Unselected -= ComboBoxItem_Unselected;
// 添加新的事件处理
comboBoxItem.MouseEnter += ComboBoxItem_MouseEnter;
comboBoxItem.MouseLeave += ComboBoxItem_MouseLeave;
comboBoxItem.Selected += ComboBoxItem_Selected;
comboBoxItem.Unselected += ComboBoxItem_Unselected;
}
catch
{
// 忽略错误
}
}
/// <summary>
/// ComboBoxItem 鼠标进入事件处理
/// </summary>
private static void ComboBoxItem_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
{
if (sender is System.Windows.Controls.ComboBoxItem comboBoxItem && !comboBoxItem.IsSelected)
{
var border = comboBoxItem.Template?.FindName("Border", comboBoxItem) as System.Windows.Controls.Border;
if (border != null)
{
border.Background = GetHoverBackgroundBrush();
}
}
}
/// <summary>
/// ComboBoxItem 鼠标离开事件处理
/// </summary>
private static void ComboBoxItem_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
{
if (sender is System.Windows.Controls.ComboBoxItem comboBoxItem && !comboBoxItem.IsSelected)
{
var border = comboBoxItem.Template?.FindName("Border", comboBoxItem) as System.Windows.Controls.Border;
if (border != null)
{
border.Background = GetTextBoxBackgroundBrush();
}
}
}
/// <summary>
/// ComboBoxItem 选中事件处理
/// </summary>
private static void ComboBoxItem_Selected(object sender, RoutedEventArgs e)
{
if (sender is System.Windows.Controls.ComboBoxItem comboBoxItem)
{
var border = comboBoxItem.Template?.FindName("Border", comboBoxItem) as System.Windows.Controls.Border;
if (border != null)
{
border.Background = GetSelectedBackgroundBrush();
}
}
}
/// <summary>
/// ComboBoxItem 取消选中事件处理
/// </summary>
private static void ComboBoxItem_Unselected(object sender, RoutedEventArgs e)
{
if (sender is System.Windows.Controls.ComboBoxItem comboBoxItem)
{
var border = comboBoxItem.Template?.FindName("Border", comboBoxItem) as System.Windows.Controls.Border;
if (border != null)
{
if (comboBoxItem.IsMouseOver)
{
border.Background = GetHoverBackgroundBrush();
}
else
{
border.Background = GetTextBoxBackgroundBrush();
}
}
}
}
/// <summary>
/// 更新 ComboBoxItem 样式触发器中的颜色
/// </summary>
private static void UpdateComboBoxItemStyleTriggers(System.Windows.Controls.ComboBoxItem comboBoxItem)
{
try
{
if (comboBoxItem.Style == null) return;
// 更新样式触发器中的颜色
foreach (var trigger in comboBoxItem.Style.Triggers)
{
if (trigger is System.Windows.Trigger baseTrigger)
{
foreach (var setter in baseTrigger.Setters)
{
if (setter is System.Windows.Setter setterBase)
{
// 更新悬停背景色
if (setterBase.Property == System.Windows.Controls.Control.BackgroundProperty &&
setterBase.Value is SolidColorBrush brush)
{
var color = brush.Color;
if (color.R == 245 && color.G == 245 && color.B == 245) // #f5f5f5 悬停背景
{
setterBase.Value = GetHoverBackgroundBrush();
}
else if (color.R == 225 && color.G == 225 && color.B == 225) // #e1e1e1 选中背景
{
setterBase.Value = GetSelectedBackgroundBrush();
}
}
}
}
}
}
}
catch
{
// 忽略错误
}
}
/// <summary>
/// 应用主题到整个控件树
/// </summary>
@@ -878,7 +464,6 @@ namespace Ink_Canvas.Windows.SettingsViews
UpdateInputControlsColors(control);
UpdateButtonColors(control);
UpdateImageIconColors(control);
UpdateComboBoxPopupColors(control);
}
}
}
@@ -230,7 +230,7 @@ namespace Ink_Canvas.Windows.SettingsViews
if (toggleSwitch == null) return;
toggleSwitch.Background = isOn
? new SolidColorBrush(Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
: new SolidColorBrush(Color.FromRgb(225, 225, 225));
var innerBorder = toggleSwitch.Child as Border;
if (innerBorder != null)
{
@@ -563,22 +563,22 @@ namespace Ink_Canvas.Windows.SettingsViews
if (comboBox != null)
{
// 根据 value 找到对应的 ComboBoxItem
int themeIndex;
switch (value)
{
case "Light":
themeIndex = 0;
break;
case "Dark":
themeIndex = 1;
break;
case "System":
themeIndex = 2;
break;
default:
themeIndex = 2;
break;
}
int themeIndex;
switch (value)
{
case "Light":
themeIndex = 0;
break;
case "Dark":
themeIndex = 1;
break;
case "System":
themeIndex = 2;
break;
default:
themeIndex = 2;
break;
}
if (comboBox.Items.Count > themeIndex)
{
@@ -586,7 +586,7 @@ namespace Ink_Canvas.Windows.SettingsViews
MainWindowSettingsHelper.InvokeComboBoxSelectionChangedWithThemeCheck("ComboBoxTheme", selectedItem);
}
else
{
{
// 如果找不到控件,直接更新设置并通知主题更新
MainWindowSettingsHelper.UpdateSettingSafely(() =>
{
@@ -622,9 +622,9 @@ namespace Ink_Canvas.Windows.SettingsViews
appearance.Theme = themeIndex;
}, "ComboBoxTheme_SelectionChanged", "ComboBoxTheme");
MainWindowSettingsHelper.NotifyThemeUpdateIfNeeded("ComboBoxTheme");
// 触发主题变化事件,通知设置窗口更新主题
ThemeChanged?.Invoke(this, new RoutedEventArgs());
// 触发主题变化事件,通知设置窗口更新主题
ThemeChanged?.Invoke(this, new RoutedEventArgs());
}
}
}
@@ -669,7 +669,7 @@ namespace Ink_Canvas.Windows.SettingsViews
// 如果找不到控件,直接更新设置
MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{
appearance.ChickenSoupSource = sourceIndex;
appearance.ChickenSoupSource = sourceIndex;
}, "ComboBoxChickenSoupSource");
}
}
@@ -704,7 +704,7 @@ namespace Ink_Canvas.Windows.SettingsViews
// 如果找不到控件,直接更新设置并通知主题更新
MainWindowSettingsHelper.UpdateSettingSafely(() =>
{
appearance.UnFoldButtonImageType = imgType;
appearance.UnFoldButtonImageType = imgType;
}, "ComboBoxUnFoldBtnImg_SelectionChanged", "ComboBoxUnFoldBtnImg");
MainWindowSettingsHelper.NotifyThemeUpdateIfNeeded("ComboBoxUnFoldBtnImg");
}
@@ -740,7 +740,7 @@ namespace Ink_Canvas.Windows.SettingsViews
// 如果找不到控件,直接更新设置
MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{
appearance.QuickColorPaletteDisplayMode = displayMode;
appearance.QuickColorPaletteDisplayMode = displayMode;
}, "ComboBoxQuickColorPaletteDisplayMode");
}
}
@@ -781,7 +781,7 @@ namespace Ink_Canvas.Windows.SettingsViews
// 如果找不到控件,直接更新设置
MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{
appearance.EraserDisplayOption = eraserOption;
appearance.EraserDisplayOption = eraserOption;
}, "ComboBoxEraserDisplayOption");
}
}
@@ -797,44 +797,12 @@ namespace Ink_Canvas.Windows.SettingsViews
try
{
ThemeHelper.ApplyThemeToControl(this);
// 为所有 ComboBox 添加 DropDownOpened 事件处理,以便在下拉菜单打开时更新颜色
UpdateComboBoxDropdownTheme(ComboBoxSplashScreenStyle);
UpdateComboBoxDropdownTheme(ComboBoxFloatingBarImg);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"ThemePanel 应用主题时出错: {ex.Message}");
}
}
/// <summary>
/// 为 ComboBox 添加下拉菜单主题更新
/// </summary>
private void UpdateComboBoxDropdownTheme(System.Windows.Controls.ComboBox comboBox)
{
if (comboBox == null) return;
// 移除旧的事件处理(如果存在)
comboBox.DropDownOpened -= ComboBox_DropDownOpened;
// 添加新的事件处理
comboBox.DropDownOpened += ComboBox_DropDownOpened;
}
/// <summary>
/// ComboBox 下拉菜单打开事件处理
/// </summary>
private void ComboBox_DropDownOpened(object sender, EventArgs e)
{
if (sender is System.Windows.Controls.ComboBox comboBox)
{
// 延迟更新,确保 Popup 已经完全创建
Dispatcher.BeginInvoke(new Action(() =>
{
ThemeHelper.UpdateComboBoxDropdownColors(comboBox);
}), System.Windows.Threading.DispatcherPriority.Loaded);
}
}
}
}
@@ -94,7 +94,7 @@
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="设置计时器提醒音的音量" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0">
<Slider x:Name="TimerVolumeSlider" Width="150" Minimum="0" Maximum="1" Value="1" TickFrequency="0.1" IsSnapToTickEnabled="True" ValueChanged="TimerVolumeSlider_ValueChanged"/>
<Slider x:Name="TimerVolumeSlider" Width="150" Minimum="0" Maximum="1" Value="1" TickFrequency="0.1" IsSnapToTickEnabled="True"/>
<TextBlock x:Name="TimerVolumeText" Text="100%" VerticalAlignment="Center" FontSize="14" Margin="12,0,0,0" Foreground="#2e3436" FontFamily="Consolas"/>
</StackPanel>
</Grid>
@@ -125,7 +125,7 @@
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="设置渐进提醒音的音量" HorizontalAlignment="Left"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0">
<Slider x:Name="ProgressiveReminderVolumeSlider" Width="150" Minimum="0" Maximum="1" Value="1" TickFrequency="0.1" IsSnapToTickEnabled="True" ValueChanged="ProgressiveReminderVolumeSlider_ValueChanged"/>
<Slider x:Name="ProgressiveReminderVolumeSlider" Width="150" Minimum="0" Maximum="1" Value="1" TickFrequency="0.1" IsSnapToTickEnabled="True"/>
<TextBlock x:Name="ProgressiveReminderVolumeText" Text="100%" VerticalAlignment="Center" FontSize="14" Margin="12,0,0,0" Foreground="#2e3436" FontFamily="Consolas"/>
</StackPanel>
</Grid>
@@ -1,5 +1,3 @@
using Ink_Canvas;
using iNKORE.UI.WPF.Helpers;
using System;
using System.Windows;
using System.Windows.Controls;
@@ -11,87 +9,9 @@ namespace Ink_Canvas.Windows.SettingsViews
/// </summary>
public partial class TimerPanel : UserControl
{
private bool _isLoaded = false;
public TimerPanel()
{
InitializeComponent();
Loaded += TimerPanel_Loaded;
}
private void TimerPanel_Loaded(object sender, RoutedEventArgs e)
{
LoadSettings();
// 添加触摸支持
MainWindowSettingsHelper.EnableTouchSupportForControls(this);
// 应用主题
ApplyTheme();
_isLoaded = true;
}
/// <summary>
/// 加载设置
/// </summary>
public void LoadSettings()
{
if (MainWindow.Settings == null || MainWindow.Settings.RandSettings == null) return;
_isLoaded = false;
try
{
var randSettings = MainWindow.Settings.RandSettings;
// 定时器音量
if (TimerVolumeSlider != null)
{
TimerVolumeSlider.Value = randSettings.TimerVolume;
if (TimerVolumeText != null)
{
TimerVolumeText.Text = (randSettings.TimerVolume * 100).ToString("F0") + "%";
}
}
// 渐进提醒
var toggleSwitchEnableProgressiveReminder = this.FindDescendantByName("ToggleSwitchEnableProgressiveReminder") as Border;
if (toggleSwitchEnableProgressiveReminder != null)
{
bool isOn = randSettings.EnableProgressiveReminder;
toggleSwitchEnableProgressiveReminder.Background = isOn
? new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(53, 132, 228))
: ThemeHelper.GetButtonBackgroundBrush();
var innerBorder = toggleSwitchEnableProgressiveReminder.Child as Border;
if (innerBorder != null)
{
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
}
}
// 渐进提醒音量面板可见性
var progressiveReminderVolumePanel = this.FindDescendantByName("ProgressiveReminderVolumePanel") as Grid;
if (progressiveReminderVolumePanel != null)
{
progressiveReminderVolumePanel.Visibility = randSettings.EnableProgressiveReminder
? Visibility.Visible
: Visibility.Collapsed;
}
// 渐进提醒音量
if (ProgressiveReminderVolumeSlider != null)
{
ProgressiveReminderVolumeSlider.Value = randSettings.ProgressiveReminderVolume;
if (ProgressiveReminderVolumeText != null)
{
ProgressiveReminderVolumeText.Text = (randSettings.ProgressiveReminderVolume * 100).ToString("F0") + "%";
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"加载定时器设置时出错: {ex.Message}");
}
_isLoaded = true;
}
public event EventHandler<RoutedEventArgs> IsTopBarNeedShadowEffect;
@@ -124,31 +44,6 @@ namespace Ink_Canvas.Windows.SettingsViews
System.Diagnostics.Debug.WriteLine($"TimerPanel 应用主题时出错: {ex.Message}");
}
}
/// <summary>
/// Slider值变化事件处理
/// </summary>
private void TimerVolumeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
if (TimerVolumeSlider != null && TimerVolumeText != null)
{
double val = TimerVolumeSlider.Value;
TimerVolumeText.Text = (val * 100).ToString("F0") + "%";
MainWindowSettingsHelper.InvokeSliderValueChanged("TimerVolumeSlider", val);
}
}
private void ProgressiveReminderVolumeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
if (ProgressiveReminderVolumeSlider != null && ProgressiveReminderVolumeText != null)
{
double val = ProgressiveReminderVolumeSlider.Value;
ProgressiveReminderVolumeText.Text = (val * 100).ToString("F0") + "%";
MainWindowSettingsHelper.InvokeSliderValueChanged("ProgressiveReminderVolumeSlider", val);
}
}
}
}
@@ -982,7 +982,7 @@ namespace Ink_Canvas.Windows
if (SnapshotPane != null) SnapshotPane.Visibility = _selectedSidebarItemName == "SnapshotItem" ? Visibility.Visible : Visibility.Collapsed;
if (AdvancedPane != null) AdvancedPane.Visibility = _selectedSidebarItemName == "AdvancedItem" ? Visibility.Visible : Visibility.Collapsed;
// 为新显示的面板加载设置并应用主题
// 为新显示的面板应用主题(延迟执行,确保面板已完全显示)
if (panelMappings.ContainsKey(_selectedSidebarItemName))
{
var selectedPanel = panelMappings[_selectedSidebarItemName];
@@ -992,15 +992,6 @@ namespace Ink_Canvas.Windows
{
try
{
// 先加载设置,确保显示的状态与实际一致
var loadSettingsMethod = selectedPanel.GetType().GetMethod("LoadSettings",
System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
if (loadSettingsMethod != null)
{
loadSettingsMethod.Invoke(selectedPanel, null);
}
// 然后应用主题
var applyThemeMethod = selectedPanel.GetType().GetMethod("ApplyTheme",
System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
if (applyThemeMethod != null)
@@ -1010,7 +1001,7 @@ namespace Ink_Canvas.Windows
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"切换面板时加载设置和应用主题到 {selectedPanel.GetType().Name} 时出错: {ex.Message}");
System.Diagnostics.Debug.WriteLine($"切换面板时应用主题到 {selectedPanel.GetType().Name} 时出错: {ex.Message}");
}
}), System.Windows.Threading.DispatcherPriority.Loaded);
}