This documentation is archived and is not being maintained.

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

'Declaration
Public NotInheritable Class GestureRecognizer _
	Inherits DependencyObject _
	Implements IDisposable
'Usage
Dim instance As GestureRecognizer
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 Function InterpretScratchoutGesture(ByVal stroke As Stroke) As Boolean 
    ' Attempt to instantiate a recognizer for scratchout gestures. 
    Dim gestures() As ApplicationGesture = {ApplicationGesture.ScratchOut}

    Dim recognizer As New GestureRecognizer(gestures)

    If Not recognizer.IsRecognizerAvailable Then 
        Return False 
    End If 

    ' Determine if the stroke was a scratchout gesture. 
    Dim gestureStrokes As StrokeCollection = New StrokeCollection()
    gestureStrokes.Add(stroke)

    Dim results As ReadOnlyCollection(Of GestureRecognitionResult)
    results = recognizer.Recognize(gestureStrokes)

    If results.Count = 0 Then 
        Return False 
    End If 

    ' Results are returned sorted in order strongest-to-weakest;  
    ' we need only analyze the first (strongest) result. 
    If (results(0).ApplicationGesture = ApplicationGesture.ScratchOut) Then 

        ' 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 
    End If 
End Function

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
Show: