繁体   English   中英

处理触摸和手势事件

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM