StylusPlugIn.OnStylusUpProcessed Method

Occurs on the application UI (user interface) thread when the user lifts the tablet pen from the digitizer.

Namespace:  System.Windows.Input.StylusPlugIns
Assembly:  PresentationCore (in PresentationCore.dll)

'Declaration
Protected Overridable Sub OnStylusUpProcessed ( _
	callbackData As Object, _
	targetVerified As Boolean _
)

Parameters

callbackData
Type: System.Object

The object that the application passed to the RawStylusInput.NotifyWhenProcessed method.

targetVerified
Type: System.Boolean

true if the pen's input was correctly routed to the StylusPlugIn; otherwise, false.

To subscribe to this method, call NotifyWhenProcessed in the OnStylusUp method

The following example creates a StylusPlugIn that checks for the Down gesture. The StylusPlugIn checks for the gesture in the OnStylusUpProcessed method, which is called from the application UI thread.

Class RecognizerPlugin
    Inherits StylusPlugIn
    Private recognizer As GestureRecognizer

    ' StylusPointCollection that contains the stylus points of the current 
    ' stroke. 
    Private points As StylusPointCollection

    ' Keeps track of the stylus to check whether two styluses are used on the 
    ' digitizer. 
    Private currentStylus As Integer 

    Public Sub New()
        recognizer = New GestureRecognizer()

    End Sub 'New 


    ' Collect the points as the user draws the stroke. 
    Protected Overrides Sub OnStylusDown(ByVal rawStylusInput As RawStylusInput)

        ' If points is not null, there is already a stroke taking place 
        ' on the digitizer, so don't create a new StylusPointsCollection. 
        If points Is Nothing Then
            points = New StylusPointCollection(rawStylusInput.GetStylusPoints().Description)
            points.Add(rawStylusInput.GetStylusPoints())
            currentStylus = rawStylusInput.StylusDeviceId
        End If 

    End Sub 'OnStylusDown

    ' Collect the points as the user draws the stroke. 
    Protected Overrides Sub OnStylusMove(ByVal rawStylusInput As RawStylusInput)

        ' Check whether the stylus that started the stroke is the same, and 
        ' that the element hasn't lost focus since the stroke began. 
        If Not (points Is Nothing) AndAlso currentStylus = rawStylusInput.StylusDeviceId Then
            points.Add(rawStylusInput.GetStylusPoints())
        End If 

    End Sub 'OnStylusMove

    ' Collect the points as the user draws the stroke. 
    Protected Overrides Sub OnStylusUp(ByVal rawStylusInput As RawStylusInput)

        ' Check whether the stylus that started the stroke is the same, and 
        ' that the element hasn't lost focus since the stroke began. 
        If Not (points Is Nothing) AndAlso currentStylus = rawStylusInput.StylusDeviceId Then
            points.Add(rawStylusInput.GetStylusPoints())

            ' Subscribe to the OnStylusUpProcessed method.
            rawStylusInput.NotifyWhenProcessed(points)
        End If

        points = Nothing
        currentStylus = 0

    End Sub 'OnStylusUp

    ' If the element loses focus, stop collecting the points and don't 
    ' perform gesture recognition. 
    Protected Overrides Sub OnStylusLeave(ByVal rawStylusInput As RawStylusInput, ByVal confirmed As Boolean)

        If confirmed Then 
            ' Clear the StylusPointCollection
            points = Nothing
            currentStylus = 0
        End If 

    End Sub 'OnStylusLeave

    ' This method is called on the application thread. 
    Protected Overrides Sub OnStylusUpProcessed(ByVal callbackData As Object, ByVal targetVerified As Boolean)

        ' Check that the element actually receive the OnStylusUp input. 
        If targetVerified AndAlso recognizer.IsRecognizerAvailable Then 

            Dim strokePoints As StylusPointCollection = callbackData

            If strokePoints Is Nothing Then 
                Return 
            End If 

            ' Create a StrokeCollection to pass to the GestureRecognizer. 
            Dim newStroke As New Stroke(strokePoints)
            Dim strokes As New StrokeCollection()
            strokes.Add(newStroke)

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

            ' If the GestureRecognizer recognizes the stroke as a Down 
            ' gesture with strong confidence, raise an event. 
            If results(0).ApplicationGesture = ApplicationGesture.Down AndAlso _
               results(0).RecognitionConfidence = RecognitionConfidence.Strong Then 
                'raise event 
            End If 
        End If 

    End Sub 'OnStylusUpProcessed 
End Class 'RecognizerPlugin

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft