共用方式為


Stroke.SetPacketValuesByProperty 方法 (Guid, Int32, Int32, array<Int32[])

設定 Stroke 物件中某個封包範圍所指定 packet 屬性的資料。

命名空間:  Microsoft.Ink
組件:  Microsoft.Ink (在 Microsoft.Ink.dll 中)

語法

'宣告
Public Function SetPacketValuesByProperty ( _
    id As Guid, _
    index As Integer, _
    count As Integer, _
    packetValues As Integer() _
) As Integer
'用途
Dim instance As Stroke
Dim id As Guid
Dim index As Integer
Dim count As Integer
Dim packetValues As Integer()
Dim returnValue As Integer

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

參數

  • index
    型別:System.Int32
    要修改之封包的起始索引。
  • count
    型別:System.Int32
    筆劃中要修改的封包數,以及 packetValues 中值的數目。值為 -1 表示會修改所有封包。
  • packetValues
    型別:array<System.Int32[]
    封包資料值的陣列。如果陣列中任何值超出屬性的最小值或最大值,則方法會失敗。若要判斷屬性中值的範圍,請呼叫 GetPacketDescriptionPropertyMetrics 方法。

傳回值

型別:System.Int32
傳回所設定封包的實際數目。

備註

如果 packetValues 陣列的長度不正確,則這個方法會擲回例外狀況。

範例

在這個範例中,InkOverlay 物件的每個已選取 Stroke 物件都會經過修改,使筆劃前半部的每個點都會包含允許的最小 NormalPressure 封包值。

若使用 GetPacketValuesByProperty 方法,則會取得 Stroke 物件前半部的 NormalPressure 封包值。接著這些值會設定為允許的最小值 (透過 GetPacketDescriptionPropertyMetrics 方法取得),並且使用 SetPacketValuesByProperty 方法再次套用至筆劃。

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)
        ' we want to get half of the NormalPressure values
        Dim halfWayPt As Integer = S.PacketCount / 2
        ' get the NormalPressure values for the first half of the packets
        Dim npValues() As Integer = S.GetPacketValuesByProperty(PacketProperty.NormalPressure, 0, halfWayPt)
        ' set the NormalPressure values to min
        For k As Integer = 0 To npValues.Length - 1
            npValues(k) = metrics.Minimum
        Next
        ' set the NormalPressure values for the first half of the packets
        S.SetPacketValuesByProperty(PacketProperty.NormalPressure, 0, halfWayPt, 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);
        // we want to get half of the NormalPressure values
        int halfWayPt = S.PacketCount / 2;
        // get the NormalPressure values for the first half of the packets
        int[] npValues = S.GetPacketValuesByProperty(PacketProperty.NormalPressure, 0, halfWayPt);
        // set the NormalPressure values to min
        for (int k = 0; k < npValues.Length; k++)
        {
            npValues[k] = metrics.Minimum;
        }
        // set the NormalPressure values for the first half of the packets
        S.SetPacketValuesByProperty(PacketProperty.NormalPressure, 0, halfWayPt, 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