优化代码

This commit is contained in:
2025-08-31 08:51:50 +08:00
parent a2aa6b48a8
commit 1bc23af61a
15 changed files with 81 additions and 46 deletions
+1 -3
View File
@@ -1339,9 +1339,7 @@ namespace Ink_Canvas.Helpers
return descriptions.Count > 0 ? string.Join(", ", descriptions) : "普通用户";
}
/// <summary>
/// 关机时保存使用时间数据
/// </summary>
+2 -6
View File
@@ -721,26 +721,22 @@ namespace Ink_Canvas.Helpers
// 根据高光位置判断当前选中的工具
// 位置计算基于SetFloatingBarHighlightPosition方法中的逻辑
bool isMouseMode = false;
string currentTool = "unknown";
bool isMouseMode;
// 简化判断:如果位置接近0,说明是鼠标模式
// 如果位置接近28,说明是批注模式
// 如果位置更大,说明是其他工具
if (position < 5) // 鼠标模式:marginOffset + (cursorWidth - actualHighlightWidth) / 2 ≈ 0
{
isMouseMode = true;
currentTool = "鼠标";
}
else if (position < 35) // 批注模式:marginOffset + cursorWidth + (penWidth - actualHighlightWidth) / 2 ≈ 28
{
isMouseMode = false;
currentTool = "批注";
}
else // 其他工具(橡皮擦、选择等)
{
isMouseMode = false;
currentTool = "其他工具";
}
return isMouseMode;
@@ -16,7 +16,6 @@ namespace Ink_Canvas.Helpers
{
private readonly RenderTargetBitmap _renderTarget;
private readonly DrawingVisual _drawingVisual;
private readonly DrawingContext _drawingContext;
private bool _isInitialized;
public HardwareAcceleratedInkProcessor(int width = 1920, int height = 1080)
@@ -191,7 +190,6 @@ namespace Ink_Canvas.Helpers
/// </summary>
public void Dispose()
{
_drawingContext?.Close();
_renderTarget?.Clear();
_isInitialized = false;
}