From d73e87b980bb8aa1453a14fe46feda56db7773b3 Mon Sep 17 00:00:00 2001
From: PrefacedCorg <1876568293@qq.com>
Date: Tue, 14 Apr 2026 12:19:36 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Ink Canvas/MainWindow.xaml | 138 ++----------------
Ink Canvas/MainWindow.xaml.cs | 2 +-
Ink Canvas/MainWindow_cs/MW_AutoFold.cs | 2 +-
.../CircularColorButton.xaml.cs | 18 ++-
InkCanvas.Controls/QuickPanelButton.xaml | 25 ++++
InkCanvas.Controls/QuickPanelButton.xaml.cs | 80 ++++++++++
InkCanvas.Controls/ToolMenuButton.xaml.cs | 34 ++++-
7 files changed, 163 insertions(+), 136 deletions(-)
create mode 100644 InkCanvas.Controls/QuickPanelButton.xaml
create mode 100644 InkCanvas.Controls/QuickPanelButton.xaml.cs
diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml
index 31407aa9..7583daf9 100644
--- a/Ink Canvas/MainWindow.xaml
+++ b/Ink Canvas/MainWindow.xaml
@@ -8846,63 +8846,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -8929,73 +8879,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs
index 696efd02..e4591fcd 100644
--- a/Ink Canvas/MainWindow.xaml.cs
+++ b/Ink Canvas/MainWindow.xaml.cs
@@ -2884,7 +2884,7 @@ namespace Ink_Canvas
ShowPage(currentPageIndex);
}
// 快速面板退出PPT放映按钮事件
- private void ExitPPTSlideShow_MouseUp(object sender, MouseButtonEventArgs e)
+ private void ExitPPTSlideShow_MouseUp(object sender, RoutedEventArgs e)
{
// 直接调用PPT放映结束按钮的逻辑
BtnPPTSlideShowEnd_Click(BtnPPTSlideShowEnd, null);
diff --git a/Ink Canvas/MainWindow_cs/MW_AutoFold.cs b/Ink Canvas/MainWindow_cs/MW_AutoFold.cs
index a71eba9a..95fd7ec0 100644
--- a/Ink Canvas/MainWindow_cs/MW_AutoFold.cs
+++ b/Ink Canvas/MainWindow_cs/MW_AutoFold.cs
@@ -315,7 +315,7 @@ namespace Ink_Canvas
/// 1. 隐藏左侧快捷面板
/// 2. 隐藏右侧快捷面板
///
- private void HideQuickPanel_MouseUp(object sender, MouseButtonEventArgs e)
+ private void HideQuickPanel_MouseUp(object sender, RoutedEventArgs e)
{
HideLeftQuickPanel();
HideRightQuickPanel();
diff --git a/InkCanvas.Controls/CircularColorButton.xaml.cs b/InkCanvas.Controls/CircularColorButton.xaml.cs
index 12bfb7ad..8feefcea 100644
--- a/InkCanvas.Controls/CircularColorButton.xaml.cs
+++ b/InkCanvas.Controls/CircularColorButton.xaml.cs
@@ -66,7 +66,7 @@ namespace Ink_Canvas.Controls
private static void OnButtonSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var button = (CircularColorButton)d;
- if (button.ButtonBorder == null) return;
+ if (button.ButtonBorder == null || button.ColorOverlay == null) return;
var size = (double)e.NewValue;
button.ButtonBorder.Width = size;
@@ -74,11 +74,17 @@ namespace Ink_Canvas.Controls
var radius = (size - 3) / 2;
button.ColorOverlay.Width = radius * 2;
button.ColorOverlay.Height = radius * 2;
- button.ImageClipGeometry.RadiusX = radius;
- button.ImageClipGeometry.RadiusY = radius;
- button.ImageClipGeometry.Center = new Point(radius, radius);
- button.TransparentGridImage.Width = radius * 2;
- button.TransparentGridImage.Height = radius * 2;
+ if (button.ImageClipGeometry != null)
+ {
+ button.ImageClipGeometry.RadiusX = radius;
+ button.ImageClipGeometry.RadiusY = radius;
+ button.ImageClipGeometry.Center = new Point(radius, radius);
+ }
+ if (button.TransparentGridImage != null)
+ {
+ button.TransparentGridImage.Width = radius * 2;
+ button.TransparentGridImage.Height = radius * 2;
+ }
}
public double ButtonSize
diff --git a/InkCanvas.Controls/QuickPanelButton.xaml b/InkCanvas.Controls/QuickPanelButton.xaml
new file mode 100644
index 00000000..5971b4c7
--- /dev/null
+++ b/InkCanvas.Controls/QuickPanelButton.xaml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
diff --git a/InkCanvas.Controls/QuickPanelButton.xaml.cs b/InkCanvas.Controls/QuickPanelButton.xaml.cs
new file mode 100644
index 00000000..f4815f5e
--- /dev/null
+++ b/InkCanvas.Controls/QuickPanelButton.xaml.cs
@@ -0,0 +1,80 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace Ink_Canvas.Controls
+{
+ public partial class QuickPanelButton : UserControl
+ {
+ public static readonly DependencyProperty LabelProperty = DependencyProperty.Register(
+ nameof(Label), typeof(string), typeof(QuickPanelButton),
+ new PropertyMetadata(string.Empty, OnLabelChanged));
+
+ private static void OnLabelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var button = (QuickPanelButton)d;
+ if (button.LabelTextBlock != null)
+ {
+ var text = (string)e.NewValue;
+ button.LabelTextBlock.Text = text;
+ button.LabelTextBlock.Visibility = string.IsNullOrEmpty(text) ? Visibility.Collapsed : Visibility.Visible;
+ button.ButtonImage.Margin = string.IsNullOrEmpty(text)
+ ? new Thickness(0, 3, 0, 3)
+ : new Thickness(0, 3, 0, 0);
+ }
+ }
+
+ public string Label
+ {
+ get => (string)GetValue(LabelProperty);
+ set => SetValue(LabelProperty, value);
+ }
+
+ public static readonly DependencyProperty IconSourceProperty = DependencyProperty.Register(
+ nameof(IconSource), typeof(ImageSource), typeof(QuickPanelButton),
+ new PropertyMetadata(null, OnIconSourceChanged));
+
+ private static void OnIconSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var button = (QuickPanelButton)d;
+ if (button.ButtonImage != null)
+ button.ButtonImage.Source = (ImageSource)e.NewValue;
+ }
+
+ public ImageSource IconSource
+ {
+ get => (ImageSource)GetValue(IconSourceProperty);
+ set => SetValue(IconSourceProperty, value);
+ }
+
+ public static readonly DependencyProperty LabelFontSizeProperty = DependencyProperty.Register(
+ nameof(LabelFontSize), typeof(double), typeof(QuickPanelButton),
+ new PropertyMetadata(8.0, OnLabelFontSizeChanged));
+
+ private static void OnLabelFontSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var button = (QuickPanelButton)d;
+ if (button.LabelTextBlock != null)
+ button.LabelTextBlock.FontSize = (double)e.NewValue;
+ }
+
+ public double LabelFontSize
+ {
+ get => (double)GetValue(LabelFontSizeProperty);
+ set => SetValue(LabelFontSizeProperty, value);
+ }
+
+ public event RoutedEventHandler ButtonMouseUp;
+
+ public QuickPanelButton()
+ {
+ InitializeComponent();
+ }
+
+ private void ButtonPanel_MouseUp(object sender, MouseButtonEventArgs e)
+ {
+ ButtonMouseUp?.Invoke(this, new RoutedEventArgs(e.RoutedEvent, this));
+ }
+ }
+}
diff --git a/InkCanvas.Controls/ToolMenuButton.xaml.cs b/InkCanvas.Controls/ToolMenuButton.xaml.cs
index deb95d53..5d3f455b 100644
--- a/InkCanvas.Controls/ToolMenuButton.xaml.cs
+++ b/InkCanvas.Controls/ToolMenuButton.xaml.cs
@@ -7,6 +7,9 @@ namespace Ink_Canvas.Controls
{
public partial class ToolMenuButton : UserControl
{
+ private Geometry _pendingGeometry;
+ private Brush _pendingBrush;
+
public static readonly DependencyProperty LabelProperty = DependencyProperty.Register(
nameof(Label), typeof(string), typeof(ToolMenuButton),
new PropertyMetadata(string.Empty, OnLabelChanged));
@@ -31,9 +34,11 @@ namespace Ink_Canvas.Controls
private static void OnIconGeometryChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var button = (ToolMenuButton)d;
- if (e.NewValue is string geometry && !string.IsNullOrEmpty(geometry) && button.IconGeometryInternal != null)
+ if (e.NewValue is string geometry && !string.IsNullOrEmpty(geometry))
{
- button.IconGeometryInternal.Geometry = Geometry.Parse(geometry);
+ button._pendingGeometry = Geometry.Parse(geometry);
+ if (button.IconGeometryInternal != null)
+ button.IconGeometryInternal.Geometry = button._pendingGeometry;
}
}
@@ -50,8 +55,9 @@ namespace Ink_Canvas.Controls
private static void OnIconBrushChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var button = (ToolMenuButton)d;
+ button._pendingBrush = (Brush)e.NewValue;
if (button.IconGeometryInternal != null)
- button.IconGeometryInternal.Brush = (Brush)e.NewValue;
+ button.IconGeometryInternal.Brush = button._pendingBrush;
}
public Brush IconBrush
@@ -66,7 +72,15 @@ namespace Ink_Canvas.Controls
set => ButtonPanel.Background = value;
}
- public GeometryDrawing Icon => IconGeometryInternal;
+ public GeometryDrawing Icon
+ {
+ get
+ {
+ if (IconGeometryInternal != null)
+ return IconGeometryInternal;
+ return new GeometryDrawing(_pendingBrush, null, _pendingGeometry);
+ }
+ }
public event MouseButtonEventHandler ButtonMouseDown;
public event MouseEventHandler ButtonMouseLeave;
@@ -75,6 +89,18 @@ namespace Ink_Canvas.Controls
public ToolMenuButton()
{
InitializeComponent();
+ Loaded += ToolMenuButton_Loaded;
+ }
+
+ private void ToolMenuButton_Loaded(object sender, RoutedEventArgs e)
+ {
+ if (IconGeometryInternal != null)
+ {
+ if (_pendingGeometry != null)
+ IconGeometryInternal.Geometry = _pendingGeometry;
+ if (_pendingBrush != null)
+ IconGeometryInternal.Brush = _pendingBrush;
+ }
}
private void ButtonPanel_MouseDown(object sender, MouseButtonEventArgs e)