简体   繁体   中英

Processing Touch and Gesture Events

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

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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