improve:显示画笔光标

This commit is contained in:
2026-01-01 18:21:28 +08:00
parent 965957aa1b
commit 7eee02dc94
2 changed files with 27 additions and 5 deletions
+27 -4
View File
@@ -72,7 +72,8 @@ namespace Ink_Canvas
// 全屏处理状态标志
public bool isFullScreenApplied = false;
private static Cursor _cachedPenCursor = null;
private static readonly object _cursorLock = new object();
#region Window Initialization
@@ -1363,9 +1364,31 @@ namespace Ink_Canvas
}
else if (canvas.EditingMode == InkCanvasEditingMode.Ink)
{
var sri = Application.GetResourceStream(new Uri("Resources/Cursors/Pen.cur", UriKind.Relative));
if (sri != null)
canvas.Cursor = new Cursor(sri.Stream);
if (_cachedPenCursor == null)
{
lock (_cursorLock)
{
if (_cachedPenCursor == null)
{
try
{
var sri = Application.GetResourceStream(new Uri("Resources/Cursors/Pen.cur", UriKind.Relative));
if (sri != null)
{
_cachedPenCursor = new Cursor(sri.Stream);
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"加载 Pen 光标资源失败: {ex.Message}", LogHelper.LogType.Error);
}
}
}
}
if (_cachedPenCursor != null)
{
canvas.Cursor = _cachedPenCursor;
}
}
// 确保光标可见,无论是鼠标、触控还是手写笔