add:WinRT墨迹识别

This commit is contained in:
2026-03-28 18:40:18 +08:00
parent dc9fb26260
commit 97bdf78b08
5 changed files with 121 additions and 49 deletions
@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
@@ -39,6 +40,9 @@ namespace Ink_Canvas
/// </summary>
private List<Circle> circles = new List<Circle>();
/// <summary>串行执行墨迹转形状(尤其 WinRT 异步延后),避免多笔 BeginInvoke 交错修改 newStrokes。</summary>
private static readonly SemaphoreSlim InkToShapeSerial = new SemaphoreSlim(1, 1);
/// <summary>
@@ -390,6 +394,7 @@ namespace Ink_Canvas
{
async Task InkToShapeProcessCoreAsync()
{
await InkToShapeSerial.WaitAsync().ConfigureAwait(true);
try
{
newStrokes.Add(e.Stroke);
@@ -713,6 +718,10 @@ namespace Ink_Canvas
}
}
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
finally
{
InkToShapeSerial.Release();
}
}
void InkToShapeProcess()
@@ -730,7 +739,7 @@ namespace Ink_Canvas
{
System.Diagnostics.Debug.WriteLine(ex);
}
}), DispatcherPriority.Background);
}), DispatcherPriority.Normal);
return;
}