UWP 手写板InkCanvas
效果如图
关键代码
<InkCanvas x:Name="inkCanvas" />
//设置绘画信息
inkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch;
InkDrawingAttributes inkDrawingAttributes = inkCanvas.InkPresenter.CopyDefaultDrawingAttributes();
inkDrawingAttributes.Size = new Size(8, 8);
inkDrawingAttributes.Color = Windows.UI.Color.FromArgb(255, 112, 112, 112);
inkDrawingAttributes.FitToCurve = true;
inkDrawingAttributes.PenTip = PenTipShape.Rectangle;
inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(inkDrawingAttributes);
InkRecognizerContainer inkRecognizerContainer = new InkRecognizerContainer();
IReadOnlyList<InkRecognizer> recognizers = inkRecognizerContainer.GetRecognizers();
InkRecognizer recognizer = recognizers.SingleOrDefault(r => r.Name == "Microsoft 中文(简体)手写识别器");
inkRecognizerContainer.SetDefaultRecognizer(recognizer);
if (token.IsCancellationRequested)
return;
IReadOnlyList<InkRecognitionResult> results = await inkRecognizerContainer.RecognizeAsync(inkCanvas.InkPresenter.StrokeContainer, InkRecognitionTarget.All);
foreach (InkRecognitionResult result in results)
{
//获得识别结果
foreach (string text in result.GetTextCandidates())
{
}
}
示例代码
参考资料
学习技术最好的文档就是【官方文档】,没有之一。
还有学习资料【Microsoft Learn】、【CSharp Learn】、【My Note】。
如果,你认为阅读这篇博客让你有些收获,不妨点击一下右下角的【推荐】按钮。
如果,你希望更容易地发现我的新博客,不妨点击一下【关注】。