語言

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

備註

當使用者使用數位化器輸入墨水時,A StylusPoint 會收集資料。 由於數位化器報告的資訊因製造商而異,其特性 StylusPoint 可能有所不同。 為了判斷某性質是否屬於 StylusPoint,呼叫 方法 HasProperty 。 該 Description 性質包含 , StylusPointDescription 指定哪些屬性屬於 StylusPoint。 所有 StylusPoint 物件都包含指定 (x, y) 座標及壓力的屬性。

建構函式

名稱 Description
StylusPoint(Double, Double, Single, StylusPointDescription, Int32[])

使用指定的 (x, y) 座標、a StylusPoint、 及在 中pressureFactor指定的額外參數初始化類別的新StylusPointDescription實例。

StylusPoint(Double, Double, Single)

使用指定的 (x, y) 座標與壓力初始化該類別的新實例 StylusPoint 。

StylusPoint(Double, Double)

使用指定的 (x, y) 座標初始化該 StylusPoint 類別的新實例。

欄位

名稱 Description
MaxXY

指定一對 (x, y) 座標的最大有效值。

MinXY

指定一對(x, y)座標的最小有效值。

屬性

名稱 Description
Description

取得或設定 StylusPointDescription ,指定儲存在 中的 StylusPoint屬性。

PressureFactor

會設定一個介於0到1之間的數值,反映觸控筆在數位化器製作時 StylusPoint 施加的壓力大小。

X

取得或設定 的 x 座標 StylusPoint值。

Y

取得或設定 的 StylusPointy 座標。

方法

名稱 Description
Equals(Object)

回傳一個值,表示指定物件是否等於 。StylusPoint

Equals(StylusPoint, StylusPoint)

回傳一個布林值,表示兩個指定 StylusPoint 物件是否相等。

Equals(StylusPoint)

回傳一個布林值,指示指定的值 StylusPoint 是否等於當前 StylusPoint值。

GetHashCode()

傳回這個實例的哈希碼。

GetPropertyValue(StylusPointProperty)

回傳指定屬性的值。

HasProperty(StylusPointProperty)

回傳電流是否 StylusPoint 包含指定的性質。

SetPropertyValue(StylusPointProperty, Int32)

將指定的屬性設定為指定的值。

ToPoint()

將 StylusPoint 轉換成 Point。

運算子

名稱 Description
Equality(StylusPoint, StylusPoint)

比較兩個指定的 StylusPoint 物體,並判斷它們是否相等。

Explicit(StylusPoint to Point)

將指定的 StylusPointPoint鑄造成 。

Inequality(StylusPoint, StylusPoint)

回傳一個布林值,表示指定 StylusPoint 物件是否不相等。

適用於