add:使用橡皮后自动切回批注

This commit is contained in:
2026-02-22 11:25:30 +08:00
parent 3e701718d3
commit d8bbee8c76
8 changed files with 251 additions and 5 deletions
@@ -383,7 +383,6 @@ namespace Ink_Canvas
/// <param name="e">事件参数。</param>
private void BtnWhiteBoardSwitchNext_Click(object sender, EventArgs e)
{
Trace.WriteLine("113223234");
if (Settings.Automation.IsAutoSaveStrokesAtClear &&
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber) SaveScreenShot(true);
+4 -1
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics;
using System.Linq;
using System.Windows;
@@ -174,6 +174,9 @@ namespace Ink_Canvas
AddedStroke = null;
ReplacedStroke = null;
}
// 橡皮擦自动切换回批注
HandleEraserOperationEnded();
}
/// <summary>
@@ -2267,6 +2267,9 @@ namespace Ink_Canvas
// 禁用高级橡皮擦系统
DisableEraserOverlay();
// 停止橡皮擦自动切换计时器(如果正在运行)
StopEraserAutoSwitchBackTimer();
SetFloatingBarHighlightPosition("pen");
// 记录当前是否已经是批注模式且是否为高光显示模式
@@ -2526,6 +2529,12 @@ namespace Ink_Canvas
HideSubPanels("eraser"); // 高亮橡皮按钮
Trace.WriteLine($"Eraser: Eraser button clicked, current size: {eraserWidth}, circle: {isEraserCircleShape}");
// 如果启用了橡皮擦自动切换功能,停止之前的计时器(如果正在运行)
if (Settings.Canvas.EnableEraserAutoSwitchBack)
{
StopEraserAutoSwitchBackTimer();
}
if (isAlreadyEraser)
{
// 已是橡皮状态,再次点击才弹出/收起面板
@@ -2570,6 +2579,12 @@ namespace Ink_Canvas
SetCursorBasedOnEditingMode(inkCanvas);
HideSubPanels("eraser"); // 高亮橡皮按钮
// 如果启用了橡皮擦自动切换功能,停止之前的计时器(如果正在运行)
if (Settings.Canvas.EnableEraserAutoSwitchBack)
{
StopEraserAutoSwitchBackTimer();
}
if (isAlreadyEraser)
{
// 已是橡皮状态,再次点击才弹出/收起面板
@@ -2564,6 +2564,7 @@ namespace Ink_Canvas
/// </remarks>
private void inkCanvas_MouseUp(object sender, MouseButtonEventArgs e)
{
HandleEraserOperationEnded(); // 橡皮擦自动切换回批注模式:松手后启动/重置计时
inkCanvas.ReleaseMouseCapture();
ViewboxFloatingBar.IsHitTestVisible = true;
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
+103 -2
View File
@@ -123,7 +123,6 @@ namespace Ink_Canvas
/// NTP时间同步定时器
/// </summary>
private Timer timerNtpSync = new Timer();
/// <summary>
/// 时间视图模型实例
/// </summary>
@@ -156,7 +155,10 @@ namespace Ink_Canvas
/// 防止重复NTP同步的标志
/// </summary>
private bool isNtpSyncing = false;
/// <summary>
/// 橡皮擦自动切换回批注模式的计时器
/// </summary>
private DispatcherTimer _eraserAutoSwitchBackTimer;
/// <summary>
/// 异步获取网络时间
/// </summary>
@@ -248,6 +250,9 @@ namespace Ink_Canvas
// 初始化定时保存墨迹定时器
InitAutoSaveStrokesTimer();
// 初始化橡皮擦自动切换回批注模式计时器
InitEraserAutoSwitchBackTimer();
}
/// <summary>
@@ -1381,5 +1386,101 @@ namespace Ink_Canvas
LogHelper.WriteLogToFile($"AutoUpdate | Error resetting retry state: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 初始化橡皮擦自动切换回批注模式计时器
/// </summary>
private void InitEraserAutoSwitchBackTimer()
{
if (_eraserAutoSwitchBackTimer == null)
{
_eraserAutoSwitchBackTimer = new DispatcherTimer();
_eraserAutoSwitchBackTimer.Tick += EraserAutoSwitchBackTimer_Tick;
}
}
/// <summary>
/// 启动橡皮擦自动切换回批注模式计时器
/// </summary>
public void StartEraserAutoSwitchBackTimer()
{
try
{
if (!Settings.Canvas.EnableEraserAutoSwitchBack) return;
if (_eraserAutoSwitchBackTimer == null) InitEraserAutoSwitchBackTimer();
// 停止之前的计时器
_eraserAutoSwitchBackTimer.Stop();
// 设置计时器间隔
int delaySeconds = Settings.Canvas.EraserAutoSwitchBackDelaySeconds;
if (delaySeconds < 1) delaySeconds = 10; // 最小1秒
_eraserAutoSwitchBackTimer.Interval = TimeSpan.FromSeconds(delaySeconds);
// 启动计时器
_eraserAutoSwitchBackTimer.Start();
LogHelper.WriteLogToFile($"橡皮擦自动切换计时器已启动,延迟 {delaySeconds} 秒", LogHelper.LogType.Trace);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"启动橡皮擦自动切换计时器失败: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 停止橡皮擦自动切换回批注模式计时器
/// </summary>
public void StopEraserAutoSwitchBackTimer()
{
try
{
if (_eraserAutoSwitchBackTimer != null)
{
_eraserAutoSwitchBackTimer.Stop();
LogHelper.WriteLogToFile("橡皮擦自动切换计时器已停止", LogHelper.LogType.Trace);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"停止橡皮擦自动切换计时器失败: {ex.Message}", LogHelper.LogType.Error);
}
}
/// <summary>
/// 橡皮擦自动切换回批注模式计时器事件处理
/// </summary>
private void EraserAutoSwitchBackTimer_Tick(object sender, EventArgs e)
{
try
{
// 检查是否仍然在橡皮擦模式
if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint &&
inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke)
{
StopEraserAutoSwitchBackTimer();
return;
}
// 检查设置是否仍然启用
if (!Settings.Canvas.EnableEraserAutoSwitchBack)
{
StopEraserAutoSwitchBackTimer();
return;
}
// 切换到批注模式
Dispatcher.Invoke(() =>
{
PenIcon_Click(null, null);
StopEraserAutoSwitchBackTimer();
LogHelper.WriteLogToFile("橡皮擦自动切换回批注模式", LogHelper.LogType.Event);
});
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"橡皮擦自动切换计时器事件处理失败: {ex.Message}", LogHelper.LogType.Error);
}
}
}
}