Files
community/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs
T

4000 lines
177 KiB
C#
Raw Normal View History

2025-08-31 11:43:52 +08:00
using Ink_Canvas.Helpers;
using iNKORE.UI.WPF.Modern;
2025-05-25 09:29:48 +08:00
using System;
2025-07-28 14:40:44 +08:00
using System.Diagnostics;
using System.Threading;
2025-05-25 09:29:48 +08:00
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
2025-07-28 14:40:44 +08:00
using System.Windows.Forms;
2025-05-25 09:29:48 +08:00
using System.Windows.Ink;
using System.Windows.Input;
2025-07-28 14:40:44 +08:00
using System.Windows.Interop;
2025-05-25 09:29:48 +08:00
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
2025-09-06 13:58:49 +08:00
using System.Windows.Threading;
2025-05-25 09:29:48 +08:00
using Application = System.Windows.Application;
2025-07-28 14:40:44 +08:00
using Button = System.Windows.Controls.Button;
2025-08-30 22:54:16 +08:00
using Cursors = System.Windows.Input.Cursors;
2025-07-28 14:40:44 +08:00
using HorizontalAlignment = System.Windows.HorizontalAlignment;
2025-07-21 12:15:56 +08:00
using Image = System.Windows.Controls.Image;
2025-06-29 13:01:33 +08:00
using MessageBox = iNKORE.UI.WPF.Modern.Controls.MessageBox;
2025-07-28 14:40:44 +08:00
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
using Panel = System.Windows.Controls.Panel;
2025-08-03 16:46:33 +08:00
using Point = System.Windows.Point;
2025-05-25 09:29:48 +08:00
2025-08-03 16:46:33 +08:00
namespace Ink_Canvas
{
public partial class MainWindow : Window
{
2025-09-06 17:12:25 +08:00
private string _currentToolMode = "cursor";
2025-08-24 11:47:39 +08:00
#region "手勢"
2025-05-25 09:29:48 +08:00
/// <summary>
2025-05-31 21:13:02 +08:00
/// 用於浮動工具欄的"手勢"按鈕和白板工具欄的"手勢"按鈕的點擊事件
2025-05-25 09:29:48 +08:00
/// </summary>
2025-08-03 16:46:33 +08:00
private void TwoFingerGestureBorder_MouseUp(object sender, RoutedEventArgs e)
{
if (TwoFingerGestureBorder.Visibility == Visibility.Visible)
{
2025-05-25 09:29:48 +08:00
AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
AnimationsHelper.HideWithSlideAndFade(PenPalette);
AnimationsHelper.HideWithSlideAndFade(BoardPenPalette);
AnimationsHelper.HideWithSlideAndFade(BorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardBorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardEraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
AnimationsHelper.HideWithSlideAndFade(BoardTwoFingerGestureBorder);
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
AnimationsHelper.HideWithSlideAndFade(PenPalette);
AnimationsHelper.HideWithSlideAndFade(BoardPenPalette);
AnimationsHelper.HideWithSlideAndFade(BorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardBorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardEraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
AnimationsHelper.ShowWithSlideFromBottomAndFade(TwoFingerGestureBorder);
AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardTwoFingerGestureBorder);
}
}
/// <summary>
2025-05-31 21:13:02 +08:00
/// 用於更新浮動工具欄的"手勢"按鈕和白板工具欄的"手勢"按鈕的樣式(開啟和關閉狀態)
2025-05-25 09:29:48 +08:00
/// </summary>
2025-08-03 16:46:33 +08:00
private void CheckEnableTwoFingerGestureBtnColorPrompt()
{
if (ToggleSwitchEnableMultiTouchMode.IsOn)
{
2025-09-13 11:46:49 +08:00
// 多指书写模式启用时,手势功能被禁用
2025-05-25 09:29:48 +08:00
TwoFingerGestureSimpleStackPanel.Opacity = 0.5;
TwoFingerGestureSimpleStackPanel.IsHitTestVisible = false;
2025-11-01 20:26:52 +08:00
EnableTwoFingerGestureBtn.Source = (BitmapImage)Application.Current.FindResource("GestureIcon");
2025-08-03 16:46:33 +08:00
2025-09-21 02:05:49 +08:00
// 根据主题设置颜色
if (Settings.Appearance.Theme == 1) // 深色主题
{
2025-10-03 17:08:46 +08:00
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
BoardGestureGeometry2.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
2025-09-21 02:05:49 +08:00
}
else // 浅色主题或跟随系统
{
2025-10-03 17:08:46 +08:00
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
BoardGestureGeometry2.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
2025-09-21 02:05:49 +08:00
}
2025-05-25 09:29:48 +08:00
BoardGestureGeometry.Geometry = Geometry.Parse(XamlGraphicsIconGeometries.DisabledGestureIcon);
BoardGestureGeometry2.Geometry = Geometry.Parse("F0 M24,24z M0,0z");
2025-09-20 11:55:50 +08:00
// 强制禁用所有双指手势功能
ForceDisableTwoFingerGestures();
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
else
{
2025-09-13 11:46:49 +08:00
// 多指书写模式禁用时,根据实际手势功能状态显示
2025-05-25 09:29:48 +08:00
TwoFingerGestureSimpleStackPanel.Opacity = 1;
TwoFingerGestureSimpleStackPanel.IsHitTestVisible = true;
2025-10-03 17:08:46 +08:00
2025-09-13 11:46:49 +08:00
// 检查是否有任何手势功能启用
bool hasGestureEnabled = Settings.Gesture.IsEnableTwoFingerGesture;
2025-10-03 17:08:46 +08:00
2025-09-13 11:46:49 +08:00
if (hasGestureEnabled)
2025-08-03 16:46:33 +08:00
{
2025-11-01 20:26:52 +08:00
EnableTwoFingerGestureBtn.Source = (BitmapImage)Application.Current.FindResource("GestureIconEnabled");
2025-08-03 16:46:33 +08:00
2025-05-25 09:29:48 +08:00
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235));
BoardGestureGeometry.Brush = new SolidColorBrush(Colors.GhostWhite);
BoardGestureGeometry2.Brush = new SolidColorBrush(Colors.GhostWhite);
BoardGestureLabel.Foreground = new SolidColorBrush(Colors.GhostWhite);
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(37, 99, 235));
BoardGestureGeometry.Geometry = Geometry.Parse(XamlGraphicsIconGeometries.EnabledGestureIcon);
2025-08-03 16:46:33 +08:00
BoardGestureGeometry2.Geometry = Geometry.Parse("F0 M24,24z M0,0z " + XamlGraphicsIconGeometries.EnabledGestureIconBadgeCheck);
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
else
{
2025-11-01 20:26:52 +08:00
EnableTwoFingerGestureBtn.Source = (BitmapImage)Application.Current.FindResource("GestureIcon");
2025-08-03 16:46:33 +08:00
2025-09-21 02:05:49 +08:00
// 根据主题设置颜色
if (Settings.Appearance.Theme == 1) // 深色主题
{
2025-10-03 17:08:46 +08:00
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
BoardGestureGeometry2.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
2025-09-21 02:05:49 +08:00
}
else // 浅色主题或跟随系统
{
BoardGesture.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
2025-10-03 17:08:46 +08:00
BoardGestureGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
BoardGestureGeometry2.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
BoardGestureLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
2025-09-21 02:05:49 +08:00
}
2025-05-25 09:29:48 +08:00
BoardGestureGeometry.Geometry = Geometry.Parse(XamlGraphicsIconGeometries.DisabledGestureIcon);
BoardGestureGeometry2.Geometry = Geometry.Parse("F0 M24,24z M0,0z");
}
}
}
/// <summary>
2025-05-31 21:13:02 +08:00
/// 控制是否顯示浮動工具欄的"手勢"按鈕
2025-05-25 09:29:48 +08:00
/// </summary>
2025-08-03 16:46:33 +08:00
private void CheckEnableTwoFingerGestureBtnVisibility(bool isVisible)
{
2025-09-07 00:20:48 +08:00
// 在PPT放映模式下根据设置决定是否显示手势按钮
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
{
2025-09-07 00:20:48 +08:00
// 如果启用了PPT放映模式显示手势按钮,且当前处于批注模式,则显示手势按钮
if (Settings.PowerPointSettings.ShowGestureButtonInSlideShow && isVisible && inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
2025-09-06 19:27:17 +08:00
{
EnableTwoFingerGestureBorder.Visibility = Visibility.Visible;
}
else
{
EnableTwoFingerGestureBorder.Visibility = Visibility.Collapsed;
}
return;
}
2025-09-07 00:20:48 +08:00
if (currentMode == 0)
{
2025-11-01 18:29:58 +08:00
if (GridTransparencyFakeBackground.Background != Brushes.Transparent && isVisible)
{
}
else
{
EnableTwoFingerGestureBorder.Visibility = Visibility.Collapsed;
return;
}
2025-09-07 00:20:48 +08:00
}
2025-05-25 09:29:48 +08:00
if (StackPanelCanvasControls.Visibility != Visibility.Visible
2025-08-03 16:46:33 +08:00
|| BorderFloatingBarMainControls.Visibility != Visibility.Visible)
{
2025-05-25 09:29:48 +08:00
EnableTwoFingerGestureBorder.Visibility = Visibility.Collapsed;
}
2025-08-03 16:46:33 +08:00
else if (isVisible)
{
EnableTwoFingerGestureBorder.Visibility = Visibility.Visible;
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
EnableTwoFingerGestureBorder.Visibility = Visibility.Collapsed;
}
}
2025-05-31 21:13:02 +08:00
#endregion "手勢"
2025-05-25 09:29:48 +08:00
#region
2025-07-28 14:40:44 +08:00
private bool isDragDropInEffect;
private Point pos;
private Point downPos;
2025-05-25 09:29:48 +08:00
private Point pointDesktop = new Point(-1, -1); //用于记录上次在桌面时的坐标
private Point pointPPT = new Point(-1, -1); //用于记录上次在PPT中的坐标
2025-08-03 16:46:33 +08:00
private void SymbolIconEmoji_MouseMove(object sender, MouseEventArgs e)
{
if (isDragDropInEffect)
{
2025-05-25 09:29:48 +08:00
var xPos = e.GetPosition(null).X - pos.X + ViewboxFloatingBar.Margin.Left;
var yPos = e.GetPosition(null).Y - pos.Y + ViewboxFloatingBar.Margin.Top;
ViewboxFloatingBar.Margin = new Thickness(xPos, yPos, -2000, -200);
pos = e.GetPosition(null);
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
pointPPT = new Point(xPos, yPos);
else
pointDesktop = new Point(xPos, yPos);
}
}
2025-08-03 16:46:33 +08:00
private void SymbolIconEmoji_MouseDown(object sender, MouseButtonEventArgs e)
{
if (isViewboxFloatingBarMarginAnimationRunning)
{
2025-05-25 09:29:48 +08:00
ViewboxFloatingBar.BeginAnimation(MarginProperty, null);
isViewboxFloatingBarMarginAnimationRunning = false;
}
isDragDropInEffect = true;
pos = e.GetPosition(null);
downPos = e.GetPosition(null);
GridForFloatingBarDraging.Visibility = Visibility.Visible;
}
2025-08-23 21:39:00 +08:00
internal void SymbolIconEmoji_MouseUp(object sender, MouseButtonEventArgs e)
2025-08-03 16:46:33 +08:00
{
2025-05-25 09:29:48 +08:00
isDragDropInEffect = false;
if (e is null || (Math.Abs(downPos.X - e.GetPosition(null).X) <= 10 &&
2025-08-03 16:46:33 +08:00
Math.Abs(downPos.Y - e.GetPosition(null).Y) <= 10))
{
if (BorderFloatingBarMainControls.Visibility == Visibility.Visible)
{
2025-05-25 09:29:48 +08:00
BorderFloatingBarMainControls.Visibility = Visibility.Collapsed;
CheckEnableTwoFingerGestureBtnVisibility(false);
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
BorderFloatingBarMainControls.Visibility = Visibility.Visible;
CheckEnableTwoFingerGestureBtnVisibility(true);
}
}
GridForFloatingBarDraging.Visibility = Visibility.Collapsed;
}
#endregion
#region
/// <summary>
/// 隱藏形狀繪製面板
/// </summary>
private void CollapseBorderDrawShape()
{
AnimationsHelper.HideWithSlideAndFade(BorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardBorderDrawShape);
}
/// <summary>
/// <c>HideSubPanels</c>的青春版。目前需要修改<c>BorderSettings</c>的關閉機制(改為動畫關閉)。
/// </summary>
private void HideSubPanelsImmediately()
{
BorderTools.Visibility = Visibility.Collapsed;
BoardBorderTools.Visibility = Visibility.Collapsed;
PenPalette.Visibility = Visibility.Collapsed;
BoardPenPalette.Visibility = Visibility.Collapsed;
BoardEraserSizePanel.Visibility = Visibility.Collapsed;
EraserSizePanel.Visibility = Visibility.Collapsed;
BorderSettings.Visibility = Visibility.Collapsed;
BoardBorderLeftPageListView.Visibility = Visibility.Collapsed;
BoardBorderRightPageListView.Visibility = Visibility.Collapsed;
2025-07-30 19:56:22 +08:00
BoardImageOptionsPanel.Visibility = Visibility.Collapsed;
2025-08-31 01:55:17 +08:00
// 添加隐藏图形工具的二级菜单面板
BorderDrawShape.Visibility = Visibility.Collapsed;
BoardBorderDrawShape.Visibility = Visibility.Collapsed;
2025-05-25 09:29:48 +08:00
}
/// <summary>
/// <para>
/// 易嚴定真,這個多功能函數包括了以下的內容:
/// </para>
/// <list type="number">
/// <item>
2025-05-31 21:13:02 +08:00
/// 隱藏浮動工具欄和白板模式下的"更多功能"面板
2025-05-25 09:29:48 +08:00
/// </item>
/// <item>
/// 隱藏白板模式下和浮動工具欄的畫筆調色盤
/// </item>
/// <item>
2025-05-31 21:13:02 +08:00
/// 隱藏白板模式下的"清屏"按鈕(已作廢)
2025-05-25 09:29:48 +08:00
/// </item>
/// <item>
/// 負責給Settings設置面板做隱藏動畫
/// </item>
/// <item>
2025-05-31 21:13:02 +08:00
/// 隱藏白板模式下和浮動工具欄的"手勢"面板
2025-05-25 09:29:48 +08:00
/// </item>
/// <item>
2025-05-31 21:13:02 +08:00
/// 當<c>ToggleSwitchDrawShapeBorderAutoHide</c>開啟時,會自動隱藏白板模式下和浮動工具欄的"形狀"面板
2025-05-25 09:29:48 +08:00
/// </item>
/// <item>
/// 按需高亮指定的浮動工具欄和白板工具欄中的按鈕,通過param<paramref name="mode"/> 來指定
/// </item>
/// <item>
/// 將浮動工具欄自動居中,通過param<paramref name="autoAlignCenter"/>
/// </item>
/// </list>
/// </summary>
/// <param name="mode">
/// <para>
/// 按需高亮指定的浮動工具欄和白板工具欄中的按鈕,有下面幾種情況:
/// </para>
/// <list type="number">
/// <item>
/// 當<c><paramref name="mode"/>==null</c>時,不會執行任何有關操作
/// </item>
/// <item>
/// 當<c><paramref name="mode"/>!="clear"</c>時,會先取消高亮所有工具欄按鈕,然後根據下面的情況進行高亮處理
/// </item>
/// <item>
2025-05-31 21:13:02 +08:00
/// 當<c><paramref name="mode"/>=="color" || <paramref name="mode"/>=="pen"</c>時,會高亮浮動工具欄和白板工具欄中的"批註""筆"按鈕
2025-05-25 09:29:48 +08:00
/// </item>
/// <item>
2025-05-31 21:13:02 +08:00
/// 當<c><paramref name="mode"/>=="eraser"</c>時,會高亮白板工具欄中的"橡皮"和浮動工具欄中的"面積擦"按鈕
2025-05-25 09:29:48 +08:00
/// </item>
/// <item>
2025-05-31 21:13:02 +08:00
/// 當<c><paramref name="mode"/>=="eraserByStrokes"</c>時,會高亮白板工具欄中的"橡皮"和浮動工具欄中的"墨跡擦"按鈕
2025-05-25 09:29:48 +08:00
/// </item>
/// <item>
2025-05-31 21:13:02 +08:00
/// 當<c><paramref name="mode"/>=="select"</c>時,會高亮浮動工具欄和白板工具欄中的"選擇""套索選"按鈕
2025-05-25 09:29:48 +08:00
/// </item>
/// </list>
/// </param>
/// <param name="autoAlignCenter">
/// 是否自動居中浮動工具欄
/// </param>
2025-08-03 16:46:33 +08:00
private async void HideSubPanels(string mode = null, bool autoAlignCenter = false)
{
2025-05-25 09:29:48 +08:00
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
AnimationsHelper.HideWithSlideAndFade(PenPalette);
AnimationsHelper.HideWithSlideAndFade(BoardPenPalette);
AnimationsHelper.HideWithSlideAndFade(BoardEraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(BorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardBorderLeftPageListView);
AnimationsHelper.HideWithSlideAndFade(BoardBorderRightPageListView);
2025-08-13 12:16:55 +08:00
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
2025-07-30 19:56:22 +08:00
2025-07-16 09:16:36 +08:00
// 隐藏背景设置面板
var bgPalette = LogicalTreeHelper.FindLogicalNode(this, "BackgroundPalette") as Border;
if (bgPalette != null)
{
AnimationsHelper.HideWithSlideAndFade(bgPalette);
}
2025-05-25 09:29:48 +08:00
2025-08-03 16:46:33 +08:00
if (BorderSettings.Visibility == Visibility.Visible)
{
2025-06-19 11:25:15 +08:00
// 设置蒙版为不可点击,并移除背景
2025-05-25 09:29:48 +08:00
BorderSettingsMask.IsHitTestVisible = false;
BorderSettingsMask.Background = null;
var sb = new Storyboard();
// 滑动动画
2025-08-03 16:46:33 +08:00
var slideAnimation = new DoubleAnimation
{
2025-05-25 09:29:48 +08:00
From = 0, // 滑动距离
To = BorderSettings.RenderTransform.Value.OffsetX - 490,
2025-05-25 09:29:48 +08:00
Duration = TimeSpan.FromSeconds(0.6)
};
2025-07-28 14:40:44 +08:00
slideAnimation.EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut };
2025-05-25 09:29:48 +08:00
Storyboard.SetTargetProperty(slideAnimation,
new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)"));
sb.Children.Add(slideAnimation);
2025-08-03 16:46:33 +08:00
sb.Completed += (s, _) =>
{
2025-05-25 09:29:48 +08:00
BorderSettings.Visibility = Visibility.Collapsed;
isOpeningOrHidingSettingsPane = false;
2025-10-18 18:29:52 +08:00
if (isTemporarilyDisablingNoFocusMode)
2025-09-06 17:51:25 +08:00
{
2025-10-18 18:29:52 +08:00
isTemporarilyDisablingNoFocusMode = false;
2025-09-06 17:51:25 +08:00
ApplyNoFocusMode();
}
2025-05-25 09:29:48 +08:00
};
BorderSettings.RenderTransform = new TranslateTransform();
isOpeningOrHidingSettingsPane = true;
2025-07-28 14:40:44 +08:00
sb.Begin(BorderSettings);
2025-05-25 09:29:48 +08:00
}
AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(BoardTwoFingerGestureBorder);
2025-08-03 16:46:33 +08:00
if (ToggleSwitchDrawShapeBorderAutoHide.IsOn)
{
2025-05-25 09:29:48 +08:00
AnimationsHelper.HideWithSlideAndFade(BorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardBorderDrawShape);
}
2025-08-03 16:46:33 +08:00
if (mode != null)
{
if (mode != "clear")
{
2025-09-21 00:25:09 +08:00
CursorIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
2025-10-01 09:52:15 +08:00
CursorIconGeometry.Geometry = Geometry.Parse(GetCorrectIcon("cursor", false));
2025-09-21 00:25:09 +08:00
PenIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
2025-10-01 09:52:15 +08:00
PenIconGeometry.Geometry = Geometry.Parse(GetCorrectIcon("pen", false));
2025-09-21 00:25:09 +08:00
StrokeEraserIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
2025-05-25 09:29:48 +08:00
StrokeEraserIconGeometry.Geometry =
2025-10-01 09:52:15 +08:00
Geometry.Parse(GetCorrectIcon("eraserStroke", false));
2025-09-21 00:25:09 +08:00
CircleEraserIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
2025-05-25 09:29:48 +08:00
CircleEraserIconGeometry.Geometry =
2025-10-01 09:52:15 +08:00
Geometry.Parse(GetCorrectIcon("eraserCircle", false));
2025-09-21 00:25:09 +08:00
LassoSelectIconGeometry.Brush = new SolidColorBrush(FloatBarForegroundColor);
2025-10-01 09:52:15 +08:00
LassoSelectIconGeometry.Geometry = Geometry.Parse(GetCorrectIcon("lassoSelect", false));
2025-05-25 09:29:48 +08:00
2025-09-21 02:05:49 +08:00
// 根据主题设置颜色
if (Settings.Appearance.Theme == 1) // 深色主题
{
2025-10-03 17:08:46 +08:00
BoardPen.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
BoardSelect.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
BoardEraser.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
BoardSelectGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
BoardEraserGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
BoardSelectLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
BoardEraserLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
BoardSelect.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
BoardEraser.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
2025-09-21 02:05:49 +08:00
}
else // 浅色主题或跟随系统
{
2025-10-03 17:08:46 +08:00
BoardPen.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
BoardSelect.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
BoardEraser.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
BoardSelectGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
BoardEraserGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
BoardSelectLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
BoardEraserLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
BoardSelect.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
BoardEraser.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
2025-09-21 02:05:49 +08:00
}
2025-05-25 09:29:48 +08:00
HideFloatingBarHighlight();
2025-05-25 09:29:48 +08:00
}
2025-10-04 17:26:11 +08:00
// 根据主题选择高光颜色
Color highlightColor;
2025-10-06 18:29:12 +08:00
bool isDarkTheme = Settings.Appearance.Theme == 1 ||
2025-10-04 17:26:11 +08:00
(Settings.Appearance.Theme == 2 && !IsSystemThemeLight());
2025-10-06 18:29:12 +08:00
2025-10-04 17:26:11 +08:00
if (isDarkTheme)
{
highlightColor = Color.FromRgb(102, 204, 255); // #66ccff for dark theme
}
else
{
highlightColor = Color.FromRgb(30, 58, 138); // Keep current color for light theme
}
2025-08-03 16:46:33 +08:00
switch (mode)
{
2025-05-25 09:29:48 +08:00
case "pen":
2025-08-03 16:46:33 +08:00
case "color":
{
2025-10-04 17:26:11 +08:00
PenIconGeometry.Brush = new SolidColorBrush(highlightColor);
2025-10-01 09:52:15 +08:00
PenIconGeometry.Geometry = Geometry.Parse(GetCorrectIcon("pen", true));
2025-08-03 16:46:33 +08:00
BoardPen.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235));
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(37, 99, 235));
BoardPenGeometry.Brush = new SolidColorBrush(Colors.GhostWhite);
BoardPenLabel.Foreground = new SolidColorBrush(Colors.GhostWhite);
SetFloatingBarHighlightPosition("pen");
2025-05-25 09:29:48 +08:00
break;
2025-08-03 16:46:33 +08:00
}
case "eraser":
{
2025-10-04 17:26:11 +08:00
CircleEraserIconGeometry.Brush = new SolidColorBrush(highlightColor);
2025-08-03 16:46:33 +08:00
CircleEraserIconGeometry.Geometry =
2025-10-01 09:52:15 +08:00
Geometry.Parse(GetCorrectIcon("eraserCircle", true));
2025-08-03 16:46:33 +08:00
BoardEraser.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235));
BoardEraser.BorderBrush = new SolidColorBrush(Color.FromRgb(37, 99, 235));
BoardEraserGeometry.Brush = new SolidColorBrush(Colors.GhostWhite);
BoardEraserLabel.Foreground = new SolidColorBrush(Colors.GhostWhite);
SetFloatingBarHighlightPosition("eraser");
2025-05-25 09:29:48 +08:00
break;
2025-08-03 16:46:33 +08:00
}
case "eraserByStrokes":
{
2025-10-04 17:26:11 +08:00
StrokeEraserIconGeometry.Brush = new SolidColorBrush(highlightColor);
2025-08-03 16:46:33 +08:00
StrokeEraserIconGeometry.Geometry =
2025-10-01 09:52:15 +08:00
Geometry.Parse(GetCorrectIcon("eraserStroke", true));
2025-08-03 16:46:33 +08:00
BoardEraser.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235));
BoardEraser.BorderBrush = new SolidColorBrush(Color.FromRgb(37, 99, 235));
BoardEraserGeometry.Brush = new SolidColorBrush(Colors.GhostWhite);
BoardEraserLabel.Foreground = new SolidColorBrush(Colors.GhostWhite);
SetFloatingBarHighlightPosition("eraserByStrokes");
2025-05-25 09:29:48 +08:00
break;
2025-08-03 16:46:33 +08:00
}
case "select":
{
2025-10-04 17:26:11 +08:00
LassoSelectIconGeometry.Brush = new SolidColorBrush(highlightColor);
2025-08-31 11:43:52 +08:00
LassoSelectIconGeometry.Geometry =
2025-10-01 09:52:15 +08:00
Geometry.Parse(GetCorrectIcon("lassoSelect", true));
2025-08-03 16:46:33 +08:00
BoardSelect.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235));
BoardSelect.BorderBrush = new SolidColorBrush(Color.FromRgb(37, 99, 235));
BoardSelectGeometry.Brush = new SolidColorBrush(Colors.GhostWhite);
BoardSelectLabel.Foreground = new SolidColorBrush(Colors.GhostWhite);
SetFloatingBarHighlightPosition("select");
2025-05-25 09:29:48 +08:00
break;
2025-08-03 16:46:33 +08:00
}
2025-08-12 15:33:19 +08:00
case "cursor":
{
2025-10-04 17:26:11 +08:00
CursorIconGeometry.Brush = new SolidColorBrush(highlightColor);
2025-08-31 11:43:52 +08:00
CursorIconGeometry.Geometry =
2025-10-01 09:52:15 +08:00
Geometry.Parse(GetCorrectIcon("cursor", true));
2025-09-21 02:05:49 +08:00
// 根据主题设置颜色
if (Settings.Appearance.Theme == 1) // 深色主题
{
2025-10-03 17:08:46 +08:00
BoardPen.Background = new SolidColorBrush(Color.FromRgb(42, 42, 42));
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(85, 85, 85));
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
2025-09-21 02:05:49 +08:00
}
else // 浅色主题或跟随系统
{
2025-10-03 17:08:46 +08:00
BoardPen.Background = new SolidColorBrush(Color.FromRgb(244, 244, 245));
BoardPen.BorderBrush = new SolidColorBrush(Color.FromRgb(161, 161, 170));
BoardPenGeometry.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
BoardPenLabel.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
2025-09-21 02:05:49 +08:00
}
2025-08-12 15:33:19 +08:00
SetFloatingBarHighlightPosition("cursor");
2025-08-12 15:33:19 +08:00
break;
}
2025-08-03 16:46:33 +08:00
case "shape":
{
// 对图形模式进行特殊处理,不修改按钮UI状态
// 只隐藏相关面板,但保持图形绘制模式
break;
}
2025-05-25 09:29:48 +08:00
}
if (autoAlignCenter) // 控制居中
{
2025-08-03 16:46:33 +08:00
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
{
2025-05-25 09:29:48 +08:00
await Task.Delay(50);
ViewboxFloatingBarMarginAnimation(60);
}
2025-07-28 14:40:44 +08:00
else if (Topmost) //非黑板
2025-05-25 09:29:48 +08:00
{
await Task.Delay(50);
ViewboxFloatingBarMarginAnimation(100, true);
}
else //黑板
{
await Task.Delay(50);
ViewboxFloatingBarMarginAnimation(60);
}
}
}
await Task.Delay(150);
isHidingSubPanelsWhenInking = false;
}
#endregion
#region
2025-08-23 21:39:00 +08:00
internal void SymbolIconUndo_MouseUp(object sender, MouseButtonEventArgs e)
2025-08-03 16:46:33 +08:00
{
2025-05-25 09:29:48 +08:00
//if (lastBorderMouseDownObject != sender) return;
if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel)
((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent);
if (sender == SymbolIconUndo && lastBorderMouseDownObject != SymbolIconUndo) return;
if (!BtnUndo.IsEnabled) return;
BtnUndo_Click(BtnUndo, null);
HideSubPanels();
}
2025-08-23 21:39:00 +08:00
internal void SymbolIconRedo_MouseUp(object sender, MouseButtonEventArgs e)
2025-08-03 16:46:33 +08:00
{
2025-05-25 09:29:48 +08:00
//if (lastBorderMouseDownObject != sender) return;
if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel)
((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent);
if (sender == SymbolIconRedo && lastBorderMouseDownObject != SymbolIconRedo) return;
if (!BtnRedo.IsEnabled) return;
BtnRedo_Click(BtnRedo, null);
HideSubPanels();
}
#endregion
#region 退
//private bool Not_Enter_Blackboard_fir_Mouse_Click = true;
2025-07-28 14:40:44 +08:00
private bool isDisplayingOrHidingBlackboard;
2025-05-25 09:29:48 +08:00
2025-08-23 21:39:00 +08:00
internal void ImageBlackboard_MouseUp(object sender, MouseButtonEventArgs e)
2025-05-25 09:29:48 +08:00
{
if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel)
((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent);
if (sender == WhiteboardFloatingBarBtn && lastBorderMouseDownObject != WhiteboardFloatingBarBtn) return;
LeftUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
RightUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
if (isDisplayingOrHidingBlackboard) return;
isDisplayingOrHidingBlackboard = true;
UnFoldFloatingBar_MouseUp(null, null);
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select) PenIcon_Click(null, null);
if (currentMode == 0)
{
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
//進入黑板
2025-05-25 09:29:48 +08:00
/*
if (Not_Enter_Blackboard_fir_Mouse_Click) {// BUG-Fixed_tmp:程序启动后直接进入白板会导致后续撤销功能、退出白板无法恢复墨迹
BtnColorRed_Click(BorderPenColorRed, null);
await Task.Delay(200);
SimulateMouseClick.SimulateMouseClickAtTopLeft();
await Task.Delay(10);
Not_Enter_Blackboard_fir_Mouse_Click = false;
}
*/
2025-08-03 16:46:33 +08:00
new Thread(() =>
{
2025-05-25 09:29:48 +08:00
Thread.Sleep(100);
Application.Current.Dispatcher.Invoke(() => { ViewboxFloatingBarMarginAnimation(60); });
2025-07-28 14:40:44 +08:00
}).Start();
2025-08-03 16:46:33 +08:00
2025-07-18 11:38:32 +08:00
HideSubPanels();
2025-05-25 09:29:48 +08:00
if (GridTransparencyFakeBackground.Background == Brushes.Transparent)
{
if (currentMode == 1)
{
currentMode = 0;
GridBackgroundCover.Visibility = Visibility.Collapsed;
AnimationsHelper.HideWithSlideAndFade(BlackboardLeftSide);
AnimationsHelper.HideWithSlideAndFade(BlackboardCenterSide);
AnimationsHelper.HideWithSlideAndFade(BlackboardRightSide);
}
BtnHideInkCanvas_Click(BtnHideInkCanvas, null);
}
if (Settings.Gesture.AutoSwitchTwoFingerGesture) // 自动关闭多指书写、开启双指移动
{
ToggleSwitchEnableTwoFingerTranslate.IsOn = true;
if (isInMultiTouchMode) ToggleSwitchEnableMultiTouchMode.IsOn = false;
}
2025-07-28 14:40:44 +08:00
if (Settings.Appearance.EnableTimeDisplayInWhiteboardMode)
2025-05-25 09:29:48 +08:00
{
WaterMarkTime.Visibility = Visibility.Visible;
WaterMarkDate.Visibility = Visibility.Visible;
2025-08-03 16:46:33 +08:00
}
else
{
2025-05-25 09:29:48 +08:00
WaterMarkTime.Visibility = Visibility.Collapsed;
WaterMarkDate.Visibility = Visibility.Collapsed;
}
2025-07-28 14:40:44 +08:00
if (Settings.Appearance.EnableChickenSoupInWhiteboardMode)
2025-05-25 09:29:48 +08:00
{
BlackBoardWaterMark.Visibility = Visibility.Visible;
2025-08-03 16:46:33 +08:00
}
else
{
2025-05-25 09:29:48 +08:00
BlackBoardWaterMark.Visibility = Visibility.Collapsed;
}
2025-08-03 16:46:33 +08:00
if (Settings.Appearance.ChickenSoupSource == 0)
{
2025-05-25 09:29:48 +08:00
int randChickenSoupIndex = new Random().Next(ChickenSoup.OSUPlayerYuLu.Length);
BlackBoardWaterMark.Text = ChickenSoup.OSUPlayerYuLu[randChickenSoupIndex];
2025-08-03 16:46:33 +08:00
}
else if (Settings.Appearance.ChickenSoupSource == 1)
{
2025-05-25 09:29:48 +08:00
int randChickenSoupIndex = new Random().Next(ChickenSoup.MingYanJingJu.Length);
BlackBoardWaterMark.Text = ChickenSoup.MingYanJingJu[randChickenSoupIndex];
2025-08-03 16:46:33 +08:00
}
else if (Settings.Appearance.ChickenSoupSource == 2)
{
2025-05-25 09:29:48 +08:00
int randChickenSoupIndex = new Random().Next(ChickenSoup.GaoKaoPhrases.Length);
BlackBoardWaterMark.Text = ChickenSoup.GaoKaoPhrases[randChickenSoupIndex];
}
if (Settings.Canvas.UsingWhiteboard)
{
ICCWaterMarkDark.Visibility = Visibility.Visible;
ICCWaterMarkWhite.Visibility = Visibility.Collapsed;
}
else
{
ICCWaterMarkWhite.Visibility = Visibility.Visible;
ICCWaterMarkDark.Visibility = Visibility.Collapsed;
}
2025-08-31 09:54:13 +08:00
// 新增:确保在白板模式下基础浮动栏被隐藏
ViewboxFloatingBar.Visibility = Visibility.Collapsed;
2025-05-25 09:29:48 +08:00
}
else
{
//关闭黑板
HideSubPanelsImmediately();
2025-09-06 14:18:09 +08:00
// 只有在PPT放映模式下且页数有效时才显示翻页按钮
2025-09-07 13:30:46 +08:00
if (StackPanelPPTControls.Visibility == Visibility.Visible &&
2025-09-06 10:17:12 +08:00
BtnPPTSlideShowEnd.Visibility == Visibility.Visible &&
2025-09-06 14:18:09 +08:00
PPTManager?.IsInSlideShow == true &&
2025-09-22 11:36:55 +08:00
PPTManager?.SlidesCount > 0)
2025-05-25 09:29:48 +08:00
{
var dops = Settings.PowerPointSettings.PPTButtonsDisplayOption.ToString();
var dopsc = dops.ToCharArray();
2025-08-31 09:54:13 +08:00
if (dopsc[0] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(LeftBottomPanelForPPTNavigation);
if (dopsc[1] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightBottomPanelForPPTNavigation);
if (dopsc[2] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(LeftSidePanelForPPTNavigation);
if (dopsc[3] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightSidePanelForPPTNavigation);
2025-05-25 09:29:48 +08:00
}
2025-09-06 10:17:12 +08:00
else
{
2025-09-06 14:18:09 +08:00
// 如果不在放映模式或页数无效,隐藏所有翻页按钮
2025-09-06 10:17:12 +08:00
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
}
2025-09-07 13:30:46 +08:00
2025-09-06 15:28:14 +08:00
// 使用PPT UI管理器来正确更新翻页按钮显示状态,确保遵循用户设置
if (_pptUIManager != null)
{
2025-09-06 15:28:14 +08:00
_pptUIManager.UpdateNavigationPanelsVisibility();
}
2025-05-25 09:29:48 +08:00
if (Settings.Automation.IsAutoSaveStrokesAtClear &&
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber) SaveScreenShot(true);
if (BtnPPTSlideShowEnd.Visibility == Visibility.Collapsed)
2025-08-03 16:46:33 +08:00
new Thread(() =>
{
2025-05-25 09:29:48 +08:00
Thread.Sleep(300);
Application.Current.Dispatcher.Invoke(() => { ViewboxFloatingBarMarginAnimation(100, true); });
2025-07-28 14:40:44 +08:00
}).Start();
2025-05-25 09:29:48 +08:00
else
2025-08-03 16:46:33 +08:00
new Thread(() =>
{
2025-05-25 09:29:48 +08:00
Thread.Sleep(300);
Application.Current.Dispatcher.Invoke(() => { ViewboxFloatingBarMarginAnimation(60); });
2025-07-28 14:40:44 +08:00
}).Start();
2025-05-25 09:29:48 +08:00
2025-08-03 16:46:33 +08:00
if (System.Windows.Controls.Canvas.GetLeft(FloatingbarSelectionBG) != 28) PenIcon_Click(null, null);
2025-05-25 09:29:48 +08:00
if (Settings.Gesture.AutoSwitchTwoFingerGesture) // 自动启用多指书写
ToggleSwitchEnableTwoFingerTranslate.IsOn = false;
// 2024.5.2 need to be tested
// if (!isInMultiTouchMode) ToggleSwitchEnableMultiTouchMode.IsOn = true;
WaterMarkTime.Visibility = Visibility.Collapsed;
WaterMarkDate.Visibility = Visibility.Collapsed;
BlackBoardWaterMark.Visibility = Visibility.Collapsed;
ICCWaterMarkDark.Visibility = Visibility.Collapsed;
ICCWaterMarkWhite.Visibility = Visibility.Collapsed;
2025-08-31 09:54:13 +08:00
// 新增:退出白板模式时恢复基础浮动栏的显示
ViewboxFloatingBar.Visibility = Visibility.Visible;
2025-05-25 09:29:48 +08:00
}
BtnSwitch_Click(BtnSwitch, null);
2025-09-22 13:11:22 +08:00
if (currentMode == 0)
{
// 根据当前编辑模式正确设置工具模式和高光位置
if (inkCanvas.EditingMode == InkCanvasEditingMode.None)
{
UpdateCurrentToolMode("cursor");
SetFloatingBarHighlightPosition("cursor");
}
else if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
{
UpdateCurrentToolMode("pen");
SetFloatingBarHighlightPosition("pen");
}
else if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
{
UpdateCurrentToolMode("eraser");
SetFloatingBarHighlightPosition("eraser");
}
else if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByStroke)
{
UpdateCurrentToolMode("eraserByStrokes");
SetFloatingBarHighlightPosition("eraserByStrokes");
}
else if (inkCanvas.EditingMode == InkCanvasEditingMode.Select)
{
UpdateCurrentToolMode("select");
SetFloatingBarHighlightPosition("select");
}
}
2025-05-25 09:29:48 +08:00
if (currentMode == 0 && inkCanvas.Strokes.Count == 0 && BtnPPTSlideShowEnd.Visibility != Visibility.Visible)
CursorIcon_Click(null, null);
BtnExit.Foreground = Brushes.White;
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
2025-08-03 16:46:33 +08:00
new Thread(() =>
{
2025-05-25 09:29:48 +08:00
Thread.Sleep(200);
Application.Current.Dispatcher.Invoke(() => { isDisplayingOrHidingBlackboard = false; });
2025-07-28 14:40:44 +08:00
}).Start();
2025-05-25 09:29:48 +08:00
SwitchToDefaultPen(null, null);
CheckColorTheme(true);
}
#endregion
2025-08-03 16:46:33 +08:00
private async void SymbolIconCursor_Click(object sender, RoutedEventArgs e)
{
if (currentMode != 0)
{
2025-05-25 09:29:48 +08:00
ImageBlackboard_MouseUp(null, null);
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
BtnHideInkCanvas_Click(BtnHideInkCanvas, null);
2025-08-03 16:46:33 +08:00
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
{
2025-05-25 09:29:48 +08:00
await Task.Delay(100);
ViewboxFloatingBarMarginAnimation(60);
}
}
}
#region
2025-08-23 21:39:00 +08:00
internal void SymbolIconDelete_MouseUp(object sender, MouseButtonEventArgs e)
2025-08-03 16:46:33 +08:00
{
2025-05-25 09:29:48 +08:00
if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel)
((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent);
if (sender == SymbolIconDelete && lastBorderMouseDownObject != SymbolIconDelete) return;
2025-08-03 16:46:33 +08:00
if (inkCanvas.GetSelectedStrokes().Count > 0)
{
2025-05-25 09:29:48 +08:00
inkCanvas.Strokes.Remove(inkCanvas.GetSelectedStrokes());
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
}
2025-08-03 16:46:33 +08:00
else if (inkCanvas.Strokes.Count > 0)
{
2025-05-25 09:29:48 +08:00
if (Settings.Automation.IsAutoSaveStrokesAtClear &&
2025-08-03 16:46:33 +08:00
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber)
{
2025-05-25 09:29:48 +08:00
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
2025-07-29 01:15:32 +08:00
{
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
var presentationName = _pptManager?.GetPresentationName() ?? "";
SaveScreenShot(true, $"{presentationName}/{currentSlide}_{DateTime.Now:HH-mm-ss}");
}
2025-05-25 09:29:48 +08:00
else
SaveScreenShot(true);
}
BtnClear_Click(null, null);
}
}
#endregion
/// <summary>
/// 面积擦子面板的清空墨迹按钮事件处理
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">RoutedEventArgs</param>
private void EraserPanelSymbolIconDelete_MouseUp(object sender, RoutedEventArgs e)
{
2025-09-27 17:09:06 +08:00
PenIcon_Click(null, null);
SymbolIconDelete_MouseUp(null, null);
}
2025-05-25 09:29:48 +08:00
#region
/// <summary>
2025-10-18 18:26:13 +08:00
/// 浮動工具欄的"套索選"按鈕事件,重定向到舊UI的<c>BtnSelect_Click</c>方法
2025-05-25 09:29:48 +08:00
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">MouseButtonEventArgs</param>
2025-08-23 21:39:00 +08:00
internal void SymbolIconSelect_MouseUp(object sender, MouseButtonEventArgs e)
2025-05-25 09:29:48 +08:00
{
if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel)
((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent);
if (sender == SymbolIconSelect && lastBorderMouseDownObject != SymbolIconSelect) return;
BtnSelect_Click(null, null);
2025-09-07 13:30:46 +08:00
2025-09-06 17:12:25 +08:00
// 更新模式缓存
UpdateCurrentToolMode("select");
2025-09-07 13:30:46 +08:00
2025-05-25 09:29:48 +08:00
HideSubPanels("select");
2025-08-24 08:45:53 +08:00
2025-05-25 09:29:48 +08:00
}
#endregion
2025-08-03 16:46:33 +08:00
private void FloatingBarToolBtnMouseDownFeedback_Panel(object sender, MouseButtonEventArgs e)
{
2025-08-11 20:19:01 +08:00
if (sender is Panel panel)
{
lastBorderMouseDownObject = sender;
if (panel == SymbolIconDelete) panel.Background = new SolidColorBrush(Color.FromArgb(28, 127, 29, 29));
else panel.Background = new SolidColorBrush(Color.FromArgb(28, 24, 24, 27));
}
else if (sender is Border border)
{
lastBorderMouseDownObject = sender;
2025-08-11 20:23:14 +08:00
// 对于快捷调色板的颜色球,不改变背景颜色,只添加透明度效果
if (border.Name?.StartsWith("QuickColor") == true)
{
// 保存原始颜色并添加透明度
var originalColor = border.Background as SolidColorBrush;
if (originalColor != null)
{
border.Background = new SolidColorBrush(Color.FromArgb(180, originalColor.Color.R, originalColor.Color.G, originalColor.Color.B));
}
}
else
{
border.Background = new SolidColorBrush(Color.FromArgb(28, 24, 24, 27));
}
2025-08-11 20:19:01 +08:00
}
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
private void FloatingBarToolBtnMouseLeaveFeedback_Panel(object sender, MouseEventArgs e)
{
2025-08-11 20:19:01 +08:00
if (sender is Panel panel)
{
lastBorderMouseDownObject = null;
panel.Background = new SolidColorBrush(Colors.Transparent);
}
else if (sender is Border border)
{
lastBorderMouseDownObject = null;
2025-08-11 20:23:14 +08:00
// 对于快捷调色板的颜色球,恢复原始颜色
if (border.Name?.StartsWith("QuickColor") == true)
{
// 根据颜色球名称恢复对应的颜色
switch (border.Name)
{
case "QuickColorWhite":
2025-08-12 12:19:55 +08:00
case "QuickColorWhiteSingle":
2025-08-11 20:23:14 +08:00
border.Background = new SolidColorBrush(Colors.White);
break;
case "QuickColorOrange":
2025-08-12 12:19:55 +08:00
case "QuickColorOrangeSingle":
2025-08-23 18:43:47 +08:00
border.Background = new SolidColorBrush(Color.FromRgb(251, 150, 80));
2025-08-11 20:23:14 +08:00
break;
case "QuickColorYellow":
2025-08-12 12:19:55 +08:00
case "QuickColorYellowSingle":
2025-08-11 20:23:14 +08:00
border.Background = new SolidColorBrush(Colors.Yellow);
break;
case "QuickColorBlack":
2025-08-12 12:19:55 +08:00
case "QuickColorBlackSingle":
2025-08-11 20:23:14 +08:00
border.Background = new SolidColorBrush(Colors.Black);
break;
case "QuickColorBlue":
2025-08-12 12:19:55 +08:00
border.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235));
2025-08-11 20:23:14 +08:00
break;
case "QuickColorRed":
2025-08-12 12:19:55 +08:00
case "QuickColorRedSingle":
2025-08-11 20:23:14 +08:00
border.Background = new SolidColorBrush(Colors.Red);
break;
2025-08-12 11:08:24 +08:00
case "QuickColorGreen":
2025-08-12 12:19:55 +08:00
case "QuickColorGreenSingle":
2025-08-31 11:43:52 +08:00
border.Background = new SolidColorBrush(Color.FromRgb(22, 163, 74));
2025-08-12 11:08:24 +08:00
break;
case "QuickColorPurple":
2025-08-12 12:19:55 +08:00
border.Background = new SolidColorBrush(Color.FromRgb(147, 51, 234));
2025-08-12 11:08:24 +08:00
break;
2025-08-11 20:23:14 +08:00
}
}
else
{
border.Background = new SolidColorBrush(Colors.Transparent);
}
2025-08-11 20:19:01 +08:00
}
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
private void SymbolIconSettings_Click(object sender, RoutedEventArgs e)
{
2025-07-28 14:40:44 +08:00
if (isOpeningOrHidingSettingsPane) return;
2025-05-25 09:29:48 +08:00
HideSubPanels();
BtnSettings_Click(null, null);
}
2025-08-31 11:43:52 +08:00
private async void SymbolIconScreenshot_MouseUp(object sender, MouseButtonEventArgs e)
{
2025-08-27 17:41:58 +08:00
HideSubPanelsImmediately();
await Task.Delay(50);
SaveScreenShotToDesktop();
}
2025-08-03 16:46:33 +08:00
private void ImageCountdownTimer_MouseUp(object sender, MouseButtonEventArgs e)
{
2025-05-25 09:29:48 +08:00
LeftUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
RightUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
2025-08-13 12:16:55 +08:00
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
2025-05-25 09:29:48 +08:00
2025-10-04 17:00:15 +08:00
// 参考老计时器的窗口置顶功能:在白板模式下停止窗口置顶
if (currentMode == 1) // 白板模式
{
Topmost = false;
}
var timerWindow = CountdownTimerWindow.CreateTimerWindow();
timerWindow.Show();
if (currentMode == 1) // 白板模式
{
timerWindow.Topmost = true;
}
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
private void OperatingGuideWindowIcon_MouseUp(object sender, MouseButtonEventArgs e)
{
2025-05-25 09:29:48 +08:00
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
2025-08-13 12:16:55 +08:00
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
2025-05-25 09:29:48 +08:00
new OperatingGuideWindow().Show();
}
2025-08-03 16:46:33 +08:00
private void SymbolIconRand_MouseUp(object sender, MouseButtonEventArgs e)
{
// 如果控件被隐藏,不处理事件
if (RandomDrawPanel.Visibility != Visibility.Visible) return;
2025-05-25 09:29:48 +08:00
LeftUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
RightUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
2025-08-13 12:16:55 +08:00
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
2025-05-25 09:29:48 +08:00
2025-10-31 12:11:02 +08:00
// 根据设置决定使用哪个点名窗口
if (Settings.RandSettings.UseNewRollCallUI)
{
// 使用新点名UI - 随机抽模式
new NewStyleRollCallWindow(Settings, false).ShowDialog();
}
else
{
// 使用默认的随机点名窗口
var randWindow = new RandWindow(Settings);
randWindow.Show();
2025-09-07 13:30:46 +08:00
2025-10-31 12:11:02 +08:00
// 使用延迟确保窗口完全显示后再强制置顶
randWindow.Dispatcher.BeginInvoke(new Action(() =>
2025-09-06 13:58:49 +08:00
{
try
{
// 强制激活窗口
randWindow.Activate();
randWindow.Focus();
2025-09-07 13:30:46 +08:00
2025-09-06 13:58:49 +08:00
// 设置置顶
randWindow.Topmost = true;
2025-09-07 13:30:46 +08:00
2025-09-06 13:58:49 +08:00
// 使用Win32 API强制置顶
var hwnd = new WindowInteropHelper(randWindow).Handle;
if (hwnd != IntPtr.Zero)
{
const int WS_EX_TOPMOST = 0x00000008;
const int GWL_EXSTYLE = -20;
const int SWP_NOMOVE = 0x0002;
const int SWP_NOSIZE = 0x0001;
const int SWP_SHOWWINDOW = 0x0040;
const int SWP_NOOWNERZORDER = 0x0200;
var HWND_TOPMOST = new IntPtr(-1);
// 设置窗口样式为置顶
int exStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
SetWindowLong(hwnd, GWL_EXSTYLE, exStyle | WS_EX_TOPMOST);
// 强制置顶
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOOWNERZORDER);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"强制置顶RandWindow失败: {ex.Message}", LogHelper.LogType.Error);
}
}), DispatcherPriority.Loaded);
2025-10-31 12:11:02 +08:00
}
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
public void CheckEraserTypeTab()
{
if (Settings.Canvas.EraserShapeType == 0)
{
2025-05-25 09:29:48 +08:00
CircleEraserTabButton.Background = new SolidColorBrush(Color.FromArgb(85, 59, 130, 246));
CircleEraserTabButton.Opacity = 1;
CircleEraserTabButtonText.FontWeight = FontWeights.Bold;
CircleEraserTabButtonText.Margin = new Thickness(2, 0.5, 0, 0);
CircleEraserTabButtonText.FontSize = 9.5;
CircleEraserTabButtonIndicator.Visibility = Visibility.Visible;
RectangleEraserTabButton.Background = new SolidColorBrush(Colors.Transparent);
RectangleEraserTabButton.Opacity = 0.75;
RectangleEraserTabButtonText.FontWeight = FontWeights.Normal;
RectangleEraserTabButtonText.FontSize = 9;
RectangleEraserTabButtonText.Margin = new Thickness(2, 1, 0, 0);
RectangleEraserTabButtonIndicator.Visibility = Visibility.Collapsed;
BoardCircleEraserTabButton.Background = new SolidColorBrush(Color.FromArgb(85, 59, 130, 246));
BoardCircleEraserTabButton.Opacity = 1;
BoardCircleEraserTabButtonText.FontWeight = FontWeights.Bold;
BoardCircleEraserTabButtonText.Margin = new Thickness(2, 0.5, 0, 0);
BoardCircleEraserTabButtonText.FontSize = 9.5;
BoardCircleEraserTabButtonIndicator.Visibility = Visibility.Visible;
BoardRectangleEraserTabButton.Background = new SolidColorBrush(Colors.Transparent);
BoardRectangleEraserTabButton.Opacity = 0.75;
BoardRectangleEraserTabButtonText.FontWeight = FontWeights.Normal;
BoardRectangleEraserTabButtonText.FontSize = 9;
BoardRectangleEraserTabButtonText.Margin = new Thickness(2, 1, 0, 0);
BoardRectangleEraserTabButtonIndicator.Visibility = Visibility.Collapsed;
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
RectangleEraserTabButton.Background = new SolidColorBrush(Color.FromArgb(85, 59, 130, 246));
RectangleEraserTabButton.Opacity = 1;
RectangleEraserTabButtonText.FontWeight = FontWeights.Bold;
RectangleEraserTabButtonText.Margin = new Thickness(2, 0.5, 0, 0);
RectangleEraserTabButtonText.FontSize = 9.5;
RectangleEraserTabButtonIndicator.Visibility = Visibility.Visible;
CircleEraserTabButton.Background = new SolidColorBrush(Colors.Transparent);
CircleEraserTabButton.Opacity = 0.75;
CircleEraserTabButtonText.FontWeight = FontWeights.Normal;
CircleEraserTabButtonText.FontSize = 9;
CircleEraserTabButtonText.Margin = new Thickness(2, 1, 0, 0);
CircleEraserTabButtonIndicator.Visibility = Visibility.Collapsed;
BoardRectangleEraserTabButton.Background = new SolidColorBrush(Color.FromArgb(85, 59, 130, 246));
BoardRectangleEraserTabButton.Opacity = 1;
BoardRectangleEraserTabButtonText.FontWeight = FontWeights.Bold;
BoardRectangleEraserTabButtonText.Margin = new Thickness(2, 0.5, 0, 0);
BoardRectangleEraserTabButtonText.FontSize = 9.5;
BoardRectangleEraserTabButtonIndicator.Visibility = Visibility.Visible;
BoardCircleEraserTabButton.Background = new SolidColorBrush(Colors.Transparent);
BoardCircleEraserTabButton.Opacity = 0.75;
BoardCircleEraserTabButtonText.FontWeight = FontWeights.Normal;
BoardCircleEraserTabButtonText.FontSize = 9;
BoardCircleEraserTabButtonText.Margin = new Thickness(2, 1, 0, 0);
BoardCircleEraserTabButtonIndicator.Visibility = Visibility.Collapsed;
}
}
2025-08-03 16:46:33 +08:00
private void SymbolIconRandOne_MouseUp(object sender, MouseButtonEventArgs e)
{
// 如果控件被隐藏,不处理事件
if (SingleDrawPanel.Visibility != Visibility.Visible) return;
2025-05-25 09:29:48 +08:00
LeftUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
RightUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
2025-08-13 12:16:55 +08:00
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
2025-05-25 09:29:48 +08:00
2025-09-13 12:08:45 +08:00
// 检查是否启用了外部点名功能
2025-08-03 16:46:33 +08:00
if (Settings.RandSettings.DirectCallCiRand)
{
try
{
2025-09-13 12:08:45 +08:00
string protocol = "";
switch (Settings.RandSettings.ExternalCallerType)
{
case 0: // ClassIsland点名
protocol = "classisland://plugins/IslandCaller/Simple/1";
break;
case 1: // SecRandom点名
protocol = "secrandom://direct_extraction";
break;
case 2: // NamePicker点名
protocol = "namepicker://";
break;
default:
protocol = "classisland://plugins/IslandCaller/Simple/1";
break;
}
2025-08-03 16:46:33 +08:00
Process.Start(new ProcessStartInfo
{
2025-09-13 12:08:45 +08:00
FileName = protocol,
2025-06-29 13:01:33 +08:00
UseShellExecute = true
});
}
2025-08-03 16:46:33 +08:00
catch (Exception ex)
{
2025-09-13 12:08:45 +08:00
MessageBox.Show("无法调用外部点名:" + ex.Message);
2025-08-03 16:46:33 +08:00
2025-10-31 12:11:02 +08:00
// 调用失败时回退到相应的点名窗口
if (Settings.RandSettings.UseNewRollCallUI)
{
new NewStyleRollCallWindow(Settings, true).ShowDialog(); // 单次抽模式
}
else
{
new RandWindow(Settings, true).ShowDialog();
}
2025-06-29 13:01:33 +08:00
}
2025-08-03 16:46:33 +08:00
}
else
{
2025-10-31 12:11:02 +08:00
// 根据设置决定使用哪个点名窗口
if (Settings.RandSettings.UseNewRollCallUI)
{
// 使用新点名UI - 单次抽模式
new NewStyleRollCallWindow(Settings, true).ShowDialog();
}
else
{
// 使用默认的随机点名窗口
new RandWindow(Settings, true).ShowDialog();
}
2025-06-29 13:01:33 +08:00
}
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
private void GridInkReplayButton_MouseUp(object sender, MouseButtonEventArgs e)
{
2025-06-09 11:49:42 +08:00
//if (lastBorderMouseDownObject != sender) return;
2025-05-25 09:29:48 +08:00
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
2025-08-13 12:16:55 +08:00
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
2025-05-25 09:29:48 +08:00
CollapseBorderDrawShape();
InkCanvasForInkReplay.Visibility = Visibility.Visible;
InkCanvasGridForInkReplay.Visibility = Visibility.Hidden;
InkCanvasGridForInkReplay.IsHitTestVisible = false;
FloatingbarUIForInkReplay.Visibility = Visibility.Hidden;
FloatingbarUIForInkReplay.IsHitTestVisible = false;
BlackboardUIGridForInkReplay.Visibility = Visibility.Hidden;
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
AnimationsHelper.ShowWithFadeIn(BorderInkReplayToolBox);
InkReplayPanelStatusText.Text = "正在重播墨迹...";
InkReplayPlayPauseBorder.Background = new SolidColorBrush(Colors.Transparent);
InkReplayPlayButtonImage.Visibility = Visibility.Collapsed;
InkReplayPauseButtonImage.Visibility = Visibility.Visible;
isStopInkReplay = false;
isPauseInkReplay = false;
isRestartInkReplay = false;
inkReplaySpeed = 1;
InkCanvasForInkReplay.Strokes.Clear();
var strokes = inkCanvas.Strokes.Clone();
if (inkCanvas.GetSelectedStrokes().Count != 0) strokes = inkCanvas.GetSelectedStrokes().Clone();
int k = 1, i = 0;
2025-08-03 16:46:33 +08:00
new Thread(() =>
{
2025-05-25 09:29:48 +08:00
isRestartInkReplay = true;
2025-08-03 16:46:33 +08:00
while (isRestartInkReplay)
{
2025-05-25 09:29:48 +08:00
isRestartInkReplay = false;
2025-08-03 16:46:33 +08:00
Application.Current.Dispatcher.Invoke(() =>
{
2025-05-25 09:29:48 +08:00
InkCanvasForInkReplay.Strokes.Clear();
});
2025-08-03 16:46:33 +08:00
foreach (var stroke in strokes)
{
2025-05-25 09:29:48 +08:00
if (isRestartInkReplay) break;
var stylusPoints = new StylusPointCollection();
if (stroke.StylusPoints.Count == 629) //圆或椭圆
{
Stroke s = null;
2025-08-03 16:46:33 +08:00
foreach (var stylusPoint in stroke.StylusPoints)
{
2025-05-25 09:29:48 +08:00
if (isRestartInkReplay) break;
2025-08-03 16:46:33 +08:00
while (isPauseInkReplay)
{
2025-05-25 09:29:48 +08:00
Thread.Sleep(10);
}
2025-08-03 16:46:33 +08:00
if (i++ >= 50)
{
2025-05-25 09:29:48 +08:00
i = 0;
Thread.Sleep((int)(10 / inkReplaySpeed));
if (isStopInkReplay) return;
}
2025-08-03 16:46:33 +08:00
Application.Current.Dispatcher.Invoke(() =>
{
try
{
2025-05-25 09:29:48 +08:00
InkCanvasForInkReplay.Strokes.Remove(s);
}
catch { }
stylusPoints.Add(stylusPoint);
s = new Stroke(stylusPoints.Clone());
s.DrawingAttributes = stroke.DrawingAttributes;
InkCanvasForInkReplay.Strokes.Add(s);
});
}
2025-08-03 16:46:33 +08:00
}
else
{
2025-05-25 09:29:48 +08:00
Stroke s = null;
2025-08-03 16:46:33 +08:00
foreach (var stylusPoint in stroke.StylusPoints)
{
2025-05-25 09:29:48 +08:00
if (isRestartInkReplay) break;
2025-08-03 16:46:33 +08:00
while (isPauseInkReplay)
{
2025-05-25 09:29:48 +08:00
Thread.Sleep(10);
}
2025-08-03 16:46:33 +08:00
if (i++ >= k)
{
2025-05-25 09:29:48 +08:00
i = 0;
Thread.Sleep((int)(10 / inkReplaySpeed));
if (isStopInkReplay) return;
}
2025-08-03 16:46:33 +08:00
Application.Current.Dispatcher.Invoke(() =>
{
try
{
2025-05-25 09:29:48 +08:00
InkCanvasForInkReplay.Strokes.Remove(s);
}
catch { }
stylusPoints.Add(stylusPoint);
s = new Stroke(stylusPoints.Clone());
s.DrawingAttributes = stroke.DrawingAttributes;
InkCanvasForInkReplay.Strokes.Add(s);
});
}
}
}
}
Thread.Sleep(100);
2025-08-03 16:46:33 +08:00
Application.Current.Dispatcher.Invoke(() =>
{
2025-05-25 09:29:48 +08:00
InkCanvasForInkReplay.Visibility = Visibility.Collapsed;
InkCanvasGridForInkReplay.Visibility = Visibility.Visible;
InkCanvasGridForInkReplay.IsHitTestVisible = true;
AnimationsHelper.HideWithFadeOut(BorderInkReplayToolBox);
FloatingbarUIForInkReplay.Visibility = Visibility.Visible;
FloatingbarUIForInkReplay.IsHitTestVisible = true;
BlackboardUIGridForInkReplay.Visibility = Visibility.Visible;
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
2025-09-20 12:38:22 +08:00
inkCanvas.IsHitTestVisible = true;
inkCanvas.IsManipulationEnabled = true;
2025-10-03 17:08:46 +08:00
2025-09-20 12:38:22 +08:00
if (inkCanvas.EditingMode == InkCanvasEditingMode.None)
{
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
}
2025-10-31 14:46:20 +08:00
ResetTouchStates();
2025-05-25 09:29:48 +08:00
});
}).Start();
}
2025-07-28 14:40:44 +08:00
private bool isStopInkReplay;
private bool isPauseInkReplay;
private bool isRestartInkReplay;
2025-05-25 09:29:48 +08:00
private double inkReplaySpeed = 1;
2025-08-03 16:46:33 +08:00
private void InkCanvasForInkReplay_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ClickCount == 2)
{
2025-05-25 09:29:48 +08:00
InkCanvasForInkReplay.Visibility = Visibility.Collapsed;
InkCanvasGridForInkReplay.Visibility = Visibility.Visible;
InkCanvasGridForInkReplay.IsHitTestVisible = true;
FloatingbarUIForInkReplay.Visibility = Visibility.Visible;
FloatingbarUIForInkReplay.IsHitTestVisible = true;
BlackboardUIGridForInkReplay.Visibility = Visibility.Visible;
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
AnimationsHelper.HideWithFadeOut(BorderInkReplayToolBox);
isStopInkReplay = true;
2025-09-20 12:38:22 +08:00
inkCanvas.IsHitTestVisible = true;
inkCanvas.IsManipulationEnabled = true;
2025-10-03 17:08:46 +08:00
2025-09-20 12:38:22 +08:00
if (inkCanvas.EditingMode == InkCanvasEditingMode.None)
{
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
}
2025-10-03 17:08:46 +08:00
2025-09-20 12:38:22 +08:00
ResetTouchStates();
2025-05-25 09:29:48 +08:00
}
}
2025-08-03 16:46:33 +08:00
private void InkReplayPlayPauseBorder_OnMouseDown(object sender, MouseButtonEventArgs e)
{
2025-05-25 09:29:48 +08:00
InkReplayPlayPauseBorder.Background = new SolidColorBrush(Color.FromArgb(34, 9, 9, 11));
}
private void InkReplayPlayPauseBorder_OnMouseUp(object sender, MouseButtonEventArgs e)
{
InkReplayPlayPauseBorder.Background = new SolidColorBrush(Colors.Transparent);
isPauseInkReplay = !isPauseInkReplay;
2025-08-03 16:46:33 +08:00
InkReplayPanelStatusText.Text = isPauseInkReplay ? "已暂停!" : "正在重播墨迹...";
InkReplayPlayButtonImage.Visibility = isPauseInkReplay ? Visibility.Visible : Visibility.Collapsed;
2025-05-25 09:29:48 +08:00
InkReplayPauseButtonImage.Visibility = !isPauseInkReplay ? Visibility.Visible : Visibility.Collapsed;
}
private void InkReplayStopButtonBorder_OnMouseDown(object sender, MouseButtonEventArgs e)
{
InkReplayStopButtonBorder.Background = new SolidColorBrush(Color.FromArgb(34, 9, 9, 11));
}
private void InkReplayStopButtonBorder_OnMouseUp(object sender, MouseButtonEventArgs e)
{
InkReplayStopButtonBorder.Background = new SolidColorBrush(Colors.Transparent);
InkCanvasForInkReplay.Visibility = Visibility.Collapsed;
InkCanvasGridForInkReplay.Visibility = Visibility.Visible;
InkCanvasGridForInkReplay.IsHitTestVisible = true;
FloatingbarUIForInkReplay.Visibility = Visibility.Visible;
FloatingbarUIForInkReplay.IsHitTestVisible = true;
BlackboardUIGridForInkReplay.Visibility = Visibility.Visible;
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
AnimationsHelper.HideWithFadeOut(BorderInkReplayToolBox);
isStopInkReplay = true;
}
private void InkReplayReplayButtonBorder_OnMouseDown(object sender, MouseButtonEventArgs e)
{
InkReplayReplayButtonBorder.Background = new SolidColorBrush(Color.FromArgb(34, 9, 9, 11));
}
private void InkReplayReplayButtonBorder_OnMouseUp(object sender, MouseButtonEventArgs e)
{
InkReplayReplayButtonBorder.Background = new SolidColorBrush(Colors.Transparent);
isRestartInkReplay = true;
isPauseInkReplay = false;
InkReplayPanelStatusText.Text = "正在重播墨迹...";
InkReplayPlayButtonImage.Visibility = Visibility.Collapsed;
InkReplayPauseButtonImage.Visibility = Visibility.Visible;
}
private void InkReplaySpeedButtonBorder_OnMouseDown(object sender, MouseButtonEventArgs e)
{
InkReplaySpeedButtonBorder.Background = new SolidColorBrush(Color.FromArgb(34, 9, 9, 11));
}
private void InkReplaySpeedButtonBorder_OnMouseUp(object sender, MouseButtonEventArgs e)
{
InkReplaySpeedButtonBorder.Background = new SolidColorBrush(Colors.Transparent);
inkReplaySpeed = inkReplaySpeed == 0.5 ? 1 :
inkReplaySpeed == 1 ? 2 :
inkReplaySpeed == 2 ? 4 :
inkReplaySpeed == 4 ? 8 : 0.5;
InkReplaySpeedTextBlock.Text = inkReplaySpeed + "x";
}
2025-08-03 16:46:33 +08:00
private void SymbolIconTools_MouseUp(object sender, MouseButtonEventArgs e)
{
2025-05-25 09:29:48 +08:00
if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel)
((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent);
if (sender == ToolsFloatingBarBtn && lastBorderMouseDownObject != ToolsFloatingBarBtn) return;
2025-08-03 16:46:33 +08:00
if (BorderTools.Visibility == Visibility.Visible)
{
2025-05-25 09:29:48 +08:00
AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
AnimationsHelper.HideWithSlideAndFade(PenPalette);
AnimationsHelper.HideWithSlideAndFade(BoardPenPalette);
AnimationsHelper.HideWithSlideAndFade(BorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardBorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardEraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
AnimationsHelper.HideWithSlideAndFade(BoardTwoFingerGestureBorder);
2025-08-13 12:16:55 +08:00
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
AnimationsHelper.HideWithSlideAndFade(PenPalette);
AnimationsHelper.HideWithSlideAndFade(BoardPenPalette);
AnimationsHelper.HideWithSlideAndFade(BorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardBorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardEraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
AnimationsHelper.HideWithSlideAndFade(BoardTwoFingerGestureBorder);
2025-08-13 12:16:55 +08:00
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
2025-05-25 09:29:48 +08:00
AnimationsHelper.ShowWithSlideFromBottomAndFade(BorderTools);
AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardBorderTools);
}
}
2025-07-28 14:40:44 +08:00
private bool isViewboxFloatingBarMarginAnimationRunning;
2025-05-25 09:29:48 +08:00
public async void ViewboxFloatingBarMarginAnimation(int MarginFromEdge,
2025-08-03 16:46:33 +08:00
bool PosXCaculatedWithTaskbarHeight = false)
{
2025-08-31 09:59:49 +08:00
// 新增:在白板模式下不执行浮动栏动画
if (currentMode == 1)
{
return;
}
2025-05-25 09:29:48 +08:00
if (MarginFromEdge == 60) MarginFromEdge = 55;
2025-08-03 16:46:33 +08:00
await Dispatcher.InvokeAsync(() =>
{
2025-08-31 09:54:13 +08:00
if (!Topmost)
2025-05-25 09:29:48 +08:00
MarginFromEdge = -60;
else
ViewboxFloatingBar.Visibility = Visibility.Visible;
isViewboxFloatingBarMarginAnimationRunning = true;
double dpiScaleX = 1, dpiScaleY = 1;
var source = PresentationSource.FromVisual(this);
2025-08-03 16:46:33 +08:00
if (source != null)
{
2025-05-25 09:29:48 +08:00
dpiScaleX = source.CompositionTarget.TransformToDevice.M11;
dpiScaleY = source.CompositionTarget.TransformToDevice.M22;
}
var windowHandle = new WindowInteropHelper(this).Handle;
2025-07-28 14:40:44 +08:00
var screen = Screen.FromHandle(windowHandle);
2025-05-25 09:29:48 +08:00
double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY;
2025-06-17 18:52:34 +08:00
// 仅计算Windows任务栏高度,不考虑其他程序对工作区的影响
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
2025-08-31 11:43:52 +08:00
2025-09-06 14:18:09 +08:00
// 使用更可靠的方法获取浮动栏宽度
double baseWidth = ViewboxFloatingBar.ActualWidth;
2025-09-07 13:30:46 +08:00
2025-09-06 14:18:09 +08:00
// 如果ActualWidth为0,尝试使用DesiredSize
if (baseWidth <= 0)
{
baseWidth = ViewboxFloatingBar.DesiredSize.Width;
}
2025-09-07 13:30:46 +08:00
2025-09-06 14:18:09 +08:00
// 如果仍然为0,使用RenderSize
if (baseWidth <= 0)
{
baseWidth = ViewboxFloatingBar.RenderSize.Width;
}
2025-09-07 13:30:46 +08:00
2025-09-06 14:18:09 +08:00
// 如果所有方法都失败,使用一个基于内容的估算值
if (baseWidth <= 0)
{
// 根据浮动栏内容估算宽度
baseWidth = 200; // 最小宽度
LogHelper.WriteLogToFile($"浮动栏宽度无法获取,使用估算值: {baseWidth}");
}
2025-09-07 13:30:46 +08:00
2025-09-06 13:58:49 +08:00
double floatingBarWidth = baseWidth * ViewboxFloatingBarScaleTransform.ScaleX;
2025-09-07 13:30:46 +08:00
2025-08-31 11:43:52 +08:00
2025-08-12 11:08:24 +08:00
// 如果快捷调色盘显示,确保有足够空间
2025-08-12 12:19:55 +08:00
if ((QuickColorPalettePanel != null && QuickColorPalettePanel.Visibility == Visibility.Visible) ||
(QuickColorPaletteSingleRowPanel != null && QuickColorPaletteSingleRowPanel.Visibility == Visibility.Visible))
2025-08-12 11:08:24 +08:00
{
2025-08-12 12:19:55 +08:00
// 根据显示模式调整宽度
if (Settings.Appearance.QuickColorPaletteDisplayMode == 0)
{
// 单行显示模式,自适应宽度,但需要足够空间显示6个颜色
floatingBarWidth = Math.Max(floatingBarWidth, 120 * ViewboxFloatingBarScaleTransform.ScaleX);
}
else
{
// 双行显示模式,宽度较大
2025-10-02 02:32:29 +08:00
floatingBarWidth = Math.Max(floatingBarWidth, 68 * ViewboxFloatingBarScaleTransform.ScaleX);
2025-08-12 12:19:55 +08:00
}
2025-08-12 11:08:24 +08:00
}
2025-08-31 11:43:52 +08:00
2025-08-12 11:08:24 +08:00
pos.X = (screenWidth - floatingBarWidth) / 2;
2025-05-25 09:29:48 +08:00
2025-08-31 09:54:13 +08:00
if (!PosXCaculatedWithTaskbarHeight)
2025-06-17 19:00:47 +08:00
{
2025-10-02 19:04:28 +08:00
// 如果任务栏高度为0(隐藏状态),则使用固定边距
2025-10-02 18:57:49 +08:00
if (toolbarHeight == 0)
2025-06-17 19:00:47 +08:00
{
2025-10-02 18:57:49 +08:00
pos.Y = screenHeight - MarginFromEdge * ViewboxFloatingBarScaleTransform.ScaleY;
2025-06-17 19:00:47 +08:00
}
else
{
2025-10-02 18:57:49 +08:00
pos.Y = screenHeight - MarginFromEdge * ViewboxFloatingBarScaleTransform.ScaleY;
2025-06-17 19:00:47 +08:00
}
}
2025-07-28 14:40:44 +08:00
else if (PosXCaculatedWithTaskbarHeight)
2025-06-17 19:00:47 +08:00
{
2025-10-02 19:04:28 +08:00
// 如果任务栏高度为0(隐藏状态),则使用固定高度
2025-10-02 18:57:49 +08:00
if (toolbarHeight == 0)
2025-06-17 19:00:47 +08:00
{
2025-10-02 18:57:49 +08:00
pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY -
3 * ViewboxFloatingBarScaleTransform.ScaleY;
2025-06-17 19:00:47 +08:00
}
else
{
2025-10-02 18:57:49 +08:00
pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY -
toolbarHeight - ViewboxFloatingBarScaleTransform.ScaleY * 3;
2025-06-17 19:00:47 +08:00
}
}
2025-05-25 09:29:48 +08:00
2025-08-03 16:46:33 +08:00
if (MarginFromEdge != -60)
{
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
{
if (pointPPT.X != -1 || pointPPT.Y != -1)
{
2025-05-25 09:29:48 +08:00
if (Math.Abs(pointPPT.Y - pos.Y) > 50)
pos = pointPPT;
else
pointPPT = pos;
}
}
2025-08-03 16:46:33 +08:00
else
{
if (pointDesktop.X != -1 || pointDesktop.Y != -1)
{
2025-05-25 09:29:48 +08:00
if (Math.Abs(pointDesktop.Y - pos.Y) > 50)
pos = pointDesktop;
else
pointDesktop = pos;
}
}
}
2025-08-03 16:46:33 +08:00
var marginAnimation = new ThicknessAnimation
{
2025-05-25 09:29:48 +08:00
Duration = TimeSpan.FromSeconds(0.35),
From = ViewboxFloatingBar.Margin,
To = new Thickness(pos.X, pos.Y, 0, -20)
};
marginAnimation.EasingFunction = new CircleEase();
ViewboxFloatingBar.BeginAnimation(MarginProperty, marginAnimation);
});
await Task.Delay(200);
2025-08-03 16:46:33 +08:00
await Dispatcher.InvokeAsync(() =>
{
2025-05-25 09:29:48 +08:00
ViewboxFloatingBar.Margin = new Thickness(pos.X, pos.Y, -2000, -200);
2025-08-31 09:54:13 +08:00
if (!Topmost) ViewboxFloatingBar.Visibility = Visibility.Hidden;
2025-05-25 09:29:48 +08:00
});
}
public async void PureViewboxFloatingBarMarginAnimationInDesktopMode()
{
2025-10-02 02:30:24 +08:00
// 在白板模式下不执行浮动栏动画
2025-08-31 09:59:49 +08:00
if (currentMode == 1)
{
return;
}
2025-08-03 16:46:33 +08:00
await Dispatcher.InvokeAsync(() =>
{
2025-05-25 09:29:48 +08:00
ViewboxFloatingBar.Visibility = Visibility.Visible;
isViewboxFloatingBarMarginAnimationRunning = true;
double dpiScaleX = 1, dpiScaleY = 1;
var source = PresentationSource.FromVisual(this);
if (source != null)
{
dpiScaleX = source.CompositionTarget.TransformToDevice.M11;
dpiScaleY = source.CompositionTarget.TransformToDevice.M22;
}
var windowHandle = new WindowInteropHelper(this).Handle;
2025-07-28 14:40:44 +08:00
var screen = Screen.FromHandle(windowHandle);
2025-05-25 09:29:48 +08:00
double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY;
2025-06-17 18:52:34 +08:00
// 仅计算Windows任务栏高度,不考虑其他程序对工作区的影响
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
2025-08-31 11:43:52 +08:00
2025-09-06 14:18:09 +08:00
double baseWidth = ViewboxFloatingBar.ActualWidth;
2025-09-07 13:30:46 +08:00
2025-09-06 14:18:09 +08:00
// 如果ActualWidth为0,尝试使用DesiredSize
if (baseWidth <= 0)
{
baseWidth = ViewboxFloatingBar.DesiredSize.Width;
}
2025-09-07 13:30:46 +08:00
2025-09-06 14:18:09 +08:00
// 如果仍然为0,使用RenderSize
if (baseWidth <= 0)
{
baseWidth = ViewboxFloatingBar.RenderSize.Width;
}
2025-09-07 13:30:46 +08:00
2025-09-06 14:18:09 +08:00
// 如果所有方法都失败,使用一个基于内容的估算值
if (baseWidth <= 0)
{
// 根据浮动栏内容估算宽度
baseWidth = 200; // 最小宽度
LogHelper.WriteLogToFile($"浮动栏宽度无法获取,使用估算值: {baseWidth}");
}
2025-09-07 13:30:46 +08:00
2025-09-06 13:58:49 +08:00
double floatingBarWidth = baseWidth * ViewboxFloatingBarScaleTransform.ScaleX;
2025-09-07 13:30:46 +08:00
2025-08-31 11:43:52 +08:00
2025-08-12 11:08:24 +08:00
// 如果快捷调色盘显示,确保有足够空间
2025-08-12 12:19:55 +08:00
if ((QuickColorPalettePanel != null && QuickColorPalettePanel.Visibility == Visibility.Visible) ||
(QuickColorPaletteSingleRowPanel != null && QuickColorPaletteSingleRowPanel.Visibility == Visibility.Visible))
2025-08-12 11:08:24 +08:00
{
2025-08-12 12:19:55 +08:00
// 根据显示模式调整宽度
if (Settings.Appearance.QuickColorPaletteDisplayMode == 0)
{
// 单行显示模式,自适应宽度,但需要足够空间显示6个颜色
floatingBarWidth = Math.Max(floatingBarWidth, 120 * ViewboxFloatingBarScaleTransform.ScaleX);
}
else
{
// 双行显示模式,宽度较大
2025-10-02 02:32:29 +08:00
floatingBarWidth = Math.Max(floatingBarWidth, 68 * ViewboxFloatingBarScaleTransform.ScaleX);
2025-08-12 12:19:55 +08:00
}
2025-08-12 11:08:24 +08:00
}
2025-08-31 11:43:52 +08:00
2025-08-12 11:08:24 +08:00
pos.X = (screenWidth - floatingBarWidth) / 2;
2025-05-25 09:29:48 +08:00
2025-10-02 02:30:24 +08:00
// 如果任务栏高度为0,则使用固定边距
2025-06-17 19:00:47 +08:00
if (toolbarHeight == 0)
{
2025-08-03 16:46:33 +08:00
pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY -
2025-06-17 19:00:47 +08:00
3 * ViewboxFloatingBarScaleTransform.ScaleY;
2025-07-28 14:40:44 +08:00
LogHelper.WriteLogToFile($"任务栏隐藏,使用固定高度: {ViewboxFloatingBar.ActualHeight}");
2025-06-17 19:00:47 +08:00
}
else
{
pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY -
toolbarHeight - ViewboxFloatingBarScaleTransform.ScaleY * 3;
}
2025-05-25 09:29:48 +08:00
if (pointDesktop.X != -1 || pointDesktop.Y != -1) pointDesktop = pos;
var marginAnimation = new ThicknessAnimation
{
Duration = TimeSpan.FromSeconds(0.35),
From = ViewboxFloatingBar.Margin,
To = new Thickness(pos.X, pos.Y, 0, -20)
};
marginAnimation.EasingFunction = new CircleEase();
ViewboxFloatingBar.BeginAnimation(MarginProperty, marginAnimation);
});
await Task.Delay(349);
2025-08-03 16:46:33 +08:00
await Dispatcher.InvokeAsync(() =>
{
2025-05-25 09:29:48 +08:00
ViewboxFloatingBar.Margin = new Thickness(pos.X, pos.Y, -2000, -200);
});
}
public async void PureViewboxFloatingBarMarginAnimationInPPTMode()
{
2025-08-31 09:59:49 +08:00
// 新增:在白板模式下不执行浮动栏动画
if (currentMode == 1)
{
return;
}
2025-08-03 16:46:33 +08:00
await Dispatcher.InvokeAsync(() =>
{
2025-05-25 09:29:48 +08:00
ViewboxFloatingBar.Visibility = Visibility.Visible;
isViewboxFloatingBarMarginAnimationRunning = true;
double dpiScaleX = 1, dpiScaleY = 1;
var source = PresentationSource.FromVisual(this);
if (source != null)
{
dpiScaleX = source.CompositionTarget.TransformToDevice.M11;
dpiScaleY = source.CompositionTarget.TransformToDevice.M22;
}
var windowHandle = new WindowInteropHelper(this).Handle;
2025-07-28 14:40:44 +08:00
var screen = Screen.FromHandle(windowHandle);
2025-05-25 09:29:48 +08:00
double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY;
2025-06-17 18:52:34 +08:00
// 仅计算Windows任务栏高度,不考虑其他程序对工作区的影响
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
2025-08-31 11:43:52 +08:00
2025-08-12 11:08:24 +08:00
// 计算浮动栏位置,考虑快捷调色盘的显示状态
2025-09-06 14:18:09 +08:00
// 使用更可靠的方法获取浮动栏宽度
double baseWidth = ViewboxFloatingBar.ActualWidth;
2025-09-07 13:30:46 +08:00
2025-09-06 14:18:09 +08:00
// 如果ActualWidth为0,尝试使用DesiredSize
if (baseWidth <= 0)
{
baseWidth = ViewboxFloatingBar.DesiredSize.Width;
}
2025-09-07 13:30:46 +08:00
2025-09-06 14:18:09 +08:00
// 如果仍然为0,使用RenderSize
if (baseWidth <= 0)
{
baseWidth = ViewboxFloatingBar.RenderSize.Width;
}
2025-09-07 13:30:46 +08:00
2025-09-06 14:18:09 +08:00
// 如果所有方法都失败,使用一个基于内容的估算值
if (baseWidth <= 0)
{
// 根据浮动栏内容估算宽度
baseWidth = 200; // 最小宽度
LogHelper.WriteLogToFile($"浮动栏宽度无法获取,使用估算值: {baseWidth}");
}
2025-09-07 13:30:46 +08:00
2025-09-06 13:58:49 +08:00
double floatingBarWidth = baseWidth * ViewboxFloatingBarScaleTransform.ScaleX;
2025-09-07 13:30:46 +08:00
2025-08-31 11:43:52 +08:00
2025-08-12 11:08:24 +08:00
// 如果快捷调色盘显示,确保有足够空间
2025-08-12 12:19:55 +08:00
if ((QuickColorPalettePanel != null && QuickColorPalettePanel.Visibility == Visibility.Visible) ||
(QuickColorPaletteSingleRowPanel != null && QuickColorPaletteSingleRowPanel.Visibility == Visibility.Visible))
2025-08-12 11:08:24 +08:00
{
2025-08-12 12:19:55 +08:00
// 根据显示模式调整宽度
if (Settings.Appearance.QuickColorPaletteDisplayMode == 0)
{
// 单行显示模式,自适应宽度,但需要足够空间显示6个颜色
floatingBarWidth = Math.Max(floatingBarWidth, 120 * ViewboxFloatingBarScaleTransform.ScaleX);
}
else
{
// 双行显示模式,宽度较大
2025-10-02 02:32:29 +08:00
floatingBarWidth = Math.Max(floatingBarWidth, 68 * ViewboxFloatingBarScaleTransform.ScaleX);
2025-08-12 12:19:55 +08:00
}
2025-08-12 11:08:24 +08:00
}
2025-08-31 11:43:52 +08:00
2025-08-12 11:08:24 +08:00
pos.X = (screenWidth - floatingBarWidth) / 2;
2025-05-25 09:29:48 +08:00
2025-06-10 18:00:31 +08:00
pos.Y = screenHeight - 55 * ViewboxFloatingBarScaleTransform.ScaleY;
2025-05-25 09:29:48 +08:00
if (pointPPT.X != -1 || pointPPT.Y != -1)
{
pointPPT = pos;
}
var marginAnimation = new ThicknessAnimation
{
Duration = TimeSpan.FromSeconds(0.35),
From = ViewboxFloatingBar.Margin,
To = new Thickness(pos.X, pos.Y, 0, -20)
};
marginAnimation.EasingFunction = new CircleEase();
ViewboxFloatingBar.BeginAnimation(MarginProperty, marginAnimation);
});
await Task.Delay(349);
2025-08-03 16:46:33 +08:00
await Dispatcher.InvokeAsync(() =>
{
2025-05-25 09:29:48 +08:00
ViewboxFloatingBar.Margin = new Thickness(pos.X, pos.Y, -2000, -200);
});
}
2025-08-23 21:39:00 +08:00
internal async void CursorIcon_Click(object sender, RoutedEventArgs e)
2025-08-03 16:46:33 +08:00
{
2025-05-25 09:29:48 +08:00
if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel)
((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent);
2025-08-03 16:46:33 +08:00
if (sender == Cursor_Icon && lastBorderMouseDownObject != Cursor_Icon) return;
2025-07-19 13:35:28 +08:00
// 禁用高级橡皮擦系统
2025-10-01 14:13:09 +08:00
DisableEraserOverlay();
2025-08-30 11:20:53 +08:00
SetCurrentToolMode(InkCanvasEditingMode.None);
2025-09-07 13:30:46 +08:00
2025-09-06 17:12:25 +08:00
UpdateCurrentToolMode("cursor");
2025-08-30 11:20:53 +08:00
2025-09-06 15:36:40 +08:00
SetFloatingBarHighlightPosition("cursor");
2025-05-25 09:29:48 +08:00
// 切换前自动截图保存墨迹
if (inkCanvas.Strokes.Count > 0 &&
2025-08-03 16:46:33 +08:00
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber)
{
2025-05-25 09:29:48 +08:00
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
2025-07-29 01:15:32 +08:00
{
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
var presentationName = _pptManager?.GetPresentationName() ?? "";
SaveScreenShot(true, $"{presentationName}/{currentSlide}_{DateTime.Now:HH-mm-ss}");
}
2025-05-25 09:29:48 +08:00
else SaveScreenShot(true);
}
2025-08-03 16:46:33 +08:00
if (BtnPPTSlideShowEnd.Visibility != Visibility.Visible)
{
if (Settings.Canvas.HideStrokeWhenSelecting)
{
2025-05-25 09:29:48 +08:00
inkCanvas.Visibility = Visibility.Collapsed;
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
inkCanvas.IsHitTestVisible = false;
inkCanvas.Visibility = Visibility.Visible;
}
}
2025-08-03 16:46:33 +08:00
else
{
if (Settings.PowerPointSettings.IsShowStrokeOnSelectInPowerPoint)
{
2025-05-25 09:29:48 +08:00
inkCanvas.Visibility = Visibility.Visible;
inkCanvas.IsHitTestVisible = true;
}
2025-08-03 16:46:33 +08:00
else
{
if (Settings.Canvas.HideStrokeWhenSelecting)
{
2025-05-25 09:29:48 +08:00
inkCanvas.Visibility = Visibility.Collapsed;
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
inkCanvas.IsHitTestVisible = false;
inkCanvas.Visibility = Visibility.Visible;
}
}
}
GridTransparencyFakeBackground.Opacity = 0;
GridTransparencyFakeBackground.Background = Brushes.Transparent;
GridBackgroundCoverHolder.Visibility = Visibility.Collapsed;
inkCanvas.Select(new StrokeCollection());
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
2025-08-03 16:46:33 +08:00
if (currentMode != 0)
{
2025-05-25 09:29:48 +08:00
SaveStrokes();
2025-07-29 01:31:21 +08:00
RestoreStrokes(true);
2025-05-25 09:29:48 +08:00
}
if (BtnSwitchTheme.Content.ToString() == "浅色")
BtnSwitch.Content = "黑板";
else
BtnSwitch.Content = "白板";
StackPanelPPTButtons.Visibility = Visibility.Visible;
BtnHideInkCanvas.Content = "显示\n画板";
CheckEnableTwoFingerGestureBtnVisibility(false);
StackPanelCanvasControls.Visibility = Visibility.Collapsed;
2025-08-31 11:43:52 +08:00
2025-08-12 11:08:24 +08:00
// 在鼠标模式下隐藏快捷调色盘
if (QuickColorPalettePanel != null)
{
QuickColorPalettePanel.Visibility = Visibility.Collapsed;
}
2025-08-12 12:19:55 +08:00
if (QuickColorPaletteSingleRowPanel != null)
{
QuickColorPaletteSingleRowPanel.Visibility = Visibility.Collapsed;
}
2025-05-25 09:29:48 +08:00
2025-08-03 16:46:33 +08:00
if (!isFloatingBarFolded)
{
2025-05-25 09:29:48 +08:00
HideSubPanels("cursor", true);
await Task.Delay(50);
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
ViewboxFloatingBarMarginAnimation(60);
else
ViewboxFloatingBarMarginAnimation(100, true);
}
}
2025-08-23 21:39:00 +08:00
internal void PenIcon_Click(object sender, RoutedEventArgs e)
2025-08-03 16:46:33 +08:00
{
2025-05-25 09:29:48 +08:00
if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel)
((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent);
if (sender == Pen_Icon && lastBorderMouseDownObject != Pen_Icon) return;
2025-09-07 00:49:10 +08:00
// 如果当前有选中的图片元素,先取消选中
if (currentSelectedElement != null)
{
UnselectElement(currentSelectedElement);
currentSelectedElement = null;
}
2025-07-19 13:35:28 +08:00
// 禁用高级橡皮擦系统
2025-10-03 17:08:46 +08:00
DisableEraserOverlay();
2025-07-19 13:35:28 +08:00
SetFloatingBarHighlightPosition("pen");
2025-05-25 09:29:48 +08:00
// 记录当前是否已经是批注模式且是否为高光显示模式
bool wasInInkMode = inkCanvas.EditingMode == InkCanvasEditingMode.Ink;
bool wasHighlighter = drawingAttributes.IsHighlighter;
2025-09-20 11:55:50 +08:00
if (drawingShapeMode != 0 && !isLongPressSelected)
2025-08-10 11:58:58 +08:00
{
return;
}
2025-08-03 16:46:33 +08:00
if (Pen_Icon.Background == null || StackPanelCanvasControls.Visibility == Visibility.Collapsed)
{
2025-09-20 11:55:50 +08:00
if (isLongPressSelected)
{
drawingShapeMode = 0;
isLongPressSelected = false;
ResetAllShapeButtonsOpacity();
}
2025-08-30 11:20:53 +08:00
// 使用集中化的工具模式切换方法
SetCurrentToolMode(InkCanvasEditingMode.Ink);
2025-09-07 13:30:46 +08:00
2025-09-06 17:12:25 +08:00
// 更新模式缓存
UpdateCurrentToolMode("pen");
2025-05-25 09:29:48 +08:00
GridTransparencyFakeBackground.Opacity = 1;
GridTransparencyFakeBackground.Background = new SolidColorBrush(StringToColor("#01FFFFFF"));
inkCanvas.IsHitTestVisible = true;
inkCanvas.Visibility = Visibility.Visible;
GridBackgroundCoverHolder.Visibility = Visibility.Visible;
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
/*if (forceEraser && currentMode == 0)
BtnColorRed_Click(sender, null);*/
2025-08-03 16:46:33 +08:00
if (GridBackgroundCover.Visibility == Visibility.Collapsed)
{
2025-05-25 09:29:48 +08:00
if (BtnSwitchTheme.Content.ToString() == "浅色")
BtnSwitch.Content = "黑板";
else
BtnSwitch.Content = "白板";
StackPanelPPTButtons.Visibility = Visibility.Visible;
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
BtnSwitch.Content = "屏幕";
StackPanelPPTButtons.Visibility = Visibility.Collapsed;
}
BtnHideInkCanvas.Content = "隐藏\n画板";
StackPanelCanvasControls.Visibility = Visibility.Visible;
//AnimationsHelper.ShowWithSlideFromLeftAndFade(StackPanelCanvasControls);
CheckEnableTwoFingerGestureBtnVisibility(true);
2025-08-30 11:20:53 +08:00
// 使用集中化的工具模式切换方法
SetCurrentToolMode(InkCanvasEditingMode.Ink);
2025-09-07 13:30:46 +08:00
2025-09-06 17:12:25 +08:00
// 更新模式缓存
UpdateCurrentToolMode("pen");
2025-08-31 11:43:52 +08:00
2025-08-12 11:08:24 +08:00
// 在批注模式下显示快捷调色盘(如果设置中启用了)
2025-08-12 12:19:55 +08:00
if (Settings.Appearance.IsShowQuickColorPalette && QuickColorPalettePanel != null && QuickColorPaletteSingleRowPanel != null)
2025-08-12 11:08:24 +08:00
{
2025-08-12 12:19:55 +08:00
// 根据显示模式选择显示哪个面板
if (Settings.Appearance.QuickColorPaletteDisplayMode == 0)
{
// 单行显示模式
QuickColorPalettePanel.Visibility = Visibility.Collapsed;
QuickColorPaletteSingleRowPanel.Visibility = Visibility.Visible;
}
else
{
// 双行显示模式
QuickColorPalettePanel.Visibility = Visibility.Visible;
QuickColorPaletteSingleRowPanel.Visibility = Visibility.Collapsed;
}
2025-08-12 11:08:24 +08:00
}
forceEraser = false;
forcePointEraser = false;
drawingShapeMode = 0;
2025-08-31 11:43:52 +08:00
2025-08-23 18:51:16 +08:00
// 保持之前的笔类型状态,而不是强制重置
if (!wasHighlighter)
{
penType = 0;
drawingAttributes.IsHighlighter = false;
drawingAttributes.StylusTip = StylusTip.Ellipse;
}
// 如果之前是荧光笔模式,则保持荧光笔属性
else if (penType == 1)
{
drawingAttributes.IsHighlighter = true;
drawingAttributes.StylusTip = StylusTip.Rectangle;
drawingAttributes.Width = Settings.Canvas.HighlighterWidth / 2;
drawingAttributes.Height = Settings.Canvas.HighlighterWidth;
}
2025-05-25 09:29:48 +08:00
ColorSwitchCheck();
HideSubPanels("pen", true);
}
2025-08-03 16:46:33 +08:00
else
{
if (wasInInkMode)
{
if (forceEraser)
{
2025-08-23 18:51:16 +08:00
// 从橡皮擦模式切换过来,保持之前的笔类型状态
forceEraser = false;
forcePointEraser = false;
drawingShapeMode = 0;
2025-08-31 11:43:52 +08:00
2025-08-23 18:51:16 +08:00
// 保持之前的笔类型状态,而不是强制重置
if (!wasHighlighter)
{
penType = 0;
drawingAttributes.IsHighlighter = false;
drawingAttributes.StylusTip = StylusTip.Ellipse;
}
// 如果之前是荧光笔模式,则保持荧光笔属性
else if (penType == 1)
{
drawingAttributes.IsHighlighter = true;
drawingAttributes.StylusTip = StylusTip.Rectangle;
drawingAttributes.Width = Settings.Canvas.HighlighterWidth / 2;
drawingAttributes.Height = Settings.Canvas.HighlighterWidth;
}
// 在非白板模式下,从线擦切换到批注时不直接弹出子面板
2025-08-03 16:46:33 +08:00
if (currentMode != 1)
{
HideSubPanels("pen", true);
return;
}
}
2025-08-03 16:46:33 +08:00
if (PenPalette.Visibility == Visibility.Visible)
{
2025-05-25 09:29:48 +08:00
AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
AnimationsHelper.HideWithSlideAndFade(PenPalette);
AnimationsHelper.HideWithSlideAndFade(BoardPenPalette);
AnimationsHelper.HideWithSlideAndFade(BorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardBorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardEraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
AnimationsHelper.HideWithSlideAndFade(BoardTwoFingerGestureBorder);
2025-08-13 12:16:55 +08:00
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
AnimationsHelper.HideWithSlideAndFade(BorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardBorderDrawShape);
AnimationsHelper.HideWithSlideAndFade(BoardEraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(BorderTools);
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
AnimationsHelper.HideWithSlideAndFade(BoardTwoFingerGestureBorder);
2025-08-13 12:16:55 +08:00
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
2025-05-25 09:29:48 +08:00
AnimationsHelper.ShowWithSlideFromBottomAndFade(PenPalette);
AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardPenPalette);
}
}
2025-08-03 16:46:33 +08:00
else
{
2025-07-21 16:00:31 +08:00
// 切换到批注模式时,确保保存当前图片信息
2025-08-03 16:46:33 +08:00
if (currentMode != 0)
{
2025-07-21 16:00:31 +08:00
SaveStrokes();
}
2025-08-30 11:20:53 +08:00
// 使用集中化的工具模式切换方法
SetCurrentToolMode(InkCanvasEditingMode.Ink);
2025-09-07 13:30:46 +08:00
2025-09-06 17:12:25 +08:00
// 更新模式缓存
UpdateCurrentToolMode("pen");
forceEraser = false;
forcePointEraser = false;
drawingShapeMode = 0;
2025-08-31 11:43:52 +08:00
2025-08-23 18:51:16 +08:00
// 保持之前的笔类型状态,而不是强制重置
if (!wasHighlighter)
{
penType = 0;
drawingAttributes.IsHighlighter = false;
drawingAttributes.StylusTip = StylusTip.Ellipse;
}
// 如果之前是荧光笔模式,则保持荧光笔属性
else if (penType == 1)
{
drawingAttributes.IsHighlighter = true;
drawingAttributes.StylusTip = StylusTip.Rectangle;
drawingAttributes.Width = Settings.Canvas.HighlighterWidth / 2;
drawingAttributes.Height = Settings.Canvas.HighlighterWidth;
}
2025-05-25 09:29:48 +08:00
ColorSwitchCheck();
HideSubPanels("pen", true);
}
}
2025-08-31 11:43:52 +08:00
2025-08-24 11:47:39 +08:00
forceEraser = false;
forcePointEraser = false;
drawingShapeMode = 0;
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
private void ColorThemeSwitch_MouseUp(object sender, RoutedEventArgs e)
{
2025-05-25 09:29:48 +08:00
isUselightThemeColor = !isUselightThemeColor;
if (currentMode == 0) isDesktopUselightThemeColor = isUselightThemeColor;
CheckColorTheme();
}
2025-08-23 21:39:00 +08:00
internal void EraserIcon_Click(object sender, RoutedEventArgs e)
2025-08-03 16:46:33 +08:00
{
2025-07-18 17:59:17 +08:00
EnterMultiTouchModeIfNeeded();
2025-07-18 16:12:04 +08:00
bool isAlreadyEraser = inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint;
forceEraser = false;
2025-05-25 09:29:48 +08:00
forcePointEraser = true;
2025-07-18 16:12:04 +08:00
drawingShapeMode = 0;
2025-07-19 13:35:28 +08:00
2025-07-21 16:00:31 +08:00
// 切换到橡皮擦模式时,确保保存当前图片信息
2025-08-03 16:46:33 +08:00
if (!isAlreadyEraser && currentMode != 0)
{
2025-07-21 16:00:31 +08:00
SaveStrokes();
}
2025-09-20 12:03:30 +08:00
if (!isAlreadyEraser)
{
ResetTouchStates();
}
2025-07-19 13:35:28 +08:00
// 启用新的高级橡皮擦系统
2025-10-03 17:08:46 +08:00
EnableEraserOverlay();
2025-07-21 16:00:31 +08:00
2025-07-19 13:35:28 +08:00
// 使用新的高级橡皮擦系统
2025-08-30 11:20:53 +08:00
// 使用集中化的工具模式切换方法
SetCurrentToolMode(InkCanvasEditingMode.EraseByPoint);
2025-09-07 13:30:46 +08:00
2025-09-06 17:12:25 +08:00
// 更新模式缓存
UpdateCurrentToolMode("eraser");
2025-09-07 13:30:46 +08:00
2025-07-19 13:35:28 +08:00
ApplyAdvancedEraserShape(); // 使用新的橡皮擦形状应用方法
2025-07-18 16:12:04 +08:00
SetCursorBasedOnEditingMode(inkCanvas);
HideSubPanels("eraser"); // 高亮橡皮按钮
2025-10-03 17:08:46 +08:00
Trace.WriteLine($"Eraser: Eraser button clicked, current size: {eraserWidth}, circle: {isEraserCircleShape}");
2025-07-19 13:35:28 +08:00
2025-08-03 16:46:33 +08:00
if (isAlreadyEraser)
{
2025-07-18 16:12:04 +08:00
// 已是橡皮状态,再次点击才弹出/收起面板
2025-08-03 16:46:33 +08:00
if (EraserSizePanel.Visibility == Visibility.Collapsed)
{
2025-05-25 09:29:48 +08:00
AnimationsHelper.ShowWithSlideFromBottomAndFade(EraserSizePanel);
2025-07-18 16:12:04 +08:00
if (BoardEraserSizePanel != null)
AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardEraserSizePanel);
2025-08-03 16:46:33 +08:00
}
else
{
2025-05-25 09:29:48 +08:00
AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
2025-07-18 16:12:04 +08:00
if (BoardEraserSizePanel != null)
AnimationsHelper.HideWithSlideAndFade(BoardEraserSizePanel);
2025-05-25 09:29:48 +08:00
}
}
}
2025-06-19 11:25:15 +08:00
2025-08-03 16:46:33 +08:00
private void BoardEraserIcon_Click(object sender, RoutedEventArgs e)
{
2025-07-18 17:59:17 +08:00
EnterMultiTouchModeIfNeeded();
2025-07-18 16:12:04 +08:00
bool isAlreadyEraser = inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint;
forceEraser = false;
forcePointEraser = true;
drawingShapeMode = 0;
2025-07-19 13:35:28 +08:00
// 启用新的高级橡皮擦系统
2025-10-03 17:08:46 +08:00
EnableEraserOverlay();
2025-08-03 16:46:33 +08:00
2025-07-19 13:35:28 +08:00
// 使用新的高级橡皮擦系统
2025-08-30 11:20:53 +08:00
// 使用集中化的工具模式切换方法
SetCurrentToolMode(InkCanvasEditingMode.EraseByPoint);
2025-09-07 13:30:46 +08:00
2025-09-06 17:12:25 +08:00
// 更新模式缓存
UpdateCurrentToolMode("eraser");
2025-09-07 13:30:46 +08:00
2025-07-19 13:35:28 +08:00
ApplyAdvancedEraserShape(); // 使用新的橡皮擦形状应用方法
2025-07-18 16:12:04 +08:00
SetCursorBasedOnEditingMode(inkCanvas);
HideSubPanels("eraser"); // 高亮橡皮按钮
2025-07-19 13:35:28 +08:00
2025-08-03 16:46:33 +08:00
if (isAlreadyEraser)
{
2025-07-18 16:12:04 +08:00
// 已是橡皮状态,再次点击才弹出/收起面板
2025-08-03 16:46:33 +08:00
if (BoardEraserSizePanel != null && BoardEraserSizePanel.Visibility == Visibility.Collapsed)
{
2025-07-18 16:12:04 +08:00
AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardEraserSizePanel);
AnimationsHelper.ShowWithSlideFromBottomAndFade(EraserSizePanel);
2025-08-03 16:46:33 +08:00
}
else
{
2025-07-18 16:12:04 +08:00
if (BoardEraserSizePanel != null)
AnimationsHelper.HideWithSlideAndFade(BoardEraserSizePanel);
AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
}
2025-06-19 11:25:15 +08:00
}
}
2025-05-25 09:29:48 +08:00
2025-08-03 16:46:33 +08:00
private void EraserIconByStrokes_Click(object sender, RoutedEventArgs e)
{
2025-07-18 17:59:17 +08:00
EnterMultiTouchModeIfNeeded();
2025-05-25 09:29:48 +08:00
if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel)
((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent);
if (sender == EraserByStrokes_Icon && lastBorderMouseDownObject != EraserByStrokes_Icon) return;
// 禁用高级橡皮擦系统
2025-10-01 14:13:09 +08:00
DisableEraserOverlay();
2025-07-06 21:09:01 +08:00
forceEraser = true;
2025-05-25 09:29:48 +08:00
forcePointEraser = false;
inkCanvas.EraserShape = new EllipseStylusShape(5, 5);
2025-08-30 11:20:53 +08:00
// 使用集中化的工具模式切换方法
SetCurrentToolMode(InkCanvasEditingMode.EraseByStroke);
2025-09-07 13:30:46 +08:00
2025-09-06 17:12:25 +08:00
// 更新模式缓存
UpdateCurrentToolMode("eraserByStrokes");
2025-09-07 13:30:46 +08:00
2025-05-25 09:29:48 +08:00
drawingShapeMode = 0;
2025-10-31 14:46:20 +08:00
// 这样从线擦切换回批注时,可以恢复之前的荧光笔状态
// penType 和 drawingAttributes 的状态将在 PenIcon_Click 中根据 wasHighlighter 来恢复
2025-05-25 09:29:48 +08:00
inkCanvas_EditingModeChanged(inkCanvas, null);
2025-10-31 14:46:20 +08:00
CancelSingleFingerDragMode();
2025-05-25 09:29:48 +08:00
HideSubPanels("eraserByStrokes");
2025-08-24 11:47:39 +08:00
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
private void CursorWithDelIcon_Click(object sender, RoutedEventArgs e)
{
2025-05-25 09:29:48 +08:00
if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel)
((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent);
if (sender == CursorWithDelFloatingBarBtn && lastBorderMouseDownObject != CursorWithDelFloatingBarBtn) return;
SymbolIconDelete_MouseUp(sender, null);
CursorIcon_Click(null, null);
}
2025-08-11 20:19:01 +08:00
// 快捷调色盘事件处理方法
private void QuickColorWhite_Click(object sender, RoutedEventArgs e)
{
SetQuickColor(Colors.White);
}
private void QuickColorOrange_Click(object sender, RoutedEventArgs e)
{
2025-08-31 11:43:52 +08:00
SetQuickColor(Color.FromRgb(251, 150, 80)); // 橙色
2025-08-11 20:19:01 +08:00
}
private void QuickColorYellow_Click(object sender, RoutedEventArgs e)
{
SetQuickColor(Colors.Yellow);
}
private void QuickColorBlack_Click(object sender, RoutedEventArgs e)
{
SetQuickColor(Colors.Black);
}
private void QuickColorBlue_Click(object sender, RoutedEventArgs e)
{
2025-08-12 12:19:55 +08:00
SetQuickColor(Color.FromRgb(37, 99, 235)); // 蓝色
2025-08-11 20:19:01 +08:00
}
private void QuickColorRed_Click(object sender, RoutedEventArgs e)
{
SetQuickColor(Colors.Red);
}
2025-08-31 11:43:52 +08:00
private void QuickColorGreen_Click(object sender, RoutedEventArgs e)
2025-08-12 11:08:24 +08:00
{
2025-08-12 12:19:55 +08:00
SetQuickColor(Color.FromRgb(22, 163, 74));
2025-08-12 11:08:24 +08:00
}
private void QuickColorPurple_Click(object sender, RoutedEventArgs e)
{
2025-08-31 11:43:52 +08:00
SetQuickColor(Color.FromRgb(147, 51, 234));
2025-08-12 11:08:24 +08:00
}
2025-08-11 20:19:01 +08:00
private void SetQuickColor(Color color)
{
// 确保当前处于批注模式
if (inkCanvas.EditingMode != InkCanvasEditingMode.Ink)
{
PenIcon_Click(null, null);
}
// 设置画笔颜色
drawingAttributes.Color = color;
inkCanvas.DefaultDrawingAttributes.Color = color;
2025-08-23 18:29:24 +08:00
// 如果当前是荧光笔模式,同时更新荧光笔颜色和属性
if (penType == 1)
{
// 根据颜色设置对应的荧光笔颜色索引
if (color == Colors.White || IsColorSimilar(color, Color.FromRgb(250, 250, 250), 10))
{
highlighterColor = 101; // 白色荧光笔
}
else if (color == Colors.Black)
{
highlighterColor = 100; // 黑色荧光笔
}
2025-08-31 07:54:43 +08:00
else if (color == Colors.Yellow || IsColorSimilar(color, Color.FromRgb(234, 179, 8)) ||
IsColorSimilar(color, Color.FromRgb(250, 204, 21)) ||
IsColorSimilar(color, Color.FromRgb(253, 224, 71)))
2025-08-23 18:29:24 +08:00
{
highlighterColor = 103; // 黄色荧光笔
}
2025-08-23 18:43:47 +08:00
else if (color == Color.FromRgb(255, 165, 0) || color == Color.FromRgb(251, 150, 80) || IsColorSimilar(color, Color.FromRgb(249, 115, 22), 20) ||
2025-08-23 18:39:12 +08:00
IsColorSimilar(color, Color.FromRgb(234, 88, 12), 20) ||
IsColorSimilar(color, Color.FromRgb(251, 146, 60), 20) ||
IsColorSimilar(color, Color.FromRgb(253, 126, 20), 20))
2025-08-23 18:29:24 +08:00
{
highlighterColor = 109; // 橙色荧光笔
}
else if (color == Color.FromRgb(37, 99, 235))
{
highlighterColor = 106; // 蓝色荧光笔
}
2025-08-31 07:54:43 +08:00
else if (color == Colors.Red || IsColorSimilar(color, Color.FromRgb(220, 38, 38)) ||
IsColorSimilar(color, Color.FromRgb(239, 68, 68)))
2025-08-23 18:29:24 +08:00
{
highlighterColor = 102; // 红色荧光笔
}
2025-08-31 07:54:43 +08:00
else if (color == Colors.Green || IsColorSimilar(color, Color.FromRgb(22, 163, 74)))
2025-08-23 18:29:24 +08:00
{
highlighterColor = 104; // 绿色荧光笔
}
else if (color == Color.FromRgb(147, 51, 234))
{
highlighterColor = 107; // 紫色荧光笔
}
// 确保荧光笔属性正确设置
drawingAttributes.Width = Settings.Canvas.HighlighterWidth / 2;
drawingAttributes.Height = Settings.Canvas.HighlighterWidth;
drawingAttributes.StylusTip = StylusTip.Rectangle;
drawingAttributes.IsHighlighter = true;
2025-08-31 11:43:52 +08:00
2025-08-23 18:29:24 +08:00
inkCanvas.DefaultDrawingAttributes.Width = Settings.Canvas.HighlighterWidth / 2;
inkCanvas.DefaultDrawingAttributes.Height = Settings.Canvas.HighlighterWidth;
inkCanvas.DefaultDrawingAttributes.StylusTip = StylusTip.Rectangle;
inkCanvas.DefaultDrawingAttributes.IsHighlighter = true;
2025-08-31 11:43:52 +08:00
2025-08-23 18:39:12 +08:00
// 确保荧光笔颜色索引正确更新
inkCanvas.DefaultDrawingAttributes.Color = drawingAttributes.Color;
2025-08-23 18:29:24 +08:00
}
2025-08-11 20:19:01 +08:00
// 更新颜色状态
if (currentMode == 0)
{
// 桌面模式
if (color == Colors.White) lastDesktopInkColor = 5;
2025-08-23 18:43:47 +08:00
else if (color == Color.FromRgb(251, 150, 80)) lastDesktopInkColor = 8; // 橙色
2025-08-11 20:19:01 +08:00
else if (color == Colors.Yellow) lastDesktopInkColor = 4;
else if (color == Colors.Black) lastDesktopInkColor = 0;
2025-08-12 12:19:55 +08:00
else if (color == Color.FromRgb(37, 99, 235)) lastDesktopInkColor = 3; // 蓝色
2025-08-11 20:19:01 +08:00
else if (color == Colors.Red) lastDesktopInkColor = 1;
2025-08-31 11:43:52 +08:00
else if (color == Colors.Green || color == Color.FromRgb(22, 163, 74)) lastDesktopInkColor = 2;
2025-08-12 12:19:55 +08:00
else if (color == Color.FromRgb(147, 51, 234)) lastDesktopInkColor = 6; // 紫色
2025-08-11 20:19:01 +08:00
}
else
{
// 白板模式
if (color == Colors.White) lastBoardInkColor = 5;
2025-08-23 18:43:47 +08:00
else if (color == Color.FromRgb(251, 150, 80)) lastBoardInkColor = 8; // 橙色
2025-08-11 20:19:01 +08:00
else if (color == Colors.Yellow) lastBoardInkColor = 4;
else if (color == Colors.Black) lastBoardInkColor = 0;
2025-08-12 12:19:55 +08:00
else if (color == Color.FromRgb(37, 99, 235)) lastBoardInkColor = 3; // 蓝色
2025-08-11 20:19:01 +08:00
else if (color == Colors.Red) lastBoardInkColor = 1;
2025-08-31 11:43:52 +08:00
else if (color == Colors.Green || color == Color.FromRgb(22, 163, 74)) lastBoardInkColor = 2;
2025-08-12 12:19:55 +08:00
else if (color == Color.FromRgb(147, 51, 234)) lastBoardInkColor = 6; // 紫色
2025-08-11 20:19:01 +08:00
}
// 更新快捷调色盘选择指示器
UpdateQuickColorPaletteIndicator(color);
// 更新颜色显示
ColorSwitchCheck();
2025-08-31 11:43:52 +08:00
2025-08-23 18:39:12 +08:00
// 如果当前是荧光笔模式,调用ColorSwitchCheck确保颜色索引正确更新
if (penType == 1)
{
ColorSwitchCheck();
}
2025-08-11 20:19:01 +08:00
}
private void UpdateQuickColorPaletteIndicator(Color selectedColor)
{
2025-08-12 12:19:55 +08:00
// 隐藏所有check图标(双行显示)
2025-08-12 11:13:35 +08:00
QuickColorWhiteCheck.Visibility = Visibility.Collapsed;
QuickColorOrangeCheck.Visibility = Visibility.Collapsed;
QuickColorYellowCheck.Visibility = Visibility.Collapsed;
QuickColorBlackCheck.Visibility = Visibility.Collapsed;
QuickColorBlueCheck.Visibility = Visibility.Collapsed;
QuickColorRedCheck.Visibility = Visibility.Collapsed;
QuickColorGreenCheck.Visibility = Visibility.Collapsed;
QuickColorPurpleCheck.Visibility = Visibility.Collapsed;
2025-08-31 11:43:52 +08:00
2025-08-12 12:19:55 +08:00
// 隐藏所有check图标(单行显示)
QuickColorWhiteCheckSingle.Visibility = Visibility.Collapsed;
QuickColorOrangeCheckSingle.Visibility = Visibility.Collapsed;
QuickColorYellowCheckSingle.Visibility = Visibility.Collapsed;
QuickColorBlackCheckSingle.Visibility = Visibility.Collapsed;
QuickColorRedCheckSingle.Visibility = Visibility.Collapsed;
QuickColorGreenCheckSingle.Visibility = Visibility.Collapsed;
2025-08-12 11:13:35 +08:00
// 显示当前选中颜色的check图标
2025-08-23 18:29:24 +08:00
// 在荧光笔模式下,使用更宽松的颜色匹配
int tolerance = (penType == 1) ? 25 : 15; // 荧光笔模式使用更大的容差
2025-08-31 11:43:52 +08:00
2025-08-23 18:29:24 +08:00
if (IsColorSimilar(selectedColor, Colors.White, tolerance) || IsColorSimilar(selectedColor, Color.FromRgb(250, 250, 250), tolerance))
2025-08-11 22:42:36 +08:00
{
2025-08-12 11:13:35 +08:00
QuickColorWhiteCheck.Visibility = Visibility.Visible;
2025-08-12 12:19:55 +08:00
QuickColorWhiteCheckSingle.Visibility = Visibility.Visible;
2025-08-11 22:42:36 +08:00
}
2025-08-23 18:29:24 +08:00
else if (IsColorSimilar(selectedColor, Colors.Black, tolerance))
2025-08-11 22:42:36 +08:00
{
2025-08-12 11:13:35 +08:00
QuickColorBlackCheck.Visibility = Visibility.Visible;
2025-08-12 12:19:55 +08:00
QuickColorBlackCheckSingle.Visibility = Visibility.Visible;
2025-08-11 22:42:36 +08:00
}
2025-08-31 11:43:52 +08:00
else if (IsColorSimilar(selectedColor, Colors.Yellow, tolerance) ||
2025-08-23 18:29:24 +08:00
IsColorSimilar(selectedColor, Color.FromRgb(234, 179, 8), tolerance) ||
IsColorSimilar(selectedColor, Color.FromRgb(250, 204, 21), tolerance) ||
IsColorSimilar(selectedColor, Color.FromRgb(253, 224, 71), tolerance))
2025-08-11 22:42:36 +08:00
{
2025-08-12 11:13:35 +08:00
QuickColorYellowCheck.Visibility = Visibility.Visible;
2025-08-12 12:19:55 +08:00
QuickColorYellowCheckSingle.Visibility = Visibility.Visible;
2025-08-11 22:42:36 +08:00
}
2025-08-31 11:43:52 +08:00
else if (IsColorSimilar(selectedColor, Color.FromRgb(255, 165, 0), tolerance) ||
2025-08-23 18:43:47 +08:00
IsColorSimilar(selectedColor, Color.FromRgb(251, 150, 80), tolerance) ||
2025-08-23 18:29:24 +08:00
IsColorSimilar(selectedColor, Color.FromRgb(249, 115, 22), tolerance) ||
2025-08-23 18:39:12 +08:00
IsColorSimilar(selectedColor, Color.FromRgb(234, 88, 12), tolerance) ||
IsColorSimilar(selectedColor, Color.FromRgb(251, 146, 60), tolerance) ||
IsColorSimilar(selectedColor, Color.FromRgb(253, 126, 20), tolerance))
2025-08-11 22:42:36 +08:00
{
2025-08-12 11:13:35 +08:00
QuickColorOrangeCheck.Visibility = Visibility.Visible;
2025-08-12 12:19:55 +08:00
QuickColorOrangeCheckSingle.Visibility = Visibility.Visible;
2025-08-11 22:42:36 +08:00
}
2025-08-23 18:29:24 +08:00
else if (IsColorSimilar(selectedColor, Color.FromRgb(37, 99, 235), tolerance))
2025-08-11 22:42:36 +08:00
{
2025-08-12 11:13:35 +08:00
QuickColorBlueCheck.Visibility = Visibility.Visible;
2025-08-12 12:19:55 +08:00
// 单行显示模式没有蓝色,所以不设置单行的check
2025-08-11 22:42:36 +08:00
}
2025-08-31 11:43:52 +08:00
else if (IsColorSimilar(selectedColor, Colors.Red, tolerance) ||
2025-08-23 18:29:24 +08:00
IsColorSimilar(selectedColor, Color.FromRgb(220, 38, 38), tolerance) ||
IsColorSimilar(selectedColor, Color.FromRgb(239, 68, 68), tolerance))
2025-08-11 22:42:36 +08:00
{
2025-08-12 11:13:35 +08:00
QuickColorRedCheck.Visibility = Visibility.Visible;
2025-08-12 12:19:55 +08:00
QuickColorRedCheckSingle.Visibility = Visibility.Visible;
2025-08-11 22:42:36 +08:00
}
2025-08-23 18:39:12 +08:00
else if (IsColorSimilar(selectedColor, Color.FromRgb(22, 163, 74), tolerance))
2025-08-12 11:08:24 +08:00
{
2025-08-12 11:13:35 +08:00
QuickColorGreenCheck.Visibility = Visibility.Visible;
2025-08-12 12:19:55 +08:00
QuickColorGreenCheckSingle.Visibility = Visibility.Visible;
2025-08-12 11:08:24 +08:00
}
2025-08-23 18:29:24 +08:00
else if (IsColorSimilar(selectedColor, Color.FromRgb(147, 51, 234), tolerance))
2025-08-12 11:08:24 +08:00
{
2025-08-12 11:13:35 +08:00
QuickColorPurpleCheck.Visibility = Visibility.Visible;
2025-08-12 12:19:55 +08:00
// 单行显示模式没有紫色,所以不设置单行的check
2025-08-12 11:08:24 +08:00
}
2025-08-11 20:19:01 +08:00
}
2025-08-11 20:28:33 +08:00
/// <summary>
/// 检查两个颜色是否相似(允许一定的误差范围)
/// </summary>
private bool IsColorSimilar(Color color1, Color color2, int tolerance = 15)
{
int rDiff = Math.Abs(color1.R - color2.R);
int gDiff = Math.Abs(color1.G - color2.G);
int bDiff = Math.Abs(color1.B - color2.B);
2025-08-31 11:43:52 +08:00
2025-08-11 20:28:33 +08:00
return rDiff <= tolerance && gDiff <= tolerance && bDiff <= tolerance;
}
2025-08-10 11:58:58 +08:00
private void SelectIcon_MouseUp(object sender, RoutedEventArgs e)
2025-08-03 16:46:33 +08:00
{
2025-07-19 13:35:28 +08:00
// 禁用高级橡皮擦系统
2025-10-03 17:08:46 +08:00
DisableEraserOverlay();
2025-08-03 16:46:33 +08:00
2025-05-25 09:29:48 +08:00
forceEraser = true;
drawingShapeMode = 0;
inkCanvas.IsManipulationEnabled = false;
2025-08-03 16:46:33 +08:00
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select)
{
2025-05-25 09:29:48 +08:00
var selectedStrokes = new StrokeCollection();
foreach (var stroke in inkCanvas.Strokes)
if (stroke.GetBounds().Width > 0 && stroke.GetBounds().Height > 0)
selectedStrokes.Add(stroke);
inkCanvas.Select(selectedStrokes);
}
2025-08-03 16:46:33 +08:00
else
{
2025-08-30 11:20:53 +08:00
// 使用集中化的工具模式切换方法
SetCurrentToolMode(InkCanvasEditingMode.Select);
2025-05-25 09:29:48 +08:00
}
}
2025-08-03 16:46:33 +08:00
private void DrawShapePromptToPen()
{
if (isLongPressSelected)
{
2025-06-19 11:25:15 +08:00
// 如果是长按选中的状态,只隐藏面板,不切换到笔模式
HideSubPanels("shape");
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
if (StackPanelCanvasControls.Visibility == Visibility.Visible)
HideSubPanels("pen");
else
HideSubPanels("cursor");
}
}
2025-08-03 16:46:33 +08:00
private void CloseBordertools_MouseUp(object sender, MouseButtonEventArgs e)
{
2025-05-25 09:29:48 +08:00
HideSubPanels();
}
#region Left Side Panel
2025-08-03 16:46:33 +08:00
private void BtnFingerDragMode_Click(object sender, RoutedEventArgs e)
{
if (isSingleFingerDragMode)
{
2025-05-25 09:29:48 +08:00
isSingleFingerDragMode = false;
BtnFingerDragMode.Content = "单指\n拖动";
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
isSingleFingerDragMode = true;
BtnFingerDragMode.Content = "多指\n拖动";
}
}
2025-08-03 16:46:33 +08:00
private void BtnUndo_Click(object sender, RoutedEventArgs e)
{
if (inkCanvas.GetSelectedStrokes().Count != 0)
{
2025-05-25 09:29:48 +08:00
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
inkCanvas.Select(new StrokeCollection());
}
var item = timeMachine.Undo();
ApplyHistoryToCanvas(item);
}
2025-08-03 16:46:33 +08:00
private void BtnRedo_Click(object sender, RoutedEventArgs e)
{
if (inkCanvas.GetSelectedStrokes().Count != 0)
{
2025-05-25 09:29:48 +08:00
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
inkCanvas.Select(new StrokeCollection());
}
var item = timeMachine.Redo();
ApplyHistoryToCanvas(item);
}
2025-08-03 16:46:33 +08:00
private void Btn_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
{
2025-05-25 09:29:48 +08:00
if (!isLoaded) return;
2025-08-03 16:46:33 +08:00
try
{
2025-05-25 09:29:48 +08:00
if (((Button)sender).IsEnabled)
((UIElement)((Button)sender).Content).Opacity = 1;
else
((UIElement)((Button)sender).Content).Opacity = 0.25;
}
catch { }
}
#endregion Left Side Panel
#region Right Side Panel
2025-07-28 14:40:44 +08:00
public static bool CloseIsFromButton;
2025-05-25 09:29:48 +08:00
2025-08-03 16:46:33 +08:00
public void BtnExit_Click(object sender, RoutedEventArgs e)
{
2025-09-27 17:52:25 +08:00
// 如果当前在设置面板中,需要先恢复无焦点模式状态
if (BorderSettings.Visibility == Visibility.Visible)
{
2025-10-18 18:29:52 +08:00
if (isTemporarilyDisablingNoFocusMode)
2025-09-27 17:52:25 +08:00
{
2025-10-18 18:29:52 +08:00
isTemporarilyDisablingNoFocusMode = false;
2025-09-27 17:52:25 +08:00
ApplyNoFocusMode();
}
SaveSettingsToFile();
}
2025-10-03 17:08:46 +08:00
2025-06-12 10:34:29 +08:00
App.IsAppExitByUser = true;
2025-07-31 10:03:29 +08:00
// 不设置 CloseIsFromButton = true,让它也经过确认流程
Close();
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
public void BtnRestart_Click(object sender, RoutedEventArgs e)
{
2025-09-27 17:52:25 +08:00
if (BorderSettings.Visibility == Visibility.Visible)
{
2025-10-18 18:29:52 +08:00
if (isTemporarilyDisablingNoFocusMode)
2025-09-27 17:52:25 +08:00
{
2025-10-18 18:29:52 +08:00
isTemporarilyDisablingNoFocusMode = false;
2025-09-27 17:52:25 +08:00
ApplyNoFocusMode();
}
SaveSettingsToFile();
}
2025-10-03 17:08:46 +08:00
2025-07-29 02:33:19 +08:00
Process.Start(System.Windows.Forms.Application.ExecutablePath, "-m");
App.IsAppExitByUser = true;
2025-07-31 10:03:29 +08:00
// 不设置 CloseIsFromButton = true,让它也经过确认流程
Close();
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
private void SettingsOverlayClick(object sender, MouseButtonEventArgs e)
{
2025-07-28 14:40:44 +08:00
if (isOpeningOrHidingSettingsPane) return;
2025-08-03 16:46:33 +08:00
2025-06-19 11:25:15 +08:00
// 获取点击的位置
Point clickPoint = e.GetPosition(BorderSettingsMask);
2025-08-03 16:46:33 +08:00
2025-06-19 11:25:15 +08:00
// 获取BorderSettings的位置和大小
Point settingsPosition = BorderSettings.TranslatePoint(new Point(0, 0), BorderSettingsMask);
Rect settingsRect = new Rect(
settingsPosition.X,
settingsPosition.Y,
BorderSettings.ActualWidth,
BorderSettings.ActualHeight
);
2025-08-03 16:46:33 +08:00
2025-06-19 11:25:15 +08:00
// 如果点击位置不在设置界面内部,才关闭设置界面
2025-08-03 16:46:33 +08:00
if (!settingsRect.Contains(clickPoint))
{
2025-06-19 11:25:15 +08:00
BtnSettings_Click(null, null);
}
2025-05-25 09:29:48 +08:00
}
2025-07-28 14:40:44 +08:00
private bool isOpeningOrHidingSettingsPane;
2025-09-06 17:51:25 +08:00
private bool wasNoFocusModeBeforeSettings;
2025-05-25 09:29:48 +08:00
2025-08-03 16:46:33 +08:00
private void BtnSettings_Click(object sender, RoutedEventArgs e)
{
if (BorderSettings.Visibility == Visibility.Visible)
{
2025-05-25 09:29:48 +08:00
HideSubPanels();
}
2025-08-03 16:46:33 +08:00
else
{
BorderSettings.Visibility = Visibility.Visible;
2025-09-06 17:51:25 +08:00
wasNoFocusModeBeforeSettings = Settings.Advanced.IsNoFocusMode;
2025-09-13 10:55:27 +08:00
userChangedNoFocusModeInSettings = false; // 重置用户修改标志
2025-09-06 17:51:25 +08:00
if (wasNoFocusModeBeforeSettings)
{
2025-10-18 18:29:52 +08:00
isTemporarilyDisablingNoFocusMode = true;
2025-09-06 17:51:25 +08:00
ApplyNoFocusMode();
}
2025-06-19 11:25:15 +08:00
// 设置蒙版为可点击,并添加半透明背景
2025-05-25 09:29:48 +08:00
BorderSettingsMask.IsHitTestVisible = true;
BorderSettingsMask.Background = new SolidColorBrush(Color.FromArgb(1, 0, 0, 0));
SettingsPanelScrollViewer.ScrollToTop();
var sb = new Storyboard();
// 滑动动画
2025-08-03 16:46:33 +08:00
var slideAnimation = new DoubleAnimation
{
From = BorderSettings.RenderTransform.Value.OffsetX - 490, // 滑动距离
2025-05-25 09:29:48 +08:00
To = 0,
Duration = TimeSpan.FromSeconds(0.6)
};
2025-07-28 14:40:44 +08:00
slideAnimation.EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut };
2025-05-25 09:29:48 +08:00
Storyboard.SetTargetProperty(slideAnimation,
new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)"));
sb.Children.Add(slideAnimation);
sb.Completed += (s, _) => { isOpeningOrHidingSettingsPane = false; };
BorderSettings.RenderTransform = new TranslateTransform();
isOpeningOrHidingSettingsPane = true;
2025-07-28 14:40:44 +08:00
sb.Begin(BorderSettings);
2025-05-25 09:29:48 +08:00
}
}
private void BtnThickness_Click(object sender, RoutedEventArgs e) { }
2025-07-28 14:40:44 +08:00
private bool forceEraser;
2025-05-25 09:29:48 +08:00
2025-08-03 16:46:33 +08:00
private void BtnClear_Click(object sender, RoutedEventArgs e)
{
2025-05-25 09:29:48 +08:00
forceEraser = false;
//BorderClearInDelete.Visibility = Visibility.Collapsed;
2025-08-03 16:46:33 +08:00
if (currentMode == 0)
{
2025-05-25 09:29:48 +08:00
// 先回到画笔再清屏,避免 TimeMachine 的相关 bug 影响
if (Pen_Icon.Background == null && StackPanelCanvasControls.Visibility == Visibility.Visible)
PenIcon_Click(null, null);
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
if (Pen_Icon.Background == null) PenIcon_Click(null, null);
}
2025-08-03 16:46:33 +08:00
if (inkCanvas.Strokes.Count != 0)
{
2025-05-25 09:29:48 +08:00
var whiteboardIndex = CurrentWhiteboardIndex;
if (currentMode == 0) whiteboardIndex = 0;
strokeCollections[whiteboardIndex] = inkCanvas.Strokes.Clone();
}
ClearStrokes(false);
2025-07-27 22:00:37 +08:00
// 保存非笔画元素(如图片)
var preservedElements = PreserveNonStrokeElements();
2025-05-25 09:29:48 +08:00
inkCanvas.Children.Clear();
2025-07-27 22:00:37 +08:00
// 恢复非笔画元素
RestoreNonStrokeElements(preservedElements);
2025-05-25 09:29:48 +08:00
if (Settings.Canvas.ClearCanvasAndClearTimeMachine) timeMachine.ClearStrokeHistory();
2025-10-31 14:46:20 +08:00
2025-11-01 18:39:52 +08:00
CancelSingleFingerDragMode();
2025-05-25 09:29:48 +08:00
}
2025-07-28 14:40:44 +08:00
private bool lastIsInMultiTouchMode;
2025-05-25 09:29:48 +08:00
2025-10-31 14:46:20 +08:00
private void CancelSingleFingerDragMode()
{
if (ToggleSwitchDrawShapeBorderAutoHide.IsOn) CollapseBorderDrawShape();
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
if (isSingleFingerDragMode) BtnFingerDragMode_Click(BtnFingerDragMode, null);
isLongPressSelected = false;
}
/// <summary>
/// 重置所有触摸相关状态,
/// </summary>
private void ResetTouchStates()
{
try
{
// 清空触摸点计数器
dec.Clear();
// 重置手掌擦状态
if (isPalmEraserActive)
{
isPalmEraserActive = false;
}
// 确保触摸事件能正常响应
inkCanvas.IsHitTestVisible = true;
inkCanvas.IsManipulationEnabled = true;
// 释放所有触摸捕获
inkCanvas.ReleaseAllTouchCaptures();
// 恢复UI元素的触摸响应
ViewboxFloatingBar.IsHitTestVisible = true;
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"重置触摸状态失败: {ex.Message}", LogHelper.LogType.Error);
}
}
2025-08-03 16:46:33 +08:00
private void BtnHideControl_Click(object sender, RoutedEventArgs e)
{
2025-05-25 09:29:48 +08:00
if (StackPanelControl.Visibility == Visibility.Visible)
StackPanelControl.Visibility = Visibility.Hidden;
else
StackPanelControl.Visibility = Visibility.Visible;
}
2025-07-28 14:40:44 +08:00
private int currentMode;
2025-05-25 09:29:48 +08:00
2025-08-03 16:46:33 +08:00
private void BtnSwitch_Click(object sender, RoutedEventArgs e)
{
if (GridTransparencyFakeBackground.Background == Brushes.Transparent)
{
if (currentMode == 0)
{
2025-05-25 09:29:48 +08:00
currentMode++;
GridBackgroundCover.Visibility = Visibility.Collapsed;
AnimationsHelper.HideWithSlideAndFade(BlackboardLeftSide);
AnimationsHelper.HideWithSlideAndFade(BlackboardCenterSide);
AnimationsHelper.HideWithSlideAndFade(BlackboardRightSide);
2025-08-03 16:46:33 +08:00
// 在PPT模式下隐藏手势面板和手势按钮
AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
AnimationsHelper.HideWithSlideAndFade(BoardTwoFingerGestureBorder);
EnableTwoFingerGestureBorder.Visibility = Visibility.Collapsed;
2025-05-25 09:29:48 +08:00
SaveStrokes(true);
ClearStrokes(true);
2025-07-29 17:38:58 +08:00
RestoreStrokes(true);
2025-07-21 12:44:05 +08:00
2025-08-03 16:46:33 +08:00
if (BtnSwitchTheme.Content.ToString() == "浅色")
{
2025-05-25 09:29:48 +08:00
BtnSwitch.Content = "黑板";
BtnExit.Foreground = Brushes.White;
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
BtnSwitch.Content = "白板";
2025-08-03 16:46:33 +08:00
if (isPresentationHaveBlackSpace)
{
2025-05-25 09:29:48 +08:00
BtnExit.Foreground = Brushes.White;
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
BtnExit.Foreground = Brushes.Black;
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
}
}
StackPanelPPTButtons.Visibility = Visibility.Visible;
}
Topmost = true;
BtnHideInkCanvas_Click(BtnHideInkCanvas, e);
}
2025-08-03 16:46:33 +08:00
else
{
switch (++currentMode % 2)
{
2025-05-25 09:29:48 +08:00
case 0: //屏幕模式
currentMode = 0;
GridBackgroundCover.Visibility = Visibility.Collapsed;
AnimationsHelper.HideWithSlideAndFade(BlackboardLeftSide);
AnimationsHelper.HideWithSlideAndFade(BlackboardCenterSide);
AnimationsHelper.HideWithSlideAndFade(BlackboardRightSide);
// 在PPT模式下隐藏手势面板和手势按钮
AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
AnimationsHelper.HideWithSlideAndFade(BoardTwoFingerGestureBorder);
EnableTwoFingerGestureBorder.Visibility = Visibility.Collapsed;
2025-05-25 09:29:48 +08:00
SaveStrokes();
ClearStrokes(true);
2025-07-29 01:31:21 +08:00
RestoreStrokes(true);
2025-07-21 12:44:05 +08:00
2025-08-31 09:54:13 +08:00
// 新增:在屏幕模式下恢复基础浮动栏的显示
ViewboxFloatingBar.Visibility = Visibility.Visible;
2025-10-02 18:15:39 +08:00
// 新增:退出白板时自动收纳功能 - 等待浮动栏完全展开后再收纳
2025-09-20 11:22:09 +08:00
if (Settings.Automation.IsAutoFoldWhenExitWhiteboard && !isFloatingBarFolded)
{
2025-10-02 18:15:39 +08:00
// 使用异步延迟,等待浮动栏展开动画完成后再收纳
Task.Run(async () =>
{
2025-10-03 17:08:46 +08:00
await Task.Delay(700);
2025-10-02 18:15:39 +08:00
await Dispatcher.InvokeAsync(() =>
{
FoldFloatingBar_MouseUp(new object(), null);
});
});
2025-09-20 11:22:09 +08:00
}
2025-08-03 16:46:33 +08:00
if (BtnSwitchTheme.Content.ToString() == "浅色")
{
2025-05-25 09:29:48 +08:00
BtnSwitch.Content = "黑板";
BtnExit.Foreground = Brushes.White;
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
BtnSwitch.Content = "白板";
2025-08-03 16:46:33 +08:00
if (isPresentationHaveBlackSpace)
{
2025-05-25 09:29:48 +08:00
BtnExit.Foreground = Brushes.White;
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
BtnExit.Foreground = Brushes.Black;
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
}
}
StackPanelPPTButtons.Visibility = Visibility.Visible;
Topmost = true;
break;
case 1: //黑板或白板模式
currentMode = 1;
GridBackgroundCover.Visibility = Visibility.Visible;
AnimationsHelper.ShowWithSlideFromBottomAndFade(BlackboardLeftSide);
AnimationsHelper.ShowWithSlideFromBottomAndFade(BlackboardCenterSide);
AnimationsHelper.ShowWithSlideFromBottomAndFade(BlackboardRightSide);
SaveStrokes(true);
ClearStrokes(true);
2025-07-28 18:23:07 +08:00
2025-07-29 01:31:21 +08:00
// 总是恢复备份墨迹,不管是否在PPT模式
// PPT墨迹和白板墨迹应该分别管理,不应该互相影响
RestoreStrokes();
2025-05-25 09:29:48 +08:00
2025-08-31 09:54:13 +08:00
// 新增:在白板模式下隐藏基础浮动栏
ViewboxFloatingBar.Visibility = Visibility.Collapsed;
2025-05-25 09:29:48 +08:00
BtnSwitch.Content = "屏幕";
2025-08-03 16:46:33 +08:00
if (BtnSwitchTheme.Content.ToString() == "浅色")
{
2025-05-25 09:29:48 +08:00
BtnExit.Foreground = Brushes.White;
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
BtnExit.Foreground = Brushes.Black;
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
}
if (Settings.Canvas.UsingWhiteboard)
{
2025-07-16 09:16:36 +08:00
// 如果有自定义背景色并且是白板模式,应用自定义背景色
if (CustomBackgroundColor.HasValue)
{
GridBackgroundCover.Background = new SolidColorBrush(CustomBackgroundColor.Value);
}
// 白板模式下设置墨迹颜色为黑色
CheckLastColor(0);
forceEraser = false;
ColorSwitchCheck();
2025-05-25 09:29:48 +08:00
}
else
{
2025-07-16 09:16:36 +08:00
// 黑板模式下设置墨迹颜色为白色
CheckLastColor(5);
forceEraser = false;
ColorSwitchCheck();
2025-05-25 09:29:48 +08:00
}
StackPanelPPTButtons.Visibility = Visibility.Collapsed;
2025-10-19 01:34:03 +08:00
if (Settings.Advanced.EnableUIAccessTopMost)
{
Topmost = true;
}
else
{
Topmost = false;
}
2025-05-25 09:29:48 +08:00
break;
}
}
}
private int BoundsWidth = 5;
2025-08-03 16:46:33 +08:00
private void BtnHideInkCanvas_Click(object sender, RoutedEventArgs e)
{
if (GridTransparencyFakeBackground.Background == Brushes.Transparent)
{
2025-05-25 09:29:48 +08:00
GridTransparencyFakeBackground.Opacity = 1;
GridTransparencyFakeBackground.Background = new SolidColorBrush(StringToColor("#01FFFFFF"));
inkCanvas.IsHitTestVisible = true;
inkCanvas.Visibility = Visibility.Visible;
GridBackgroundCoverHolder.Visibility = Visibility.Visible;
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
2025-08-03 16:46:33 +08:00
if (GridBackgroundCover.Visibility == Visibility.Collapsed)
{
2025-05-25 09:29:48 +08:00
if (BtnSwitchTheme.Content.ToString() == "浅色")
BtnSwitch.Content = "黑板";
else
BtnSwitch.Content = "白板";
StackPanelPPTButtons.Visibility = Visibility.Visible;
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
BtnSwitch.Content = "屏幕";
StackPanelPPTButtons.Visibility = Visibility.Collapsed;
}
BtnHideInkCanvas.Content = "隐藏\n画板";
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
// Auto-clear Strokes 要等待截图完成再清理笔记
2025-08-03 16:46:33 +08:00
if (BtnPPTSlideShowEnd.Visibility != Visibility.Visible)
{
2025-05-25 09:29:48 +08:00
if (isLoaded && Settings.Automation.IsAutoClearWhenExitingWritingMode)
2025-08-03 16:46:33 +08:00
if (inkCanvas.Strokes.Count > 0)
{
2025-05-25 09:29:48 +08:00
if (Settings.Automation.IsAutoSaveStrokesAtClear && inkCanvas.Strokes.Count >
Settings.Automation.MinimumAutomationStrokeNumber)
SaveScreenShot(true);
//BtnClear_Click(null, null);
}
inkCanvas.IsHitTestVisible = true;
inkCanvas.Visibility = Visibility.Visible;
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
if (isLoaded && Settings.Automation.IsAutoClearWhenExitingWritingMode &&
!Settings.PowerPointSettings.IsNoClearStrokeOnSelectWhenInPowerPoint)
2025-08-03 16:46:33 +08:00
if (inkCanvas.Strokes.Count > 0)
{
2025-05-25 09:29:48 +08:00
if (Settings.Automation.IsAutoSaveStrokesAtClear && inkCanvas.Strokes.Count >
Settings.Automation.MinimumAutomationStrokeNumber)
SaveScreenShot(true);
//BtnClear_Click(null, null);
}
2025-08-03 16:46:33 +08:00
if (Settings.PowerPointSettings.IsShowStrokeOnSelectInPowerPoint)
{
2025-05-25 09:29:48 +08:00
inkCanvas.Visibility = Visibility.Visible;
inkCanvas.IsHitTestVisible = true;
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
inkCanvas.IsHitTestVisible = true;
inkCanvas.Visibility = Visibility.Visible;
}
}
GridTransparencyFakeBackground.Opacity = 0;
GridTransparencyFakeBackground.Background = Brushes.Transparent;
GridBackgroundCoverHolder.Visibility = Visibility.Collapsed;
2025-08-03 16:46:33 +08:00
if (currentMode != 0)
{
2025-05-25 09:29:48 +08:00
SaveStrokes();
RestoreStrokes(true);
}
if (BtnSwitchTheme.Content.ToString() == "浅色")
BtnSwitch.Content = "黑板";
else
BtnSwitch.Content = "白板";
StackPanelPPTButtons.Visibility = Visibility.Visible;
BtnHideInkCanvas.Content = "显示\n画板";
}
2025-08-03 16:46:33 +08:00
if (GridTransparencyFakeBackground.Background == Brushes.Transparent)
{
2025-05-25 09:29:48 +08:00
StackPanelCanvasControls.Visibility = Visibility.Collapsed;
CheckEnableTwoFingerGestureBtnVisibility(false);
HideSubPanels("cursor");
2025-08-31 11:43:52 +08:00
2025-08-31 09:54:13 +08:00
// 新增:在屏幕模式下显示基础浮动栏
if (currentMode == 0)
{
ViewboxFloatingBar.Visibility = Visibility.Visible;
}
2025-05-25 09:29:48 +08:00
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
AnimationsHelper.ShowWithSlideFromLeftAndFade(StackPanelCanvasControls);
CheckEnableTwoFingerGestureBtnVisibility(true);
2025-08-31 11:43:52 +08:00
2025-08-31 09:54:13 +08:00
// 新增:在批注模式下显示基础浮动栏
if (currentMode == 0)
{
ViewboxFloatingBar.Visibility = Visibility.Visible;
}
2025-05-25 09:29:48 +08:00
}
}
2025-08-03 16:46:33 +08:00
private void BtnSwitchSide_Click(object sender, RoutedEventArgs e)
{
if (ViewBoxStackPanelMain.HorizontalAlignment == HorizontalAlignment.Right)
{
2025-05-25 09:29:48 +08:00
ViewBoxStackPanelMain.HorizontalAlignment = HorizontalAlignment.Left;
ViewBoxStackPanelShapes.HorizontalAlignment = HorizontalAlignment.Right;
}
2025-08-03 16:46:33 +08:00
else
{
2025-05-25 09:29:48 +08:00
ViewBoxStackPanelMain.HorizontalAlignment = HorizontalAlignment.Right;
ViewBoxStackPanelShapes.HorizontalAlignment = HorizontalAlignment.Left;
}
}
2025-08-03 16:46:33 +08:00
private void StackPanel_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
2025-05-25 09:29:48 +08:00
if (((StackPanel)sender).Visibility == Visibility.Visible)
GridForLeftSideReservedSpace.Visibility = Visibility.Collapsed;
else
GridForLeftSideReservedSpace.Visibility = Visibility.Visible;
}
#endregion
2025-05-31 21:13:02 +08:00
2025-07-30 19:56:22 +08:00
private void InsertImageOptions_MouseUp(object sender, MouseButtonEventArgs e)
{
2025-08-30 18:59:32 +08:00
// Check if the image options panel is currently visible
bool isImagePanelVisible = BoardImageOptionsPanel.Visibility == Visibility.Visible;
2025-08-31 11:43:52 +08:00
2025-08-30 18:59:32 +08:00
// Toggle the image options panel
if (isImagePanelVisible)
2025-07-30 19:56:22 +08:00
{
2025-08-30 18:59:32 +08:00
// Panel was visible, so hide it with animation
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
2025-07-30 19:56:22 +08:00
}
else
{
2025-08-30 18:59:32 +08:00
// Panel was hidden, so hide other panels and show this one
HideSubPanelsImmediately();
AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardImageOptionsPanel);
2025-07-30 19:56:22 +08:00
}
}
private void CloseImageOptionsPanel_MouseUp(object sender, MouseButtonEventArgs e)
{
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
}
private async void ImageOptionScreenshot_MouseUp(object sender, MouseButtonEventArgs e)
{
// Hide the options panel
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
// Wait a bit for the panel to hide
await Task.Delay(100);
2025-08-30 19:40:14 +08:00
// Capture screenshot and insert to canvas
2025-08-31 09:09:22 +08:00
await CaptureScreenshotAndInsert();
2025-07-30 19:56:22 +08:00
}
private async void ImageOptionSelectFile_MouseUp(object sender, MouseButtonEventArgs e)
{
// Hide the options panel
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
// Open file dialog to select image
var dialog = new OpenFileDialog
{
Filter = "图片文件|*.jpg;*.jpeg;*.png;*.bmp;*.gif"
};
if (dialog.ShowDialog() == true)
{
string filePath = dialog.FileName;
Image image = await CreateAndCompressImageAsync(filePath);
if (image != null)
{
string timestamp = "img_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss_fff");
image.Name = timestamp;
2025-08-30 23:19:53 +08:00
// 初始化TransformGroup
if (image is FrameworkElement element)
{
var transformGroup = new TransformGroup();
transformGroup.Children.Add(new ScaleTransform(1, 1));
transformGroup.Children.Add(new TranslateTransform(0, 0));
transformGroup.Children.Add(new RotateTransform(0));
element.RenderTransform = transformGroup;
}
2025-07-30 19:56:22 +08:00
CenterAndScaleElement(image);
2025-08-31 11:43:52 +08:00
2025-08-30 23:19:53 +08:00
// 设置图片属性,避免被InkCanvas选择系统处理
image.IsHitTestVisible = true;
image.Focusable = false;
2025-08-31 11:43:52 +08:00
2025-08-30 23:19:53 +08:00
// 初始化InkCanvas选择设置
if (inkCanvas != null)
{
// 清除当前选择,避免显示控制点
inkCanvas.Select(new StrokeCollection());
// 同时通过图片的IsHitTestVisible和Focusable属性来避免InkCanvas选择系统的干扰
inkCanvas.EditingMode = InkCanvasEditingMode.None;
}
2025-08-31 11:43:52 +08:00
2025-07-30 19:56:22 +08:00
inkCanvas.Children.Add(image);
2025-08-30 23:19:53 +08:00
// 绑定事件处理器
if (image is FrameworkElement elementForEvents)
{
// 鼠标事件
elementForEvents.MouseLeftButtonDown += Element_MouseLeftButtonDown;
elementForEvents.MouseLeftButtonUp += Element_MouseLeftButtonUp;
elementForEvents.MouseMove += Element_MouseMove;
elementForEvents.MouseWheel += Element_MouseWheel;
// 触摸事件
2025-09-30 17:22:32 +08:00
elementForEvents.TouchDown += Element_TouchDown;
elementForEvents.TouchUp += Element_TouchUp;
2025-08-30 23:19:53 +08:00
elementForEvents.IsManipulationEnabled = true;
elementForEvents.ManipulationDelta += Element_ManipulationDelta;
elementForEvents.ManipulationCompleted += Element_ManipulationCompleted;
// 设置光标
elementForEvents.Cursor = Cursors.Hand;
}
2025-07-30 19:56:22 +08:00
timeMachine.CommitElementInsertHistory(image);
2025-09-07 00:49:10 +08:00
// 插入图片后切换到选择模式并刷新浮动栏高光显示
SetCurrentToolMode(InkCanvasEditingMode.Select);
UpdateCurrentToolMode("select");
HideSubPanels("select");
2025-07-30 19:56:22 +08:00
}
}
}
2025-08-30 22:54:16 +08:00
// 新增:插入图片方法
private async void InsertImage_MouseUp_New(object sender, MouseButtonEventArgs e)
{
var dialog = new OpenFileDialog
{
Filter = "图片文件|*.jpg;*.jpeg;*.png;*.bmp;*.gif"
};
if (dialog.ShowDialog() == true)
{
string filePath = dialog.FileName;
Image image = await CreateAndCompressImageAsync(filePath);
if (image != null)
{
string timestamp = "img_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss_fff");
image.Name = timestamp;
// 初始化TransformGroup
if (image is FrameworkElement element)
{
var transformGroup = new TransformGroup();
transformGroup.Children.Add(new ScaleTransform(1, 1));
transformGroup.Children.Add(new TranslateTransform(0, 0));
transformGroup.Children.Add(new RotateTransform(0));
element.RenderTransform = transformGroup;
}
CenterAndScaleElement(image);
2025-08-31 11:43:52 +08:00
2025-08-30 22:54:16 +08:00
// 设置图片属性,避免被InkCanvas选择系统处理
image.IsHitTestVisible = true;
image.Focusable = false;
2025-08-31 11:43:52 +08:00
2025-08-30 22:54:16 +08:00
// 初始化InkCanvas选择设置
if (inkCanvas != null)
{
// 清除当前选择,避免显示控制点
inkCanvas.Select(new StrokeCollection());
// 设置编辑模式为非选择模式
inkCanvas.EditingMode = InkCanvasEditingMode.None;
}
2025-08-31 11:43:52 +08:00
2025-08-30 22:54:16 +08:00
inkCanvas.Children.Add(image);
// 绑定事件处理器
if (image is FrameworkElement elementForEvents)
{
// 鼠标事件
elementForEvents.MouseLeftButtonDown += Element_MouseLeftButtonDown;
elementForEvents.MouseLeftButtonUp += Element_MouseLeftButtonUp;
elementForEvents.MouseMove += Element_MouseMove;
elementForEvents.MouseWheel += Element_MouseWheel;
// 触摸事件
2025-09-30 17:22:32 +08:00
elementForEvents.TouchDown += Element_TouchDown;
elementForEvents.TouchUp += Element_TouchUp;
2025-08-30 22:54:16 +08:00
elementForEvents.IsManipulationEnabled = true;
elementForEvents.ManipulationDelta += Element_ManipulationDelta;
elementForEvents.ManipulationCompleted += Element_ManipulationCompleted;
// 设置光标
elementForEvents.Cursor = Cursors.Hand;
}
timeMachine.CommitElementInsertHistory(image);
2025-09-07 00:49:10 +08:00
// 插入图片后切换到选择模式并刷新浮动栏高光显示
SetCurrentToolMode(InkCanvasEditingMode.Select);
UpdateCurrentToolMode("select");
HideSubPanels("select");
2025-08-30 22:54:16 +08:00
}
}
}
2025-07-30 19:56:22 +08:00
// Keep the old method for backward compatibility
2025-07-21 12:15:56 +08:00
private async void InsertImage_MouseUp(object sender, MouseButtonEventArgs e)
{
2025-07-28 14:40:44 +08:00
var dialog = new OpenFileDialog
2025-07-21 12:15:56 +08:00
{
Filter = "图片文件|*.jpg;*.jpeg;*.png;*.bmp;*.gif"
};
if (dialog.ShowDialog() == true)
{
2025-07-21 12:44:05 +08:00
string filePath = dialog.FileName;
Image image = await CreateAndCompressImageAsync(filePath); // 补充image定义
if (image != null)
{
string timestamp = "img_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss_fff");
image.Name = timestamp;
2025-08-30 22:54:16 +08:00
// 初始化TransformGroup
if (image is FrameworkElement element)
{
var transformGroup = new TransformGroup();
transformGroup.Children.Add(new ScaleTransform(1, 1));
transformGroup.Children.Add(new TranslateTransform(0, 0));
transformGroup.Children.Add(new RotateTransform(0));
element.RenderTransform = transformGroup;
}
2025-07-29 17:38:58 +08:00
CenterAndScaleElement(image);
2025-08-31 11:43:52 +08:00
2025-08-30 22:54:16 +08:00
// 设置图片属性,避免被InkCanvas选择系统处理
image.IsHitTestVisible = true;
image.Focusable = false;
2025-08-31 11:43:52 +08:00
2025-08-30 22:54:16 +08:00
// 初始化InkCanvas选择设置
if (inkCanvas != null)
{
// 清除当前选择,避免显示控制点
inkCanvas.Select(new StrokeCollection());
// 设置编辑模式为非选择模式
inkCanvas.EditingMode = InkCanvasEditingMode.None;
}
2025-08-31 11:43:52 +08:00
2025-07-21 12:44:05 +08:00
inkCanvas.Children.Add(image);
2025-08-30 22:54:16 +08:00
// 绑定事件处理器
if (image is FrameworkElement elementForEvents)
{
// 鼠标事件
elementForEvents.MouseLeftButtonDown += Element_MouseLeftButtonDown;
elementForEvents.MouseLeftButtonUp += Element_MouseLeftButtonUp;
elementForEvents.MouseMove += Element_MouseMove;
elementForEvents.MouseWheel += Element_MouseWheel;
// 触摸事件
2025-09-30 17:22:32 +08:00
elementForEvents.TouchDown += Element_TouchDown;
elementForEvents.TouchUp += Element_TouchUp;
2025-08-30 22:54:16 +08:00
elementForEvents.IsManipulationEnabled = true;
elementForEvents.ManipulationDelta += Element_ManipulationDelta;
elementForEvents.ManipulationCompleted += Element_ManipulationCompleted;
// 设置光标
elementForEvents.Cursor = Cursors.Hand;
}
2025-07-21 12:44:05 +08:00
timeMachine.CommitElementInsertHistory(image);
2025-09-07 00:49:10 +08:00
// 插入图片后切换到选择模式并刷新浮动栏高光显示
SetCurrentToolMode(InkCanvasEditingMode.Select);
UpdateCurrentToolMode("select");
HideSubPanels("select");
2025-07-21 12:44:05 +08:00
}
2025-07-21 12:15:56 +08:00
}
}
2025-07-27 22:00:37 +08:00
#region
/// <summary>
/// 获取浮动栏中指定按钮的位置
/// </summary>
/// <param name="buttonName">按钮的名称</param>
/// <returns>按钮在浮动栏中的相对位置</returns>
private double GetFloatingBarButtonPosition(string buttonName)
{
try
{
// 获取浮动栏容器
var floatingBarPanel = StackPanelFloatingBar;
if (floatingBarPanel == null) return 0;
double currentPosition = 0;
2025-08-31 11:43:52 +08:00
// 遍历浮动栏中的所有子元素
foreach (var child in floatingBarPanel.Children)
{
if (child is UIElement element)
{
// 检查是否是我们要找的按钮
if (IsTargetButton(element, buttonName))
{
return currentPosition;
}
2025-08-31 11:43:52 +08:00
// 累加当前元素的位置
currentPosition += GetElementWidth(element);
}
}
2025-08-31 11:43:52 +08:00
return 0;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"获取按钮位置失败: {ex.Message}", LogHelper.LogType.Error);
return 0;
}
}
/// <summary>
/// 检查元素是否是目标按钮
/// </summary>
private bool IsTargetButton(UIElement element, string buttonName)
{
if (element is FrameworkElement fe)
{
return fe.Name == buttonName;
}
return false;
}
/// <summary>
/// 获取元素的宽度
/// </summary>
private double GetElementWidth(UIElement element)
{
if (element is FrameworkElement fe)
{
// 对于SimpleStackPanel,使用其实际宽度
if (fe.GetType().Name == "SimpleStackPanel")
{
return fe.ActualWidth > 0 ? fe.ActualWidth : 28; // 默认宽度28
}
2025-08-31 11:43:52 +08:00
// 对于其他元素,使用其宽度或默认宽度
return fe.ActualWidth > 0 ? fe.ActualWidth : 28;
}
return 28; // 默认宽度
}
/// <summary>
/// 设置浮动栏高光显示位置
/// </summary>
/// <param name="mode">模式名称</param>
private void SetFloatingBarHighlightPosition(string mode)
{
try
{
if (FloatingbarSelectionBG == null) return;
2025-09-06 15:36:40 +08:00
// 检查浮动栏是否处于收起状态
if (isFloatingBarFolded || (BorderFloatingBarMainControls != null && BorderFloatingBarMainControls.Visibility == Visibility.Collapsed))
{
// 在收起状态下,仍然需要设置高光位置,但可能需要调整计算方式
// 这里先隐藏高光,等浮动栏展开时再显示
FloatingbarSelectionBG.Visibility = Visibility.Hidden;
return;
}
double position = 0;
double buttonWidth = 28; // 每个按钮的默认宽度
double highlightWidth = 28; // 高光的默认宽度
2025-08-31 11:43:52 +08:00
// 检查快捷调色盘是否显示及其实际宽度
bool isQuickColorPaletteVisible = false;
double quickColorPaletteWidth = 0;
2025-08-31 08:51:50 +08:00
if (QuickColorPalettePanel != null && QuickColorPalettePanel.Visibility == Visibility.Visible)
{
isQuickColorPaletteVisible = true;
quickColorPaletteWidth = QuickColorPalettePanel.ActualWidth > 0 ? QuickColorPalettePanel.ActualWidth : 60;
}
else if (QuickColorPaletteSingleRowPanel != null && QuickColorPaletteSingleRowPanel.Visibility == Visibility.Visible)
{
isQuickColorPaletteVisible = true;
quickColorPaletteWidth = QuickColorPaletteSingleRowPanel.ActualWidth > 0 ? QuickColorPaletteSingleRowPanel.ActualWidth : 120;
}
2025-08-30 18:33:57 +08:00
// 获取实际按钮宽度,如果获取不到则使用默认值,同时考虑按钮的可见性
double cursorWidth = (Cursor_Icon?.Visibility == Visibility.Visible && Cursor_Icon?.ActualWidth > 0) ? Cursor_Icon.ActualWidth : 0;
double penWidth = (Pen_Icon?.Visibility == Visibility.Visible && Pen_Icon?.ActualWidth > 0) ? Pen_Icon.ActualWidth : 0;
double deleteWidth = (SymbolIconDelete?.Visibility == Visibility.Visible && SymbolIconDelete?.ActualWidth > 0) ? SymbolIconDelete.ActualWidth : 0;
double eraserWidth = (Eraser_Icon?.Visibility == Visibility.Visible && Eraser_Icon?.ActualWidth > 0) ? Eraser_Icon.ActualWidth : 0;
double eraserByStrokesWidth = (EraserByStrokes_Icon?.Visibility == Visibility.Visible && EraserByStrokes_Icon?.ActualWidth > 0) ? EraserByStrokes_Icon.ActualWidth : 0;
double selectWidth = (SymbolIconSelect?.Visibility == Visibility.Visible && SymbolIconSelect?.ActualWidth > 0) ? SymbolIconSelect.ActualWidth : 0;
// 获取高光的实际宽度
double actualHighlightWidth = FloatingbarSelectionBG.ActualWidth > 0 ? FloatingbarSelectionBG.ActualWidth : highlightWidth;
2025-08-31 11:43:52 +08:00
double marginOffset = 0;
// 快捷调色盘的MarginMargin="4,0,4,0",所以总宽度需要加上8像素
double quickColorPaletteTotalWidth = isQuickColorPaletteVisible ? quickColorPaletteWidth + 8 : 0;
2025-08-31 11:43:52 +08:00
// 根据模式计算位置,确保高光居中对齐按钮
switch (mode)
{
case "cursor":
// 鼠标按钮位置:marginOffset + (cursorWidth - actualHighlightWidth) / 2
position = marginOffset + (cursorWidth - actualHighlightWidth) / 2;
break;
case "pen":
case "color":
// 批注按钮位置:marginOffset + cursorWidth + (penWidth - actualHighlightWidth) / 2
position = marginOffset + cursorWidth + (penWidth - actualHighlightWidth) / 2;
break;
case "eraser":
if (isQuickColorPaletteVisible)
{
// 有快捷调色盘时:鼠标 + 批注 + 快捷调色盘(包含Margin) + 清空 + (面积擦 - 高光) / 2
position = marginOffset + cursorWidth + penWidth + quickColorPaletteTotalWidth + deleteWidth + (eraserWidth - actualHighlightWidth) / 2;
}
else
{
// 没有快捷调色盘时:鼠标 + 批注 + 清空 + (面积擦 - 高光) / 2
position = marginOffset + cursorWidth + penWidth + deleteWidth + (eraserWidth - actualHighlightWidth) / 2;
}
break;
case "eraserByStrokes":
if (isQuickColorPaletteVisible)
{
// 有快捷调色盘时:鼠标 + 批注 + 快捷调色盘(包含Margin) + 清空 + 面积擦 + (线擦 - 高光) / 2
position = marginOffset + cursorWidth + penWidth + quickColorPaletteTotalWidth + deleteWidth + eraserWidth + (eraserByStrokesWidth - actualHighlightWidth) / 2;
}
else
{
// 没有快捷调色盘时:鼠标 + 批注 + 清空 + 面积擦 + (线擦 - 高光) / 2
position = marginOffset + cursorWidth + penWidth + deleteWidth + eraserWidth + (eraserByStrokesWidth - actualHighlightWidth) / 2;
}
break;
case "select":
if (isQuickColorPaletteVisible)
{
// 有快捷调色盘时:鼠标 + 批注 + 快捷调色盘(包含Margin) + 清空 + 面积擦 + 线擦 + (套索选 - 高光) / 2
position = marginOffset + cursorWidth + penWidth + quickColorPaletteTotalWidth + deleteWidth + eraserWidth + eraserByStrokesWidth + (selectWidth - actualHighlightWidth) / 2;
}
else
{
// 没有快捷调色盘时:鼠标 + 批注 + 清空 + 面积擦 + 线擦 + (套索选 - 高光) / 2
position = marginOffset + cursorWidth + penWidth + deleteWidth + eraserWidth + eraserByStrokesWidth + (selectWidth - actualHighlightWidth) / 2;
}
break;
case "shape":
if (isQuickColorPaletteVisible)
{
// 有快捷调色盘时:鼠标 + 批注 + 快捷调色盘(包含Margin) + 清空 + 面积擦 + 线擦 + 套索选 + (几何 - 高光) / 2
position = marginOffset + cursorWidth + penWidth + quickColorPaletteTotalWidth + deleteWidth + eraserWidth + eraserByStrokesWidth + selectWidth + (buttonWidth - actualHighlightWidth) / 2;
}
else
{
// 没有快捷调色盘时:鼠标 + 批注 + 清空 + 面积擦 + 线擦 + 套索选 + (几何 - 高光) / 2
position = marginOffset + cursorWidth + penWidth + deleteWidth + eraserWidth + eraserByStrokesWidth + selectWidth + (buttonWidth - actualHighlightWidth) / 2;
}
break;
default:
position = marginOffset;
break;
}
2025-10-04 17:30:26 +08:00
// 根据主题设置高光颜色
Color highlightBackgroundColor;
Color highlightBarColor;
2025-10-06 18:29:12 +08:00
bool isDarkTheme = Settings.Appearance.Theme == 1 ||
2025-10-04 17:30:26 +08:00
(Settings.Appearance.Theme == 2 && !IsSystemThemeLight());
2025-10-06 18:29:12 +08:00
2025-10-04 17:30:26 +08:00
if (isDarkTheme)
{
2025-10-06 18:29:12 +08:00
highlightBackgroundColor = Color.FromArgb(21, 102, 204, 255);
highlightBarColor = Color.FromRgb(102, 204, 255);
2025-10-04 17:30:26 +08:00
}
else
{
2025-10-06 18:29:12 +08:00
highlightBackgroundColor = Color.FromArgb(21, 59, 130, 246);
highlightBarColor = Color.FromRgb(37, 99, 235);
2025-10-04 17:30:26 +08:00
}
// 设置高光背景颜色
FloatingbarSelectionBG.Background = new SolidColorBrush(highlightBackgroundColor);
if (FloatingbarSelectionBG.Child is System.Windows.Controls.Canvas canvas && canvas.Children.Count > 0)
{
var firstChild = canvas.Children[0];
if (firstChild is Border innerBorder)
{
innerBorder.Background = new SolidColorBrush(highlightBarColor);
}
}
// 设置高光位置
FloatingbarSelectionBG.Visibility = Visibility.Visible;
System.Windows.Controls.Canvas.SetLeft(FloatingbarSelectionBG, position);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"设置高光位置失败: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 隐藏浮动栏高光显示
/// </summary>
private void HideFloatingBarHighlight()
{
if (FloatingbarSelectionBG != null)
{
FloatingbarSelectionBG.Visibility = Visibility.Hidden;
System.Windows.Controls.Canvas.SetLeft(FloatingbarSelectionBG, 0);
}
}
2025-08-30 18:33:57 +08:00
/// <summary>
/// 获取当前选中的模式
/// </summary>
/// <returns>当前选中的模式名称</returns>
public string GetCurrentSelectedMode()
{
try
{
2025-09-06 17:12:25 +08:00
// 优先使用缓存的模式,避免在浮动栏刷新时返回过时的模式信息
if (!string.IsNullOrEmpty(_currentToolMode))
{
return _currentToolMode;
}
// 如果缓存为空,则从inkCanvas状态推断模式
2025-08-30 18:33:57 +08:00
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select)
{
return "select";
}
2025-08-31 09:54:13 +08:00
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
2025-08-30 18:33:57 +08:00
{
// 检查是否是荧光笔模式
if (drawingAttributes != null && drawingAttributes.IsHighlighter)
{
return "color";
}
2025-08-31 09:54:13 +08:00
return "pen";
2025-08-30 18:33:57 +08:00
}
2025-08-31 09:54:13 +08:00
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
2025-08-30 18:33:57 +08:00
{
// 检查是面积擦还是线擦
if (Eraser_Icon != null && Eraser_Icon.Visibility == Visibility.Visible)
{
return "eraser";
}
2025-08-31 09:54:13 +08:00
if (EraserByStrokes_Icon != null && EraserByStrokes_Icon.Visibility == Visibility.Visible)
2025-08-30 18:33:57 +08:00
{
return "eraserByStrokes";
}
}
else if (inkCanvas.EditingMode == InkCanvasEditingMode.None)
{
return "cursor";
}
else if (drawingShapeMode != 0)
{
return "shape";
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"获取当前选中模式失败: {ex.Message}", LogHelper.LogType.Error);
}
2025-08-31 11:43:52 +08:00
2025-09-06 17:12:25 +08:00
return "cursor"; // 默认返回鼠标模式
}
/// <summary>
/// 更新当前工具模式缓存
/// </summary>
/// <param name="mode">模式名称</param>
private void UpdateCurrentToolMode(string mode)
{
_currentToolMode = mode;
2025-08-30 18:33:57 +08:00
}
2025-08-30 18:10:55 +08:00
#endregion
#region
/// <summary>
/// 为浮动栏按钮添加触摸和手写笔事件支持,让触摸和手写笔点击直接调用对应的鼠标点击方法
/// </summary>
private void AddTouchSupportToFloatingBarButtons()
{
// 为主要的浮动栏按钮添加触摸和手写笔事件支持
if (SymbolIconSelect != null)
{
SymbolIconSelect.TouchDown += (s, e) => SymbolIconSelect_MouseUp(s, null);
SymbolIconSelect.StylusDown += (s, e) => SymbolIconSelect_MouseUp(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (SymbolIconUndo != null)
{
SymbolIconUndo.TouchDown += (s, e) => SymbolIconUndo_MouseUp(s, null);
SymbolIconUndo.StylusDown += (s, e) => SymbolIconUndo_MouseUp(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (SymbolIconRedo != null)
{
SymbolIconRedo.TouchDown += (s, e) => SymbolIconRedo_MouseUp(s, null);
SymbolIconRedo.StylusDown += (s, e) => SymbolIconRedo_MouseUp(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (SymbolIconDelete != null)
{
SymbolIconDelete.TouchDown += (s, e) => SymbolIconDelete_MouseUp(s, null);
SymbolIconDelete.StylusDown += (s, e) => SymbolIconDelete_MouseUp(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (ToolsFloatingBarBtn != null)
{
ToolsFloatingBarBtn.TouchDown += (s, e) => SymbolIconTools_MouseUp(s, null);
ToolsFloatingBarBtn.StylusDown += (s, e) => SymbolIconTools_MouseUp(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (RandomDrawPanel != null)
{
RandomDrawPanel.TouchDown += (s, e) => SymbolIconRand_MouseUp(s, null);
RandomDrawPanel.StylusDown += (s, e) => SymbolIconRand_MouseUp(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (SingleDrawPanel != null)
{
SingleDrawPanel.TouchDown += (s, e) => SymbolIconRandOne_MouseUp(s, null);
SingleDrawPanel.StylusDown += (s, e) => SymbolIconRandOne_MouseUp(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
// 注意:Screenshot和Settings按钮在XAML中没有直接的Name属性,需要通过其他方式绑定
// 这些按钮的事件处理已经在XAML中通过MouseUp绑定
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (BorderFloatingBarMoveControls != null)
{
BorderFloatingBarMoveControls.TouchDown += (s, e) => SymbolIconEmoji_MouseUp(s, null);
BorderFloatingBarMoveControls.StylusDown += (s, e) => SymbolIconEmoji_MouseUp(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
// 白板模式下的按钮不添加触摸事件支持,保持原有的鼠标事件处理
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
// 为快捷调色盘按钮添加触摸和手写笔事件支持
if (QuickColorWhite != null)
{
QuickColorWhite.TouchDown += (s, e) => QuickColorWhite_Click(s, null);
QuickColorWhite.StylusDown += (s, e) => QuickColorWhite_Click(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (QuickColorOrange != null)
{
QuickColorOrange.TouchDown += (s, e) => QuickColorOrange_Click(s, null);
QuickColorOrange.StylusDown += (s, e) => QuickColorOrange_Click(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (QuickColorYellow != null)
{
QuickColorYellow.TouchDown += (s, e) => QuickColorYellow_Click(s, null);
QuickColorYellow.StylusDown += (s, e) => QuickColorYellow_Click(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (QuickColorBlack != null)
{
QuickColorBlack.TouchDown += (s, e) => QuickColorBlack_Click(s, null);
QuickColorBlack.StylusDown += (s, e) => QuickColorBlack_Click(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (QuickColorBlue != null)
{
QuickColorBlue.TouchDown += (s, e) => QuickColorBlue_Click(s, null);
QuickColorBlue.StylusDown += (s, e) => QuickColorBlue_Click(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (QuickColorRed != null)
{
QuickColorRed.TouchDown += (s, e) => QuickColorRed_Click(s, null);
QuickColorRed.StylusDown += (s, e) => QuickColorRed_Click(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (QuickColorGreen != null)
{
QuickColorGreen.TouchDown += (s, e) => QuickColorGreen_Click(s, null);
QuickColorGreen.StylusDown += (s, e) => QuickColorGreen_Click(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (QuickColorPurple != null)
{
QuickColorPurple.TouchDown += (s, e) => QuickColorPurple_Click(s, null);
QuickColorPurple.StylusDown += (s, e) => QuickColorPurple_Click(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
// 单行快捷调色盘
if (QuickColorWhiteSingle != null)
{
QuickColorWhiteSingle.TouchDown += (s, e) => QuickColorWhite_Click(s, null);
QuickColorWhiteSingle.StylusDown += (s, e) => QuickColorWhite_Click(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (QuickColorOrangeSingle != null)
{
QuickColorOrangeSingle.TouchDown += (s, e) => QuickColorOrange_Click(s, null);
QuickColorOrangeSingle.StylusDown += (s, e) => QuickColorOrange_Click(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (QuickColorYellowSingle != null)
{
QuickColorYellowSingle.TouchDown += (s, e) => QuickColorYellow_Click(s, null);
QuickColorYellowSingle.StylusDown += (s, e) => QuickColorYellow_Click(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (QuickColorBlackSingle != null)
{
QuickColorBlackSingle.TouchDown += (s, e) => QuickColorBlack_Click(s, null);
QuickColorBlackSingle.StylusDown += (s, e) => QuickColorBlack_Click(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (QuickColorRedSingle != null)
{
QuickColorRedSingle.TouchDown += (s, e) => QuickColorRed_Click(s, null);
QuickColorRedSingle.StylusDown += (s, e) => QuickColorRed_Click(s, null);
}
2025-08-31 11:43:52 +08:00
2025-08-30 18:10:55 +08:00
if (QuickColorGreenSingle != null)
{
QuickColorGreenSingle.TouchDown += (s, e) => QuickColorGreen_Click(s, null);
QuickColorGreenSingle.StylusDown += (s, e) => QuickColorGreen_Click(s, null);
}
}
2025-09-20 11:55:50 +08:00
/// <summary>
/// 强制禁用所有双指手势功能(当多指书写模式启用时)
/// </summary>
private void ForceDisableTwoFingerGestures()
{
// 强制关闭所有双指手势设置
Settings.Gesture.IsEnableTwoFingerTranslate = false;
Settings.Gesture.IsEnableTwoFingerZoom = false;
Settings.Gesture.IsEnableTwoFingerRotation = false;
// 更新UI开关状态
if (ToggleSwitchEnableTwoFingerTranslate != null)
ToggleSwitchEnableTwoFingerTranslate.IsOn = false;
if (ToggleSwitchEnableTwoFingerZoom != null)
ToggleSwitchEnableTwoFingerZoom.IsOn = false;
if (ToggleSwitchEnableTwoFingerRotation != null)
ToggleSwitchEnableTwoFingerRotation.IsOn = false;
// 更新设置窗口中的开关状态
if (BoardToggleSwitchEnableTwoFingerTranslate != null)
BoardToggleSwitchEnableTwoFingerTranslate.IsOn = false;
if (BoardToggleSwitchEnableTwoFingerZoom != null)
BoardToggleSwitchEnableTwoFingerZoom.IsOn = false;
if (BoardToggleSwitchEnableTwoFingerRotation != null)
BoardToggleSwitchEnableTwoFingerRotation.IsOn = false;
}
2025-08-30 18:10:55 +08:00
#endregion
2025-05-25 09:29:48 +08:00
}
2025-07-06 21:09:01 +08:00
}