Compartir a través de


InkPicture.SystemGesture Event

Occurs when a system gesture is recognized.

Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in microsoft.ink.dll)

Syntax

'Declaration
Public Event SystemGesture As InkCollectorSystemGestureEventHandler
'Usage
Dim instance As InkPicture
Dim handler As InkCollectorSystemGestureEventHandler

AddHandler instance.SystemGesture, handler
public event InkCollectorSystemGestureEventHandler SystemGesture
public:
event InkCollectorSystemGestureEventHandler^ SystemGesture {
    void add (InkCollectorSystemGestureEventHandler^ value);
    void remove (InkCollectorSystemGestureEventHandler^ value);
}
/** @event */
public void add_SystemGesture (InkCollectorSystemGestureEventHandler value)

/** @event */
public void remove_SystemGesture (InkCollectorSystemGestureEventHandler value)
In JScript, you can handle the events defined by a class, but you cannot define your own.
Not applicable.

Remarks

System gestures give information about the Cursor object that is being used to create the gesture. They also provide shortcuts to combinations of mouse events and are effective ways to detect mouse events.

For example, instead of listening for a MouseUpMouseUp and MouseDownMouseDown pair of events with no other mouse events occurring in between, you can listen for the Tap or RightTap system gestures.

As another example, instead of listening for MouseDownMouseDown and MouseMoveMouseMove events and getting numerous MouseMoveMouseMove messages, you can listen for the Drag or RightDrag system gestures, as long as you do not need the (x, y) coordinates of every position of the mouse. This allows you to receive only one message instead of numerous MouseMoveMouseMove messages.

For a list of specific system gestures, see the SystemGesture enumeration type. For more information about system gestures, see Using Gestures and Command Input on the Tablet PC.

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

When you create an InkCollectorSystemGestureEventHandler 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.

Example

This C# example displays gesture event information in the status bar of the main form window. Start with a generic generated application, add an InkPicture control, theInkPicture, add a status bar, theStatusBar to the main form, and then add the following code

[C#]

//...
using Microsoft.Ink;

namespace CSGestureEvents
{
    public class Form1 : System.Windows.Forms.Form
    {
        private System.Windows.Forms.StatusBar theStatusBar;
        private Microsoft.Ink.InkPicture theInkPicture;
        // ... The generated code will be here.
        //Add this code following the implementation of Main():

        private void Form1_Load(object sender, System.EventArgs e)
        {
            theInkPicture.CollectionMode = CollectionMode.InkAndGesture;
            ClearAppGestures();
            // Turn on interest in the ChevronDown and ChevronUp application gestures.
            theInkPicture.SetGestureStatus(ApplicationGesture.ChevronDown, true);
            theInkPicture.SetGestureStatus(ApplicationGesture.ChevronUp, true);
            theInkPicture.Gesture += new InkCollectorGestureEventHandler(Gesture_Event);
            theInkPicture.SystemGesture += new InkCollectorSystemGestureEventHandler(SystemGesture_Event);
            theInkPicture.InkEnabled = 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 InkPicture.
        private void ClearAppGestures()
        {
            ApplicationGesture test = ApplicationGesture.NoGesture;
            System.Array theGestureIds = System.Enum.GetValues(test.GetType());
            foreach (ApplicationGesture theGestureId in theGestureIds)
            {
                theInkPicture.SetGestureStatus(theGestureId, false);
            }
        }
    }
//...

This Microsoft® Visual Basic® .NET example displays gesture event information in the status bar of the main form window. Start with a generic generated application, add an InkPicture control, theInkPicture, add a status bar, theStatusBar to the main form, and then add the following code.

[Visual Basic]

Imports Microsoft.Ink
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "
    'This contains the standard generated form code
    Friend theStatusBar As System.Windows.Forms.StatusBar
    Friend theInkPicture As Microsoft.Ink.InkPicture
'...
#End Region


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Set the InkOverlay to collect both ink and gestures.
        theInkPicture.CollectionMode = CollectionMode.InkAndGesture
        'Clear interest in all of the application gestures
        ClearAppGestures()
        'Set the interest in only two gestures.
        theInkPicture.SetGestureStatus(ApplicationGesture.ChevronDown, True)
        theInkPicture.SetGestureStatus(ApplicationGesture.ChevronUp, True)
        'Add the handlers for application and system gestures.
        AddHandler theInkPicture.Gesture, AddressOf Gesture_Event
        AddHandler theInkPicture.SystemGesture, AddressOf SystemGesture_Event
        theInkPicture.InkEnabled = 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
            theInkPicture.SetGestureStatus(theGestureId, False)
        Next
    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

InkPicture Class
InkPicture Members
Microsoft.Ink Namespace
Cursor
InkCollectorSystemGestureEventArgs
SystemGesture

Other Resources

Using Gestures