Processing Touch and Gesture Events

穿精又带淫゛_ 提交于 2019-12-22 00:39:05

问题


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.

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.

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?

My initialization code is below:

  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;
                }
            }

回答1:


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;


来源:https://stackoverflow.com/questions/28586942/processing-touch-and-gesture-events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!