StylusPoint Structure
Represents a single data point collected from the digitizer and stylus.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
A StylusPoint collects data when a user inputs ink using the digitizer. Because the information that a digitizer reports differs depending on the manufacturer, the properties within a StylusPoint can vary. To determine whether a property is in the StylusPoint, call the HasProperty method. The Description property contains a StylusPointDescription that specifies which properties are in the StylusPoint. All StylusPoint objects contain properties that specify the (x, y) coordinates, as well as the pressure.
The following example gets property names and values for each StylusPoint in a StylusPointCollection. This example assumes that there is a TextBlock called packetOutput.
Private Sub WriteStylusPointValues(ByVal points As StylusPointCollection) Dim pointsDescription As StylusPointDescription = points.Description Dim properties As ReadOnlyCollection(Of StylusPointPropertyInfo) = _ pointsDescription.GetStylusPointProperties() ' Write the name and and value of each property in ' every stylus point. Dim packetWriter As New StringWriter() packetWriter.WriteLine("{0} stylus points", points.Count.ToString()) For Each stylusPoint As StylusPoint In points packetWriter.WriteLine("Stylus Point info") packetWriter.WriteLine("X: {0}", stylusPoint.X.ToString()) packetWriter.WriteLine("Y: {0}", stylusPoint.Y.ToString()) packetWriter.WriteLine("Pressure: {0}", stylusPoint.PressureFactor.ToString()) ' Get the property name and value for each StylusPoint. ' Note that this loop reports the X, Y, and pressure values differantly than ' getting their values above. For i As Integer = 0 To pointsDescription.PropertyCount - 1 Dim currentProperty As StylusPointProperty = properties(i) ' GetStylusPointPropertyName is defined below and returns the ' name of the property. packetWriter.Write("{0}: ", GetStylusPointPropertyName(currentProperty)) packetWriter.WriteLine(stylusPoint.GetPropertyValue(currentProperty).ToString()) Next i packetWriter.WriteLine() Next stylusPoint packetOutput.Text = packetWriter.ToString() End Sub 'WriteStylusPointValues ... ' Use reflection to get the name of currentProperty. Private Function GetStylusPointPropertyName(ByVal currentProperty As StylusPointProperty) As String Dim guid As Guid = currentProperty.Id ' Iterate through the StylusPointProperties to find the StylusPointProperty ' that matches currentProperty, then return the name. Dim theFieldInfo As FieldInfo For Each theFieldInfo In GetType(StylusPointProperties).GetFields() Dim pointProperty As StylusPointProperty = _ CType(theFieldInfo.GetValue(currentProperty), StylusPointProperty) If pointProperty.Id = guid Then Return theFieldInfo.Name End If Next theFieldInfo Return "Not found" End Function 'GetStylusPointPropertyName
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.