次の方法で共有


InkOverlay.DesiredPacketDescription プロパティ

InkOverlay オブジェクトで描画されるインクに関連付けられたパケットの側面における対象を取得または設定します。

名前空間 :  Microsoft.Ink
アセンブリ :  Microsoft.Ink (Microsoft.Ink.dll 内)

構文

'宣言
<BrowsableAttribute(False)> _
Public Property DesiredPacketDescription As Guid()
'使用
Dim instance As InkOverlay
Dim value As Guid()

value = instance.DesiredPacketDescription

instance.DesiredPacketDescription = value
[BrowsableAttribute(false)]
public Guid[] DesiredPacketDescription { get; set; }
[BrowsableAttribute(false)]
public:
property array<Guid>^ DesiredPacketDescription {
    array<Guid>^ get ();
    void set (array<Guid>^ value);
}
/** @property */
/** @attribute BrowsableAttribute(false) */
public Guid[] get_DesiredPacketDescription()
/** @property */
/** @attribute BrowsableAttribute(false) */
public  void set_DesiredPacketDescription(Guid[] value)
public function get DesiredPacketDescription () : Guid[]
public function set DesiredPacketDescription (value : Guid[])

プロパティ値

型 : array<System.Guid[]
Guid オブジェクトの配列。それぞれが InkOverlay オブジェクトで描画されるインクに関連付けられたパケットの側面を表します。

解説

パケットの説明は PacketProperty オブジェクトの Guid オブジェクトの配列です。

既定では、DesiredPacketDescription は、PacketProperty オブジェクトの XY、および NormalPressure を格納します。DesiredPacketDescription をこれ以外のものに設定する場合、X および Y も追加されます。たとえば、DesiredPacketDescription を ButtonPressure にのみ設定する場合、{ButtonPressure} のみではなく、{X、Y、ButtonPressure} が返されます。

DesiredPacketDescription が PacketStatus を含むものに設定される場合、PacketStatus が 3 番目の位置に追加されます。たとえば、DesiredPacketDescription を (a、b、c、d、PacketStatus、e、f) に設定する場合、(X、Y、PacketStatus、a、b、c、d、e、f) が返されます。

マルチタブレット モードでは、これはすべてのタブレット デバイスのパケットの説明です。デバイスがどれも既知のパケット説明のプロパティをサポートしない場合、プロパティ データは返されません。

  • このプロパティの変更は Enabled プロパティが false から true に変更されるまで受信パケット データに影響しません。

次の例では、DesiredPacketDescription プロパティを使用して、PacketProperty オブジェクトの特定の Guid オブジェクトを追跡し、次に、NewPackets イベント中に、公開されたパケット プロパティを使用する方法を示します。

最初に、DesiredPacketDescription プロパティが初期化され、イベント ハンドラが割り当てられます。

' Express interest in PacketStatus, TimerTick, and NormalPressure
' X and Y will be added automatically
Dim PacketDesc As Guid() = New Guid() _
    { _
        PacketProperty.PacketStatus, _
        PacketProperty.TimerTick, _
        PacketProperty.NormalPressure _
    }

' mInkObject can be InkCollector, InkOverlay, or InkPicture
mInkObject.DesiredPacketDescription = PacketDesc
' assign event handlers
AddHandler mInkObject.CursorInRange, New InkCollectorCursorInRangeEventHandler(AddressOf mInkObject_CursorInRange)
AddHandler mInkObject.NewPackets, New InkCollectorNewPacketsEventHandler(AddressOf mInkObject_NewPackets)
// Express interest in PacketStatus, TimerTick, and NormalPressure
// X and Y will be added automatically
Guid[] PacketDesc = new Guid[] 
{
    PacketProperty.PacketStatus,
    PacketProperty.TimerTick,
    PacketProperty.NormalPressure
};
// mInkObject can be InkCollector, InkOverlay, or InkPicture
mInkObject.DesiredPacketDescription = PacketDesc;
// assign event handlers
mInkObject.CursorInRange += new InkCollectorCursorInRangeEventHandler(mInkObject_CursorInRange);
mInkObject.NewPackets += new InkCollectorNewPacketsEventHandler(mInkObject_NewPackets);

CursorInRange イベントが発生するときに、InkOverlay オブジェクトがこの特定の Cursor オブジェクトとやり取りを行ったのがこれが初めてであるかどうかを確認するチェックが行われます。初めてである場合は、DefaultDrawingAttributes プロパティの複製を使用して、DrawingAttributes プロパティが割り当てられます。これにより、以降の DrawingAttributes プロパティへのアクセスで、Null 参照例外がスローされなくなります。

Private Sub mInkObject_CursorInRange(ByVal sender As Object, ByVal e As InkCollectorCursorInRangeEventArgs)
    Const MOUSE_CURSOR_ID As Integer = 1
    If e.NewCursor Then
        ' mInkObject can be InkCollector, InkOverlay, or InkPicture
        e.Cursor.DrawingAttributes = mInkObject.DefaultDrawingAttributes.Clone()
        ' if this cursor is the mouse, we'll set color to red
        If (MOUSE_CURSOR_ID = e.Cursor.Id) Then
            e.Cursor.DrawingAttributes.Color = Color.Red
        End If

    End If
End Sub
private void mInkObject_CursorInRange(object sender, InkCollectorCursorInRangeEventArgs e)
{
    const int MOUSE_CURSOR_ID = 1;

    if (e.NewCursor)
    {
        // mInkObject can be InkCollector, InkOverlay, or InkPicture
        e.Cursor.DrawingAttributes = mInkObject.DefaultDrawingAttributes.Clone();
        // if this cursor is the mouse, we'll set color to red
        if (MOUSE_CURSOR_ID == e.Cursor.Id)
        {
            e.Cursor.DrawingAttributes.Color = Color.Red;
        }
    }
}

NewPackets イベントが発生するときに、NormalPressure がパケット データに含まれているかどうかを確認するチェックが行われます。含まれている場合、圧力情報がステータス ラベルに表示され、DrawingAttributes プロパティが変更されます。

Private Sub mInkObject_NewPackets(ByVal sender As Object, ByVal e As InkCollectorNewPacketsEventArgs)

    ' find the NormalPressure PacketProperty
    ' Set NormalPressure to -1 if not there, as some digitizers won't support it
    Dim PacketDesc As Guid() = e.Stroke.PacketDescription
    Dim NormalPressure As Integer = -1

    For k As Integer = 0 To PacketDesc.Length - 1
        If PacketDesc(k) = PacketProperty.NormalPressure Then
            ' for simplicity, in case of multiple packets, use the first packet only
            NormalPressure = e.PacketData(k)
        End If
    Next k

    ' If we have the NormalPressure information
    ' change DrawingAttributes according to the NormalPressure
    ' Note that the change does not take effect until the next stroke
    If NormalPressure <> -1 Then
        ' display the pressure on a status label
        Me.statusLabelPressure.Text = NormalPressure.ToString()
        e.Cursor.DrawingAttributes.Width = NormalPressure * 4
        ' if pressure is above 127, change color to Red
        If NormalPressure > 127 Then
            e.Cursor.DrawingAttributes.Color = Color.Red
        Else
            e.Cursor.DrawingAttributes.Color = mInkObject.DefaultDrawingAttributes.Color
        End If
    End If

End Sub
private void mInkObject_NewPackets(object sender, InkCollectorNewPacketsEventArgs e)
{
    // find the NormalPressure PacketProperty
    // Set NormalPressure to -1 if not there, as some digitizers won't support it
    Guid[] PacketDesc = e.Stroke.PacketDescription;
    int NormalPressure = -1;
    for (int k = 0; k < PacketDesc.Length; k++)
    {
        if (PacketDesc[k] == PacketProperty.NormalPressure)
        {
            // for simplicity, in case of multiple packets, use the first packet only
            NormalPressure = e.PacketData[k];
        }
    }

    // If we have the NormalPressure information
    // change DrawingAttributes according to the NormalPressure
    // Note that the change does not take effect until the next stroke
    if (NormalPressure != -1)
    {
        // display the pressure on a status label
        this.statusLabelPressure.Text = NormalPressure.ToString();
        e.Cursor.DrawingAttributes.Width = NormalPressure * 4;
        // if pressure is above 127, change color to Red
        if (NormalPressure > 127)
        {
            e.Cursor.DrawingAttributes.Color = Color.Red;
        }
        else
        {
            e.Cursor.DrawingAttributes.Color = mInkObject.DefaultDrawingAttributes.Color;
        }
    }
}

プラットフォーム

Windows Vista

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 3.0

参照

参照

InkOverlay クラス

InkOverlay メンバ

Microsoft.Ink 名前空間

PacketProperty

Tablet