[英]Processing Touch and Gesture Events
我正在使用一個涉及手勢輸入的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/zh-cn/library/ms827533.aspx )。
我不得不將墨水收集模式更改為:
inkCollector.CollectionMode = CollectionMode.InkAndGesture;
並禁用墨水渲染到控件上:
inkCollector.DynamicRendering = false;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.