Xamarin触摸跟踪(用于使用SkiaSharp绘图) [英] Xamarin Touch Tracking (for drawing with SkiaSharp)

查看:228
本文介绍了Xamarin触摸跟踪(用于使用SkiaSharp绘图)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我还有一个关于Xamarin的问题。在Xamarin文档中,有关于 Touch Tracking 的东西,我想要的是使用 SkiaSharp 命名空间来做一些绘图,例如用户输入。因此,用户用手指在 BoxView 上画些东西。

Today, I have another question about Xamarin. In the Xamarin documentation there is something about Touch Tracking, what I want is using the SkiaSharp Namespace to do some drawing as user input. So, the user uses his fingers to draw something on a BoxView or something like that.

问题:很难查找名称空间,在xamarin文档中没有任何痕迹。只是名字叫 TouchTracking,我也需要 TouchEffects。

Problem: it's hard to find the namespaces, no trace in the xamarin documentation. Just that the name is "TouchTracking" and I need "TouchEffects" too.

我用Google搜索了一下,我只得到了0.1.0 beta的东西,其中有TouchEffects。甚至不在同一个名称空间中,但是它们在提供的代码示例中,这并不重要,但是我发现的不是跨平台的,这确实让我感到困扰,因为如果有的话,我有志通过跨平台来完成所有工作

I googled a little and all i got is some 0.1.0 beta stuff where the TouchEffects are not even in the same namespace, but they are in the provided code example, which wouldn't really matter, but the one I found is not for cross-platform and this really bothers me because I have the ambition to do everything via crossplatform if possible.

那么触摸屏是否有跨平台解决方案?

So are there cross-platform solutions for touch drawing?

推荐答案

我真的很讨厌回答自己的问题,但是偶然发现我发现,SkiaSharp实际上支持我们需要的一切。这真是太神奇了,因为在我的Google研究之后,我发现EVERYBODY正在寻找它,而且似乎只有MR Gestures确实支持我所寻找的东西。
关键点:$ b​​ $ b SKCanvasView有一个带参数的Touch事件(对象,SKTouchEventArgs)。这些事件args提供您需要在表面,位置,操作类型(按下,释放,退出,输入,取消,...)上绘制的所有内容。
但是请注意:您需要以将 Handled设置为true启用处理,否则,事件args将仅返回Pressed。
另外,在创建SKCanvasView时还必须启用触摸输入。

I really hate to answer my own questions but by accident i found out, that SkiaSharp actually supports everything we need. Which is pretty amazing, since after my google research i found out EVERYBODY is looking for it and it seemed only MR Gestures does support what i was looking for. To the point: SKCanvasView has a Touch event with arguments (object, SKTouchEventArgs). those event args provide everything you need to draw on the surface, position, type of action (pressed, released, exited, entered, cancelled, ...) but please notice: you need to enable the handling with setting 'Handled' true, if not the event args will return just Pressed. Also you have to enable the Touch Input when creating the SKCanvasView.

有人应将其添加到上一个答案提供的页面中。

Someone should add this to the page provided in the previous answer.

这篇关于Xamarin触摸跟踪(用于使用SkiaSharp绘图)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆