Condividi tramite


Proprietà InkPicture.DesiredPacketDescription

Aggiornamento: novembre 2007

Ottiene o imposta un interesse negli aspetti dei pacchetti associati all'input penna disegnato sull'oggetto InkPicture.

Spazio dei nomi:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Sintassi

'Dichiarazione
<BrowsableAttribute(False)> _
Public Property DesiredPacketDescription As Guid()
'Utilizzo
Dim instance As InkPicture
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[])

Valore proprietà

Tipo: array<System.Guid[]
Matrice di oggetti Guid, ognuno dei quali rappresenta un aspetto dei pacchetti associato all'input penna disegnato sull'oggetto InkPicture.

Note

La descrizione del pacchetto è costituita da una matrice di oggetti Guid dell'oggetto PacketProperty.

Per impostazione predefinita, la proprietà DesiredPacketDescription include gli oggetti X, Y e NormalPressure dell'oggetto PacketProperty. Se si imposta la proprietà DesiredPacketDescription su qualsiasi altro parametro, saranno aggiunti anche gli oggetti X e Y. Ad esempio, se si imposta la proprietà DesiredPacketDescription soltanto su ButtonPressure, una funzione get restituisce {X, Y ButtonPressure} e non solo {ButtonPressure}.

Quando per la proprietà DesiredPacketDescription sono specificate impostazioni che includono l'oggetto PacketStatus, PacketStatus viene aggiunto in terza posizione. Ad esempio, se si imposta DesiredPacketDescription su (a, b, c, d, PacketStatus, e, f), una funzione get restituisce (X, Y, PacketStatus, a, b, c, d, e, f).

Nella modalità a più tavolette, questa descrizione del pacchetto è valida per tutti i dispositivi del Tablet PC. Se uno dei dispositivi non supporta una proprietà di descrizione del pacchetto nota, i dati della proprietà non vengono restituiti.

Eventuali modifiche apportate a questa proprietà non influiscono sui dati del pacchetto in ingresso fino a che non si cambia la proprietà InkEnabled da false in true.

Esempi

Nell'esempio seguente viene illustrato come utilizzare la proprietà DesiredPacketDescription per esprimere un interesse in oggetti Guid specifici dell'oggetto PacketProperty e utilizzare quindi le proprietà del pacchetto esposte durante l'evento NewPackets.

Anzitutto, viene inizializzata la proprietà DesiredPacketDescription e vengono assegnati i gestori eventi.

' 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);

Quando viene generato l'evento CursorInRange, viene effettuato un controllo per verificare se è la prima volta che l'oggetto InkPicture entra in contatto con questo particolare oggetto Cursor. In questo caso, la proprietà DrawingAttributes viene assegnata con un clone della proprietà DefaultDrawingAttributes. In questo modo viene garantito che l'accesso successivo alla proprietà DrawingAttributes non generi un'eccezione di riferimento 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;
        }
    }
}

Quando viene generato l'evento NewPackets, viene effettuato un controllo per verificare se l'oggetto NormalPressure è incluso nei dati del pacchetto. In questo caso, le informazioni sulla pressione vengono visualizzate in un'etichetta di stato e viene modificata la proprietà 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;
        }
    }
}

Piattaforme

Windows Vista

.NET Framework e .NET Compact Framework non supportano tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.

Informazioni sulla versione

.NET Framework

Supportato in: 3.0

Vedere anche

Riferimenti

InkPicture Classe

Membri InkPicture

Spazio dei nomi Microsoft.Ink

PacketProperty

Tablet