GestureRecognizer Class

Recognizes ink gestures.

Namespace: System.Windows.Ink
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:

public sealed class GestureRecognizer : DependencyObject, IDisposable
public final class GestureRecognizer extends DependencyObject implements IDisposable
public final class GestureRecognizer extends DependencyObject implements IDisposable
 You cannot use this class in XAML. 

A GestureRecognizer identifies an ink gesture. You can set the GestureRecognizer to recognize all or a subset of application gestures. To set the GestureRecognizer to recognize a subset of the available gestures, pass an ApplicationGesture array to the constructor or use the SetEnabledGestures method. To determine whether a StrokeCollection contains a gesture, call the Recognize method.

The following example demonstrates how to determine whether a Stroke is a Scratchout gesture.

private bool InterpretScratchoutGesture(Stroke stroke)
    // Attempt to instantiate a recognizer for scratchout gestures.
    ApplicationGesture[] gestures = {ApplicationGesture.ScratchOut};
    GestureRecognizer recognizer = new GestureRecognizer(gestures);

    if (!recognizer.IsRecognizerAvailable)
        return false;

    // Determine if the stroke was a scratchout gesture.
    StrokeCollection gestureStrokes = new StrokeCollection();

    ReadOnlyCollection<GestureRecognitionResult> results = recognizer.Recognize(gestureStrokes);

    if (results.Count == 0)
        return false;

    // Results are returned sorted in order strongest-to-weakest; 
    // we need only analyze the first (strongest) result.
    if (results[0].ApplicationGesture == ApplicationGesture.ScratchOut &&
          results[0].RecognitionConfidence == RecognitionConfidence.Strong)
        // Use the scratchout stroke to perform hit-testing and 
        // erase existing strokes, as necessary.
        return true;
        // Not a gesture: display the stroke normally.
        return false;

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

.NET Framework

Supported in: 3.0