Поделиться через


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. В этом примере предполагается, что вызывается 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, Single, StylusPointDescription, Int32[])

Инициализирует новый экземпляр StylusPoint класса с помощью указанных координат (x, y), а pressureFactorтакже дополнительных параметров, указанных в параметре StylusPointDescription.

StylusPoint(Double, Double, Single)

Инициализирует новый экземпляр StylusPoint класса с помощью указанных координат (x, y) и давления.

StylusPoint(Double, Double)

Инициализирует новый экземпляр StylusPoint класса с помощью указанных координат (x, y).

Поля

Имя Описание
MaxXY

Указывает наибольшее допустимое значение для пары координат (x, y).

MinXY

Задает наименьшее допустимое значение для пары координат (x, y).

Свойства

Имя Описание
Description

Возвращает или задает StylusPointDescription значение, указывающее свойства, хранящиеся в объекте StylusPoint.

PressureFactor

Возвращает или задает значение от 0 до 1, которое отражает объем давления пера, применяемого к поверхности дигитайзера при StylusPoint создании.

X

Возвращает или задает значение для координат x объекта StylusPoint.

Y

Возвращает или задает координату y объекта StylusPoint.

Методы

Имя Описание
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 объекты неравными.

Применяется к