Stroke.SetPacketValuesByProperty Method (Guid, array<Int32[])
Sets the data for a specified packet property for all packets in the Stroke object.
Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in Microsoft.Ink.dll)
Syntax
'Declaration
Public Function SetPacketValuesByProperty ( _
id As Guid, _
packetValues As Integer() _
) As Integer
'Usage
Dim instance As Stroke
Dim id As Guid
Dim packetValues As Integer()
Dim returnValue As Integer
returnValue = instance.SetPacketValuesByProperty(id, _
packetValues)
public int SetPacketValuesByProperty(
Guid id,
int[] packetValues
)
public:
int SetPacketValuesByProperty(
Guid id,
array<int>^ packetValues
)
public function SetPacketValuesByProperty(
id : Guid,
packetValues : int[]
) : int
Parameters
id
Type: System.GuidThe Guid identifier from the PacketProperty object that is used to select which packet data is set. Use the PacketDescription property to determine the defined properties for this Stroke object.
packetValues
Type: array<System.Int32[]The array of packet data values. The method fails if any of the values in the array exceed the minimum or maximum value of the property. To determine the range of values in the property, call the GetPacketDescriptionPropertyMetrics method.
Return Value
Type: System.Int32
Returns the actual number of packets set.
Remarks
All packets are modified.
This method throws an exception if the packetValues array is the incorrect length.
Examples
In this example, each selected Stroke object of an InkOverlay object is modified so that the NormalPressure packet always increases or remains constant throughout the points of the stroke.
Using the GetPacketValuesByProperty method, the NormalPressure packet values for the Stroke object are obtained and sorted into ascending order. The sorted values are then reapplied to the stroke using the SetPacketValuesByProperty method.
Try
For Each S As Stroke In mInkOverlay.Selection
' get the NormalPressure values
Dim npValues() As Integer = S.GetPacketValuesByProperty(PacketProperty.NormalPressure)
' sort them
Array.Sort(npValues)
' set the NormalPressure values
S.SetPacketValuesByProperty(PacketProperty.NormalPressure, 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 NormalPressure values
int[] npValues = S.GetPacketValuesByProperty(PacketProperty.NormalPressure);
// sort them
Array.Sort(npValues);
// set the NormalPressure values
S.SetPacketValuesByProperty(PacketProperty.NormalPressure, 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