Compartilhar via


StylusPoint Estrutura

Definição

Representa um único ponto de dados coletado do digitalizador e da caneta.

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)
Herança
StylusPoint
Implementações

Exemplos

O exemplo a seguir obtém nomes de propriedade e valores para cada StylusPoint um em um StylusPointCollection. Este exemplo pressupõe que há um TextBlock chamado 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

Comentários

Um StylusPoint coleta dados quando um usuário insira tinta usando o digitalizador. Como as informações que um digitalizador relata diferem dependendo do fabricante, as propriedades dentro de um StylusPoint podem variar. Para determinar se uma propriedade está no StylusPointmétodo , chame o HasProperty método. A Description propriedade contém um StylusPointDescription que especifica quais propriedades estão no StylusPoint. Todos os StylusPoint objetos contêm propriedades que especificam as coordenadas (x, y), bem como a pressão.

Construtores

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

Inicializa uma nova instância da StylusPoint classe usando coordenadas especificadas (x, y), um pressureFactore parâmetros adicionais especificados no StylusPointDescription.

StylusPoint(Double, Double, Single)

Inicializa uma nova instância da StylusPoint classe usando coordenadas e pressão especificadas (x, y).

StylusPoint(Double, Double)

Inicializa uma nova instância da StylusPoint classe usando coordenadas especificadas (x, y).

Campos

Nome Description
MaxXY

Especifica o maior valor válido para um par de coordenadas (x, y).

MinXY

Especifica o menor valor válido para um par de coordenadas (x, y).

Propriedades

Nome Description
Description

Obtém ou define o StylusPointDescription que especifica as propriedades armazenadas no StylusPoint.

PressureFactor

Obtém ou define um valor entre 0 e 1 que reflete a quantidade de pressão que a caneta aplica à superfície do digitalizador quando é StylusPoint criada.

X

Obtém ou define o valor da coordenada x do StylusPoint.

Y

Obtém ou define a coordenada y do StylusPoint.

Métodos

Nome Description
Equals(Object)

Retorna um valor que indica se o objeto especificado é igual ao StylusPoint.

Equals(StylusPoint, StylusPoint)

Retorna um valor booliano que indica se os dois objetos especificados StylusPoint são iguais.

Equals(StylusPoint)

Retorna um valor booliano que indica se o especificado StylusPoint é igual ao atual StylusPoint.

GetHashCode()

Retorna o código hash dessa instância.

GetPropertyValue(StylusPointProperty)

Retorna o valor da propriedade especificada.

HasProperty(StylusPointProperty)

Retorna se a atual StylusPoint contém a propriedade especificada.

SetPropertyValue(StylusPointProperty, Int32)

Define a propriedade especificada com o valor especificado.

ToPoint()

Converte um StylusPoint em um Point.

Operadores

Nome Description
Equality(StylusPoint, StylusPoint)

Compara dois objetos especificados StylusPoint e determina se eles são iguais.

Explicit(StylusPoint to Point)

Converte o especificado StylusPoint em um Point.

Inequality(StylusPoint, StylusPoint)

Retorna um valor booliano que indica se os objetos especificados StylusPoint são diferentes.

Aplica-se a