Edit

Share via


StylusPoint Struct

Definition

Represents a single data point collected from the digitizer and stylus.

C#
public struct StylusPoint : IEquatable<System.Windows.Input.StylusPoint>
Inheritance
StylusPoint
Implements

Examples

The following example gets property names and values for each StylusPoint in a StylusPointCollection. This example assumes that there is a TextBlock called packetOutput.

C#
private void WriteStylusPointValues(StylusPointCollection points)
{
    StylusPointDescription pointsDescription = points.Description;

    ReadOnlyCollection<StylusPointPropertyInfo> properties = 
        pointsDescription.GetStylusPointProperties();
    
    // Write the name and value of each property in
    // every stylus point.
    StringWriter packetWriter = new StringWriter();
    packetWriter.WriteLine("{0} stylus points", points.Count.ToString());
    foreach (StylusPoint 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 (int i = 0; i < pointsDescription.PropertyCount; ++i)
        {
            StylusPointProperty currentProperty = properties[i];

            // GetStylusPointPropertyName is defined below and returns the
            // name of the property.
            packetWriter.Write("{0}: ", GetStylusPointPropertyName(currentProperty));
            packetWriter.WriteLine(stylusPoint.GetPropertyValue(currentProperty).ToString());
        }
        packetWriter.WriteLine();
    }

    packetOutput.Text = packetWriter.ToString();
}
C#
// Use reflection to get the name of currentProperty.
private string GetStylusPointPropertyName(StylusPointProperty currentProperty)
{
    Guid guid = currentProperty.Id;

    // Iterate through the StylusPointProperties to find the StylusPointProperty
    // that matches currentProperty, then return the name.
    foreach (FieldInfo theFieldInfo
        in typeof(StylusPointProperties).GetFields())
    {
        StylusPointProperty property = (StylusPointProperty) theFieldInfo.GetValue(currentProperty);
        if (property.Id == guid)
        {
            return theFieldInfo.Name;
        }
    }
    return "Not found";
}

Remarks

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.

Constructors

StylusPoint(Double, Double, Single, StylusPointDescription, Int32[])

Initializes a new instance of the StylusPoint class using specified (x, y) coordinates, a pressureFactor, and additional parameters specified in the StylusPointDescription.

StylusPoint(Double, Double, Single)

Initializes a new instance of the StylusPoint class using specified (x, y) coordinates and pressure.

StylusPoint(Double, Double)

Initializes a new instance of the StylusPoint class using specified (x, y) coordinates.

Fields

MaxXY

Specifies the largest valid value for a pair of (x, y) coordinates.

MinXY

Specifies the smallest valid value for a pair of (x, y) coordinates.

Properties

Description

Gets or sets the StylusPointDescription that specifies the properties stored in the StylusPoint.

PressureFactor

Gets or sets a value between 0 and 1 that reflects the amount of pressure the stylus applies to the digitizer's surface when the StylusPoint is created.

X

Gets or sets the value for the x-coordinate of the StylusPoint.

Y

Gets or sets the y-coordinate of the StylusPoint.

Methods

Equals(Object)

Returns a value indicating whether the specified object is equal to the StylusPoint.

Equals(StylusPoint, StylusPoint)

Returns a Boolean value that indicates whether the two specified StylusPoint objects are equal.

Equals(StylusPoint)

Returns a Boolean value that indicates whether the specified StylusPoint is equal to the current StylusPoint.

GetHashCode()

Returns the hash code for this instance.

GetPropertyValue(StylusPointProperty)

Returns the value of the specified property.

HasProperty(StylusPointProperty)

Returns whether the current StylusPoint contains the specified property.

SetPropertyValue(StylusPointProperty, Int32)

Sets the specified property to the specified value.

ToPoint()

Converts a StylusPoint to a Point.

Operators

Equality(StylusPoint, StylusPoint)

Compares two specified StylusPoint objects and determines whether they are equal.

Explicit(StylusPoint to Point)

Casts the specified StylusPoint to a Point.

Inequality(StylusPoint, StylusPoint)

Returns a Boolean value which indicates whether the specified StylusPoint objects are unequal.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9