improve:显示画笔光标
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
// 确保光标可见,无论是鼠标、触控还是手写笔
|
||||
|
||||
@@ -418,7 +418,6 @@ namespace Ink_Canvas
|
||||
}
|
||||
catch { }
|
||||
|
||||
SetCursorBasedOnEditingMode(inkCanvas);
|
||||
|
||||
var strokeVisual = GetStrokeVisual(e.StylusDevice.Id);
|
||||
var stylusPointCollection = e.GetStylusPoints(this);
|
||||
|
||||
Reference in New Issue
Block a user