处理触摸和手势事件 [英] Processing Touch and Gesture Events
问题描述
我正在使用一个GUI,该GUI涉及手势输入,该手势输入来自与Windows 7计算机连接的电容式触摸面板.该操作系统已安装了Tablet PC支持驱动程序,而这些驱动程序应该是进行通讯的唯一方法.
I am working on a GUI that involves gesture input coming from a capacitive touch panel that is connected to a Windows 7 machine. The OS has Tablet PC support drivers installed and those should be the only mean of communicating.
我的主要方法是使用Microsoft.ink.dll中引用的InkCollector类.它使我能够访问SystemGesture事件,这些事件足以实现我要寻找的行为.
My primary approach is to use InkCollector class that is referenced inside Microsoft.ink.dll. It gives me access to SystemGesture events which are sufficient to implement the behaviour I am seeking for.
现在的问题是,大约一秒钟之后,SystemGesture.Flick事件到达的速度非常慢.我了解到正在进行识别Flick的过程,但这仍然使该想法无法使用.
Now the problem is that the SystemGesture.Flick event arrives very slowly, after about a full second. I understand that there is processing going on to recognize the Flick, but it still makes the idea unusuable.
关于如何加快速度的任何想法?
Any ideas of how to speed things up?
我的初始化代码如下:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
InkCollector inkCollector = new InkCollector(this);
inkCollector.CollectionMode = CollectionMode.GestureOnly;
inkCollector.Enabled = true;
inkCollector.SetGestureStatus(ApplicationGesture.AllGestures, true);
inkCollector.SystemGesture += SystemGestureEventHandler;
inkCollector.Gesture += GestureEventHandler;
}
public void SystemGestureEventHandler(object o, InkCollectorSystemGestureEventArgs args)
{
switch (args.Id)
{
case SystemGesture.Drag:
outputText.AppendText("Drag" + Environment.NewLine);
break;
case SystemGesture.DoubleTap:
outputText.AppendText("DoubleTap"+ Environment.NewLine);
break;
case SystemGesture.Flick:
outputText.AppendText("Flick"+ Environment.NewLine);
break;
case SystemGesture.HoldEnter:
outputText.AppendText("HoldEnter"+ Environment.NewLine);
break;
case SystemGesture.HoldLeave:
outputText.AppendText("HoldLeave" + Environment.NewLine);
break;
case SystemGesture.Tap:
outputText.AppendText("Tap"+ Environment.NewLine);
break;
default:
break;
}
}
public void GestureEventHandler(object o, InkCollectorGestureEventArgs args)
{
foreach (Gesture gesture in args.Gestures)
{
switch (gesture.Id)
{
case ApplicationGesture.ArrowDown:
outputText.AppendText("Gesture: Arrow Down"+ Environment.NewLine);
break;
case ApplicationGesture.ArrowUp:
outputText.AppendText("Gesture: Arrow Up" + Environment.NewLine);
break;
case ApplicationGesture.Down:
outputText.AppendText("Gesture: Down" + Environment.NewLine);
break;
case ApplicationGesture.Up:
outputText.AppendText("Gesture: Up" + Environment.NewLine);
break;
default:
break;
}
}
推荐答案
经过一番挖掘,我发现延迟实际上是故意的,并导致手势无法识别和完成.不幸的是,无法修改此超时(请参阅: https://msdn.microsoft.com /en-us/library/ms827533.aspx ).
After some digging I found that the delay was actually intentional and served as a timeout for a gesture to be recognized and complete. Unfortunately, this timeout cannot be modified (see: https://msdn.microsoft.com/en-us/library/ms827533.aspx).
我不得不将墨水收集模式更改为:
I had to change the ink collection mode to:
inkCollector.CollectionMode = CollectionMode.InkAndGesture;
并将墨迹渲染禁用到控件上:
and disable the ink rendering onto control:
inkCollector.DynamicRendering = false;
这篇关于处理触摸和手势事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!