none
Detecting gestures such as double tap,exclamation and Curlicue RRS feed

  • Question

  • hi,
    may i know how a double tap,exclamation and Curlicue gesture are done? for tap, it is not a problem....however for a double tap...i can't seem to get it although i double click the mouse fast. it will be detected as two separate taps. The same case for exclamation which it detect a Down gesture. Lastly how to draw curlicue?

    i use the below functions:

     ReadOnlyCollection<GestureRecognitionResult> gestureResults = e.GetGestureRecognitionResults();

                // Check the first recognition result for a gesture.
                if (gestureResults[0].RecognitionConfidence ==
                    RecognitionConfidence.Strong)
    {
                    switch (gestureResults[0].ApplicationGesture)
               {
                        case ApplicationGesture.ArrowDown:
    //do something....

    .....

    }
    }



    Thanks for any help
    Tuesday, October 23, 2007 9:21 AM

Answers

All replies

  • Hi,

     

    I assume you are using WPF's InkCanvas to collect the ink / gestures, correct?

     

    InkCanvas' built-in gesture functionality does not support multi-stroke gesture. Thus you can not receive double-tap and exclamation.

     

    You can use the GestureRecognizer class [1] directly and feed it the strokes you have collected. That will you to detect multi-stroke gestures.

     

    To find a visual representation of a curlicue gesture, take a look at [2].

     

    Thanks,

    Stefan Wick

     

    Microsoft - Windows Experience

     

    [1] http://msdn2.microsoft.com/en-us/library/system.windows.ink.gesturerecognizer.aspx

    [2] http://msdn2.microsoft.com/en-us/library/ms704830.aspx

    Wednesday, October 24, 2007 4:25 AM
  • Hi,

    thanks for your helpful reply...however can you help to point me some simple example or codes on how to catch the double tap or excalmation gestures. Apart from that, double tap is considered as two strokes?

    Thanks in advance.
    Wednesday, October 24, 2007 7:13 AM
  • Here is some sample to demonstrate this. Note that for a real application you want to consider two strokes as a gesture only when they were collected in a short period time. This sample does not do this for the sake of simplicity.

     

    Thanks,

    Stefan Wick

     

    Microsoft - Windows Experience

     

    Code Block

    public partial class Window1 : Window
    {
        private GestureRecognizer recognizer;
        public Window1()
        {
            InitializeComponent();
            recognizer = new GestureRecognizer();
            recognizer.SetEnabledGestures(new ApplicationGesture[]{

              ApplicationGesture.DoubleTap, ApplicationGesture.Exclamation });
        }

     

        private void InkCanvas_StrokeCollected(object sender,

                                          InkCanvasStrokeCollectedEventArgs e)
        {
            int strokesCount = inkCanvas.Strokes.Count;
            if (strokesCount > 1)
            {
                StrokeCollection strokesToRecognize = new StrokeCollection();
                strokesToRecognize.Add(inkCanvas.Strokes[strokesCount - 1]);
                strokesToRecognize.Add(inkCanvas.Strokes[strokesCount - 2]);
                ReadOnlyCollection<GestureRecognitionResult> results =

                     recognizer.Recognize(strokesToRecognize);
                foreach (GestureRecognitionResult result in results)
                {
                    if (result.ApplicationGesture !=

                        ApplicationGesture.NoGesture)
                    {
                        Debug.WriteLine(result.ApplicationGesture);
                    }
                }
            }
        }
    }

     

     

    Wednesday, October 24, 2007 1:48 PM