다음을 통해 공유


InkOverlay.DesiredPacketDescription 속성

업데이트: 2007년 11월

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 개체의 X, YNormalPressure가 포함됩니다. DesiredPacketDescription을 다른 값으로 설정하면 XY도 추가됩니다. 예를 들어 DesiredPacketDescription을 ButtonPressure로만 설정하면 get이 {ButtonPressure}뿐만 아니라 {X, Y, ButtonPressure}도 반환합니다.

DesiredPacketDescription을 PacketStatus가 포함된 항목으로 설정하면 세 번째 위치에 PacketStatus가 추가됩니다. 예를 들어 DesiredPacketDescription을 (a, b, c, d, PacketStatus, e, f)로 설정하면 get이 (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 개체와 처음으로 접촉했는지 확인합니다. 확인에 성공하면 DrawingAttributes 속성에 DefaultDrawingAttributes 속성의 복제본이 할당됩니다. 이렇게 하면 이후에 DrawingAttributes 속성에 액세스할 때 null 참조 예외가 throw되지 않습니다.

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