StylusPoint 结构

定义

表示从数字化仪和触笔收集到的单个数据点。

public value class StylusPoint : IEquatable<System::Windows::Input::StylusPoint>
public struct StylusPoint : IEquatable<System.Windows.Input.StylusPoint>
type StylusPoint = struct
Public Structure StylusPoint
Implements IEquatable(Of StylusPoint)
继承
StylusPoint
实现

示例

以下示例获取 中StylusPointCollection每个 StylusPoint 的属性名称和值。 此示例假定有一个名为 TextBlockpacketOutput

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();
}
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 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
// 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";
}
' 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

注解

StylusPoint当用户使用数字化器输入墨迹时,收集数据。 由于数字化器报告的信息因制造商而异,因此 中的 StylusPoint 属性可能会有所不同。 若要确定 属性是否位于 中 StylusPoint,请调用 HasProperty 方法。 属性 Description 包含一个 StylusPointDescription ,它指定 哪些属性位于 中 StylusPoint。 所有对象都包含 StylusPoint 指定 (x、y) 坐标以及压力的属性。

构造函数

StylusPoint(Double, Double)

使用指定的 (x, y) 坐标初始化 StylusPoint 类的新实例。

StylusPoint(Double, Double, Single)

使用指定的 (x, y) 坐标和压力初始化 StylusPoint 类的新实例。

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

使用指定 (x, y) 坐标、pressureFactor 和在 StylusPointDescription 中指定的其他参数初始化 StylusPoint 的新实例。

字段

MaxXY

指定 (x, y) 坐标对的最大有效值。

MinXY

指定 (x, y) 坐标对的最小有效值。

属性

Description

获取或设置 StylusPointDescription,它用于指定 StylusPoint 中存储的属性。

PressureFactor

获取或设置一个介于 0 和 1 之间的值,以反映在创建 StylusPoint 时,触笔施加于数字化仪图面的压力大小。

X

获取或设置 StylusPoint 的 X 坐标值。

Y

获取或设置 StylusPoint 的 Y 坐标。

方法

Equals(Object)

返回一个值,该值指示指定对象是否与 StylusPoint 相等。

Equals(StylusPoint)

返回一个布尔值,该值指示指定 StylusPoint 是否与当前的 StylusPoint 相等。

Equals(StylusPoint, StylusPoint)

返回一个布尔值,该值指示指定的两个 StylusPoint 对象是否相等。

GetHashCode()

返回此实例的哈希代码。

GetPropertyValue(StylusPointProperty)

返回指定的属性的值。

HasProperty(StylusPointProperty)

返回当前 StylusPoint 是否包含指定属性。

SetPropertyValue(StylusPointProperty, Int32)

将指定属性设置为指定值。

ToPoint()

StylusPoint 转换为 Point

运算符

Equality(StylusPoint, StylusPoint)

比较指定的两个 StylusPoint 对象,并确定它们是否相等。

Explicit(StylusPoint to Point)

将指定的 StylusPoint 强制转换为 Point

Inequality(StylusPoint, StylusPoint)

返回一个布尔值,该值指示指定的 StylusPoint 对象是否不相等。

适用于