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


Stroke.SetPacketValuesByProperty - метод (Guid, Int32, array<Int32[])

Обновлен: Ноябрь 2007

Sets the data for a specified packet property for one packet in the Stroke object.

Пространство имен:  Microsoft.Ink
Сборка:  Microsoft.Ink (в Microsoft.Ink.dll)

Синтаксис

'Декларация
Public Function SetPacketValuesByProperty ( _
    id As Guid, _
    index As Integer, _
    packetValues As Integer() _
) As Integer
'Применение
Dim instance As Stroke
Dim id As Guid
Dim index As Integer
Dim packetValues As Integer()
Dim returnValue As Integer

returnValue = instance.SetPacketValuesByProperty(id, _
    index, packetValues)
public int SetPacketValuesByProperty(
    Guid id,
    int index,
    int[] packetValues
)
public:
int SetPacketValuesByProperty(
    Guid id, 
    int index, 
    array<int>^ packetValues
)
public int SetPacketValuesByProperty(
    Guid id,
    int index,
    int[] packetValues
)
public function SetPacketValuesByProperty(
    id : Guid, 
    index : int, 
    packetValues : int[]
) : int

Параметры

  • index
    Тип: System.Int32
    The starting index of the packet to be modified.
  • packetValues
    Тип: 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.

Возвращаемое значение

Тип: System.Int32
Returns the actual number of packets set.

Заметки

This method throws an exception if the packetValues array is the incorrect length.

Примеры

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
}

Платформы

Windows Vista

Среды .NET Framework и .NET Compact Framework поддерживают не все версии каждой платформы. Поддерживаемые версии перечислены в разделе Требования к системе для .NET Framework.

Сведения о версии

.NET Framework

Поддерживается в версии: 3.0

См. также

Ссылки

Stroke Класс

Stroke - члены

SetPacketValuesByProperty - перегрузка

Microsoft.Ink - пространство имен

PacketProperty

Stroke.GetPacketDescriptionPropertyMetrics