StylusPoint 結構

定義

表示從數位板和手寫筆收集的單一資料點 (Data Point)。

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 物件是否不相等。

適用於