Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
InkCollector Class
InkCollector Events
 Gesture Event
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
InkCollector..::.Gesture Event

Occurs when an application gesture is recognized.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)
Visual Basic (Declaration)
Public Event Gesture As InkCollectorGestureEventHandler
Visual Basic (Usage)
Dim instance As InkCollector
Dim handler As InkCollectorGestureEventHandler

AddHandler instance.Gesture, handler
C#
public event InkCollectorGestureEventHandler Gesture
Visual C++
public:
 event InkCollectorGestureEventHandler^ Gesture {
    void add (InkCollectorGestureEventHandler^ value);
    void remove (InkCollectorGestureEventHandler^ value);
}
JScript
JScript does not support events.

For this event to occur, the InkCollector object must have interest in a set of application gestures. To set the InkCollector object's interest in a set of gestures, call the SetGestureStatus method.

For a list of specific application gestures, see the ApplicationGesture enumeration. For more information about application gestures, see Pen Input, Ink, and Recognition.

The event handler receives an argument of type InkCollectorGestureEventArgs that contains data about this event.

When you create an InkCollectorGestureEventHandler delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate.

When the CollectionMode property is set to GestureOnly, the timeout between when a user adds a gesture and when the Gesture event occurs is a fixed value that you cannot alter programmatically. Gesture recognition is faster in InkAndGesture mode.

To prevent the collection of ink while in InkAndGesture mode:

Set CollectionMode to InkAndGesture.

  • Delete the Stroke object in the Stroke event.

  • Process the gesture in the Gesture event.

To prevent the flow of ink while gesturing, set the DynamicRendering property to false.

In addition to while the user inserts ink, the Gesture event fires when the InkCollector object is in select or erase mode. You are responsible for tracking the editing mode and should be aware of the mode before interpreting the event.

NoteNote:

To recognize gestures, you must use an object or control that can collect ink.

NoteNote:

The InkCollector object uses the InkCollectorGestureEventHandler delegate to add a gesture event handler.

The event handler is this example displays application gesture information on a status bar label, statusLabelAppGesture.

Visual Basic
Private Sub Event_OnApplicationGesture(ByVal sender As Object, ByVal e As InkCollectorGestureEventArgs)

    ' There might be more than one gesture passed in InkCollectorGestureEventArgs
    ' The gestures are arranged in order of confidence from most to least
    ' This event handler is only concerned with the first (most confident) gesture
    Dim G As Gesture = e.Gestures(0)

    ' we will use the gesture if it has confidence of strong or intermediate

    If G.Confidence = RecognitionConfidence.Intermediate Or _
    G.Confidence = RecognitionConfidence.Strong Then

        Select Case G.Id
            Case ApplicationGesture.Left
                statusLabelAppGesture.Text = "Left"
            Case ApplicationGesture.Right
                statusLabelAppGesture.Text = "Right"
            Case ApplicationGesture.Up
                statusLabelAppGesture.Text = "Up"
            Case ApplicationGesture.Down
                statusLabelAppGesture.Text = "Down"
        End Select

    End If
End Sub
C#
void Event_OnApplicationGesture(object sender, InkCollectorGestureEventArgs e)
{
    // There might be more than one gesture passed in InkCollectorGestureEventArgs
    // The gestures are arranged in order of confidence from most to least
    // This event handler is only concerned with the first (most confident) gesture
    Gesture G = e.Gestures[0];

    // we will use the gesture if it has confidence of strong or intermediate

    if (G.Confidence == RecognitionConfidence.Intermediate ||
        G.Confidence == RecognitionConfidence.Strong)
    {

        switch (G.Id)
        {
            case ApplicationGesture.Left:
                statusLabelAppGesture.Text = "Left";
                break;
            case ApplicationGesture.Right:
                statusLabelAppGesture.Text = "Right";
                break;
            case ApplicationGesture.Up:
                statusLabelAppGesture.Text = "Up";
                break;
            case ApplicationGesture.Down:
                statusLabelAppGesture.Text = "Down";
                break;
        }
    }

}

Only application gestures in which you have expressed an interest will fire this event. In this example, the InkCollector object, mInkCollector expresses an interest in four gestures of the ApplicationGesture enumeration.

Visual Basic
' set InkCollector interest in the Left, Right, Up, Down gestures
mInkCollector.SetGestureStatus(ApplicationGesture.Left, True)
mInkCollector.SetGestureStatus(ApplicationGesture.Right, True)
mInkCollector.SetGestureStatus(ApplicationGesture.Up, True)
mInkCollector.SetGestureStatus(ApplicationGesture.Down, True)
C#
// set InkCollector interest in the Left, Right, Up, Down gestures
mInkCollector.SetGestureStatus(ApplicationGesture.Left, true);
mInkCollector.SetGestureStatus(ApplicationGesture.Right, true);
mInkCollector.SetGestureStatus(ApplicationGesture.Up, true);
mInkCollector.SetGestureStatus(ApplicationGesture.Down, true);

Prior to collection of ink and gestures, the InkCollector object, mInkCollector registers the event handler.

Visual Basic
' register the Gesture event handler
AddHandler mInkCollector.Gesture, New InkCollectorGestureEventHandler(AddressOf Event_OnApplicationGesture)
C#
// register the Gesture event handler
mInkCollector.Gesture += new InkCollectorGestureEventHandler(Event_OnApplicationGesture);

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker