StylusPoint.PressureFactor Propriété

Définition

Obtient ou définit une valeur entre 0 et 1 qui reflète la quantité de pression que le stylet applique à la surface du digitaliseur lorsque le StylusPoint est créé.Gets or sets a value between 0 and 1 that reflects the amount of pressure the stylus applies to the digitizer's surface when the StylusPoint is created.

public:
 property float PressureFactor { float get(); void set(float value); };
public float PressureFactor { get; set; }
member this.PressureFactor : single with get, set
Public Property PressureFactor As Single

Valeur de propriété

Single

Valeur entre 0 et 1 qui indique la quantité de pression que le stylet applique à la surface du digitaliseur lorsque le StylusPoint est créé.Value between 0 and 1 indicating the amount of pressure the stylus applies to the digitizer's surface as the StylusPoint is created.

Exceptions

La valeur affectée à la propriété PressureFactor est inférieure à 0 ou supérieure à 1.The PressureFactor property is set to a value less than 0 or greater than 1.

Exemples

L’exemple suivant utilise la PressureFactor propriété pour récupérer et afficher la valeur de pression pour chaque StylusPoint dans une StylusPointCollection appelée points .The following example uses the PressureFactor property to retrieve and display the pressure value for each StylusPoint in a StylusPointCollection called points. Cet exemple suppose qu’il existe un TextBlock appelé packetOutput .This example assumes that there is a TextBlock called 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

Remarques

La valeur de la PressureFactor propriété est exprimée sous la forme d’une valeur comprise entre 0 et 1.The value of the PressureFactor property is expressed as a value between 0 and 1. La valeur 0 indique qu’aucune pression n’est appliquée, tandis que la valeur 1 indique que la quantité maximale de pression est appliquée.A value of 0 indicates that no pressure is applied, while a value of 1 indicates that the maximum amount of pressure is applied. Une valeur de 0,5 indique que 50% de la pression maximale est appliqué, et ainsi de suite.A value of 0.5 indicates that 50% of the maximum pressure is applied, and so on.

S’applique à