Compartir a través de


InkPicture.DesiredPacketDescription (Propiedad)

Actualización: noviembre 2007

Obtiene o establece el interés en aspectos de los paquetes asociados a la entrada manuscrita dibujada en el objeto InkPicture.

Espacio de nombres:  Microsoft.Ink
Ensamblado:  Microsoft.Ink (en Microsoft.Ink.dll)

Sintaxis

'Declaración
<BrowsableAttribute(False)> _
Public Property DesiredPacketDescription As Guid()
'Uso
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[])

Valor de propiedad

Tipo: array<System.Guid[]
La matriz de objetos Guid, cada uno de los cuales representa un aspecto de los paquetes asociados a la entrada manuscrita utilizada en el objeto InkPicture.

Comentarios

La descripción del paquete es una matriz de objetos Guid del objeto PacketProperty.

De forma predeterminada, la propiedad DesiredPacketDescription contiene los campos X, Yy NormalPressure del objeto PacketProperty. Si establece la propiedad DesiredPacketDescription en otro valor, también se agregan los campos X y Y. Por ejemplo, si establece DesiredPacketDescription sólo en ButtonPressure, Get devuelve {X, Y, ButtonPressure}, no sólo {ButtonPressure}.

Cuando la propiedad DesiredPacketDescription se establece en un valor que incluye el campo PacketStatus, este campo PacketStatus se agrega en la tercera posición. Por ejemplo, si establece DesiredPacketDescription en (a, b, c, d, PacketStatus, e, f), Get devuelve (X, Y, PacketStatus, a, b, c, d, e, f).

En el modo de varios Tablet PC, ésta es la descripción del paquete para todos los dispositivos de Tablet PC. Si cualquiera de los dispositivos no admite una propiedad de descripción de paquete conocida, no se devuelven los datos de la propiedad.

Los cambios de esta propiedad no afectan a los datos del paquete entrante hasta que la propiedad InkEnabled cambie de false a true.

Ejemplos

En el ejemplo siguiente se muestra cómo puede utilizar la propiedad DesiredPacketDescription para expresar interés en objetos Guid concretos del objeto PacketProperty y, a continuación, utilizar las propiedades de paquete expuestas durante el evento NewPackets.

Primero, se inicializa la propiedad DesiredPacketDescription y se asignan los controladores de eventos.

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

Cuando se desencadena el evento CursorInRange, se realiza una comprobación para evaluar si se trata de la primera vez que el objeto InkPicture ha entrado en contacto con este objeto Cursor específico. En caso afirmativo, a la propiedad DrawingAttributes se le asigna un clon de la propiedad DefaultDrawingAttributes. De este modo, se garantiza que el acceso posterior a la propiedad DrawingAttributes no desencadene una excepción de referencia nula.

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;
        }
    }
}

Cuando se desencadena el evento NewPackets, se realiza una comprobación para evaluar si se incluye el campo NormalPressure en los datos del paquete. En caso afirmativo, la información sobre la presión se muestra en una etiqueta de estado y se modifica la propiedad 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;
        }
    }
}

Plataformas

Windows Vista

.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Información de versión

.NET Framework

Compatible con: 3.0

Vea también

Referencia

InkPicture (Clase)

InkPicture (Miembros)

Microsoft.Ink (Espacio de nombres)

PacketProperty

Tablet