处理触摸和手势事件

我正在开发一个GUI,它涉及来自连接到Windows 7机器的电容式触摸面板的手势输入。 操作系统安装了Tablet PC支持驱动程序,这些驱动程序应该是唯一的通信方式。

我的主要方法是使用在Microsoft.ink.dll中引用的InkCollector类。 它使我能够访问足以实现我正在寻找的行为的SystemGesture事件。

现在问题是SystemGesture.Flick事件在大约一整秒后非常缓慢地到达。 我知道正在处理以识别Flick,但它仍然使这个想法变得不可行。

有关如何加快速度的任何想法?

我的初始化代码如下:

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 )。

我不得不将墨水收集模式更改为:

 inkCollector.CollectionMode = CollectionMode.InkAndGesture; 

并禁用墨水渲染到控件:

 inkCollector.DynamicRendering = false;