StylusDevice..::.GetStylusPoints Method Home
This page is specific to:Microsoft Version:Silverlight 3
.NET Framework Class Library for Silverlight
StylusDevice..::.GetStylusPoints Method

Returns the stylus points collected since the last mouse event.

Namespace:  System.Windows.Input
Assembly:  System.Windows (in System.Windows.dll)
Syntax

'Usage

Dim instance As StylusDevice
Dim relativeTo As UIElement
Dim returnValue As StylusPointCollection

returnValue = instance.GetStylusPoints(relativeTo)

'Declaration

Public Function GetStylusPoints ( _
    relativeTo As UIElement _
) As StylusPointCollection

Parameters

relativeTo
Type: System.Windows..::.UIElement
Specifies the offset for the object (typically an InkPresenter) that should be applied to captured points.

Return Value

Type: System.Windows.Input..::.StylusPointCollection
A collection of the stylus points collected since the last mouse event.
Remarks

The coordinates of the returned StylusPointCollection points are relative to the InkPresenter that is passed into the method.

If the active device is a mouse, the returned StylusPointCollection contains a single point that corresponds to the mouse event.

Examples

The following code snippet iterates through stylus points of the strokes drawn in the first InkPresenter control to display its mirror image in the second InkPresenter control.

    Private MyStroke As Stroke

    Public Sub New()
        MyBase.New()
        InitializeComponent()
        SetBoundaryForIP1()
        SetBoundaryForIP2()
    End Sub

    'A new stroke object, MyStroke, is created and is added to the StrokeCollection object
    'of the InkPresenter, MyIP1
    Private Sub MyIP1_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseEventArgs)
        MyIP1.CaptureMouse()
        Dim MyStylusPointCollection As StylusPointCollection = New StylusPointCollection
        MyStylusPointCollection.Add(e.StylusDevice.GetStylusPoints(MyIP1))
        MyStroke = New Stroke(MyStylusPointCollection)
        MyIP1.Strokes.Add(MyStroke)
    End Sub

    'StylusPoint objects are collected from the MouseEventArgs and added to MyStroke
    Private Sub MyIP1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
        If (Not (MyStroke) Is Nothing) Then
            MyStroke.StylusPoints.Add(e.StylusDevice.GetStylusPoints(MyIP1))
        End If
    End Sub

    'MyStroke is completed
    Private Sub MyIP1_LostMouseCapture(ByVal sender As Object, ByVal e As MouseEventArgs)
        MyStroke = Nothing
    End Sub

    'Create the mirror image of the stroke collection in MyIP1 and adding it to MyIP2
    Private Sub BtMirror_Click(ByVal sender As Object, ByVal e As EventArgs)
        'Iterate through the Strokes in the StrokeCollection of MyIP1
        For Each stroke As Stroke In MyIP1.Strokes
            Dim newcollection As StylusPointCollection = New StylusPointCollection
            'Iterate through the stylus points of each stroke in MyIP1
            For Each p As StylusPoint In stroke.StylusPoints
                'Create the mirror image
                Dim newpoint As StylusPoint = New StylusPoint
                newpoint.X = (MyIP1.ActualWidth - p.X)
                newpoint.Y = p.Y
                newcollection.Add(newpoint)
            Next
            'Add the mirror image to MyIP2
            Dim newStroke As Stroke = New Stroke(newcollection)
            MyIP2.Strokes.Add(newStroke)
        Next
    End Sub



Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Other Resources

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View