次の方法で共有


Stroke.SetPacketValuesByProperty メソッド (Guid, Int32, array<Int32[])

Stroke オブジェクト内の 1 つのパケットの指定されたパケット プロパティのデータを設定します。

名前空間 :  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

パラメータ

  • id
    型 : System.Guid
    設定するパケット データの選択に使用される PacketProperty オブジェクトの Guid 識別子。PacketDescription プロパティを使用して、この Stroke オブジェクトの定義されたプロパティを確認します。
  • index
    型 : System.Int32
    変更するパケットの開始位置インデックス。
  • 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)
        ' 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