语言

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
实现

示例

下面的示例获取一个StylusPoint中每个StylusPointCollection属性的属性名称和值。 此示例假定有一个 TextBlock 调用 packetOutput。

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, Single, StylusPointDescription, Int32[])

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

StylusPoint(Double, Double, Single)

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

StylusPoint(Double, Double)

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

字段

名称 说明
MaxXY

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

MinXY

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

属性

名称 说明
Description

获取或设置指定 StylusPointDescription 存储在 .. 中的 StylusPoint属性。

PressureFactor

获取或设置一个介于 0 和 1 之间的值,该值反映触笔在创建时 StylusPoint 应用于数字化器表面的压力量。

X

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

Y

获取或设置 . 的 StylusPointy 坐标。

方法

名称 说明
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 对象是否不相等。

适用于