Share via


Stroke.GetPacketDescriptionPropertyMetrics Method

Returns the metrics for a given packet description type.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Syntax

'Declaration
Public Function GetPacketDescriptionPropertyMetrics ( _
    id As Guid _
) As TabletPropertyMetrics
'Usage
Dim instance As Stroke 
Dim id As Guid 
Dim returnValue As TabletPropertyMetrics 

returnValue = instance.GetPacketDescriptionPropertyMetrics(id)
public TabletPropertyMetrics GetPacketDescriptionPropertyMetrics(
    Guid id
)
public:
TabletPropertyMetrics GetPacketDescriptionPropertyMetrics(
    Guid id
)
public function GetPacketDescriptionPropertyMetrics(
    id : Guid
) : TabletPropertyMetrics

Parameters

Return Value

Type: Microsoft.Ink.TabletPropertyMetrics
Returns the metrics for a given packet description type.

Examples

In this example, each selected Stroke object of an InkOverlay object is modified so that each point of the second half of the stroke contains the maxium allowed NormalPressure packet value.

Using the GetPacketValuesByProperty method, the NormalPressure packet values for the second half of the Stroke object are obtained. The values are then set to the maximum allowed (as obtained via the GetPacketDescriptionPropertyMetrics method), and reapplied to the stroke using the SetPacketValuesByProperty method.

Try 
    For Each S As Stroke In mInkOverlay.Selection
        ' get the PacketProperty.NormalPressure metrics for the stroke 
        Dim metrics As TabletPropertyMetrics = S.GetPacketDescriptionPropertyMetrics(PacketProperty.NormalPressure)
        ' get the starting point 
        Dim startPt As Integer = S.PacketCount / 2
        ' get the NormalPressure values starting at startPt 
        Dim npValues() As Integer = S.GetPacketValuesByProperty(PacketProperty.NormalPressure, startPt)
        ' set the NormalPressure values to max 
        For k As Integer = 0 To npValues.Length - 1
            npValues(k) = metrics.Maximum
        Next 
        ' set the NormalPressure values starting at startPt
        S.SetPacketValuesByProperty(PacketProperty.NormalPressure, startPt, npValues)
    Next 

Catch ex As ArgumentException
    ' This exception will be raised if PacketProperty.NormalPressure is not supported 
    ' This will be the case if creating strokes with a mouse 
End Try
try
{
    foreach (Stroke S in mInkOverlay.Selection)
    {
        // get the PacketProperty.NormalPressure metrics for the stroke
        TabletPropertyMetrics metrics = S.GetPacketDescriptionPropertyMetrics(PacketProperty.NormalPressure);
        // get the starting point 
        int startPt = S.PacketCount / 2;
        // get the NormalPressure values starting at startPt 
        int[] npValues = S.GetPacketValuesByProperty(PacketProperty.NormalPressure, startPt);
        // set the NormalPressure values to max 
        for (int k = 0; k < npValues.Length; k++)
        {
            npValues[k] = metrics.Maximum;
        }
        // set the NormalPressure values starting at startPt
        S.SetPacketValuesByProperty(PacketProperty.NormalPressure, startPt, npValues);
    }
}
catch (ArgumentException)
{
    // This exception will be raised if PacketProperty.NormalPressure is not supported 
    // This will be the case if creating strokes with a mouse
}

Platforms

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

Stroke Class

Stroke Members

Microsoft.Ink Namespace

Stroke.GetPacketValuesByProperty

Stroke.SetPacketValuesByProperty

Tablet.GetPropertyMetrics