Export (0) Print
Expand All

GestureRecognizer Class

Recognizes ink gestures.

Namespace:  System.Windows.Ink
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public sealed class GestureRecognizer : DependencyObject, 
	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();
    gestureStrokes.Add(stroke);

    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;
    }
    else
    {
        // 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 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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.5, 3.0

Community Additions

ADD
Show:
© 2014 Microsoft