InkOverlay.Gesture Event
Occurs when an application gesture is recognized.
Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in microsoft.ink.dll)
Syntax
'Declaration
Public Event Gesture As InkCollectorGestureEventHandler
'Usage
Dim instance As InkOverlay
Dim handler As InkCollectorGestureEventHandler
AddHandler instance.Gesture, handler
public event InkCollectorGestureEventHandler Gesture
public:
event InkCollectorGestureEventHandler^ Gesture {
void add (InkCollectorGestureEventHandler^ value);
void remove (InkCollectorGestureEventHandler^ value);
}
/** @event */
public void add_Gesture (InkCollectorGestureEventHandler value)
/** @event */
public void remove_Gesture (InkCollectorGestureEventHandler value)
In JScript, you can handle the events defined by a class, but you cannot define your own.
Not applicable.
Remarks
For this event to occur, the InkOverlay object must have interest in a set of application gestures. To set the InkOverlay object's interest in a set of gestures, call the SetGestureStatus method.
For a list of specific application gestures, see the ApplicationGesture enumeration type. For more information about application gestures, see Command Input on the Tablet PC and Using Gestures.
The event handler receives an argument of type InkCollectorGestureEventArgs containing 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.
InkOverlay.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 in the Stroke event.
Process the gesture in the Gesture event.
To prevent the flow of ink while a user records a gesture, set the DynamicRendering property to false.
In addition to when inserting ink, the Gesture event fires when in select or erase mode. You are responsible for tracking the editing mode and should be aware of the mode before interpreting the event.
Note
To recognize gestures, you must use an object or control that can collect ink.
Note
The InkOverlay object uses the InkCollectorGestureEventHandler delegate to add a gesture event handler.
Example
This C# example displays gesture event information in the status bar, theStatusBar
, of the main form window. Start with a generic generated application, add the status bar to the main form, and then add the following code.
//...
using Microsoft.Ink;
namespace CSGestureEvents
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.StatusBar theStatusBar;
// ... The generated code will be here.
//Add this code following the implementation of Main():
InkOverlay theInkOverlay;
private void Form1_Load(object sender, System.EventArgs e)
{
// Initialize the InkOverlay object.
theInkOverlay = new InkOverlay(Handle);
theInkOverlay.CollectionMode = CollectionMode.InkAndGesture;
ClearAppGestures(theInkOverlay);
// Turn on interest in the ChevronDown application gesture.
theInkOverlay.SetGestureStatus(ApplicationGesture.ChevronDown, true);
theInkOverlay.SetGestureStatus(ApplicationGesture.ChevronUp, true);
theInkOverlay.Gesture += new InkCollectorGestureEventHandler(Gesture_Event);
theInkOverlay.SystemGesture += new InkCollectorSystemGestureEventHandler(SystemGesture_Event);
theInkOverlay.Enabled = true;
}
private void Gesture_Event(object sender,
InkCollectorGestureEventArgs e)
{
ApplicationGesture theGestureId = e.Gestures[0].Id;
theStatusBar.Text = theGestureId.ToString();
// Cancelling the gesture will cause the ink to remain.
if (theGestureId == ApplicationGesture.ChevronDown)
e.Cancel = true;
}
private void SystemGesture_Event(object sender,
InkCollectorSystemGestureEventArgs e)
{
SystemGesture theGestureId = e.Id;
theStatusBar.Text = "System: " + theGestureId.ToString() +
" " + e.Point.ToString();
}
// Set all of the ApplicationGestures' status
// to false on the InkOverlay object.
private void ClearAppGestures()
{
ApplicationGesture test = ApplicationGesture.NoGesture;
System.Array theGestureIds = System.Enum.GetValues(test.GetType());
foreach (ApplicationGesture theGestureId in theGestureIds)
{
theInkOverlay.SetGestureStatus(theGestureId, false);
}
}
// Event handler for the form's closed event
private void Form1_Closed(object sender, System.EventArgs e)
{
theInkOverlay.Dispose();
theInkOverlay = null;
}
}
}
This Microsoft Visual Basic .NET example displays gesture event information in the status bar, theStatusBar
, of the main form window. Start with a generic generated application, add the status bar to the main form, and then add the following code.
Imports Microsoft.Ink
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
'This contains the standard generated form code
Private theStatusBar As System.Windows.Forms.StatusBar
#End Region
Dim theInkOverlay As InkOverlay
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Initialize InkOverlay.
theInkOverlay = New InkOverlay(Handle)
'Set the InkOverlay to collect both ink and gestures.
theInkOverlay.CollectionMode = CollectionMode.InkAndGesture
'Clear interest in all of the application gestures
ClearAppGestures(theInkOverlay)
'Set the interest in only two gestures.
theInkOverlay.SetGestureStatus(ApplicationGesture.ChevronDown, True)
theInkOverlay.SetGestureStatus(ApplicationGesture.ChevronUp, True)
'Add the handlers for application and system gestures.
AddHandler theInkOverlay.Gesture, AddressOf Gesture_Event
AddHandler theInkOverlay.SystemGesture, AddressOf SystemGesture_Event
theInkOverlay.Enabled = True
End Sub
Private Sub Gesture_Event(ByVal sender As Object, _
ByVal e As InkCollectorGestureEventArgs)
Dim theGestureId As ApplicationGesture = e.Gestures(0).Id
theStatusBar.Text = theGestureId.ToString()
'Cancelling the gesture will cause the ink to remain.
If theGestureId = ApplicationGesture.ChevronDown Then
e.Cancel = True
End If
End Sub
Private Sub SystemGesture_Event( _
ByVal sender As Object, _
ByVal e As InkCollectorSystemGestureEventArgs)
Dim theGestureId As SystemGesture = e.Id
theStatusBar.Text = "System: " + theGestureId.ToString() + " " + e.Point.ToString()
End Sub
' Set all of the ApplicationGestures' status
' to false on the InkOverlay object.
Private Sub ClearAppGestures()
Dim test As ApplicationGesture = ApplicationGesture.NoGesture
Dim theGestureIds As System.Array = System.Enum.GetValues(test.GetType())
Dim theGestureId As ApplicationGesture
For Each theGestureId In theGestureIds
theInkOverlay.SetGestureStatus(theGestureId, False)
Next
End Sub
'Event handler for the form's closed event
Private Sub Form1_Closed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Closed
theInkOverlay.Dispose()
Set theInkOverlay = Nothing
End Sub
End Class
Platforms
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
Version Information
.NET Framework
Supported in: 3.0
See Also
Reference
InkOverlay Class
InkOverlay Members
Microsoft.Ink Namespace
ApplicationGesture
InkCollectorGestureEventArgs
InkOverlay.SetGestureStatus