IStylusSyncPlugin.Packets Method

IStylusSyncPlugin.Packets Method

Informs the object implementing the IStylusSyncPlugin interface that the stylus is moving on the digitizer.

Definition

Visual Basic .NET Public Sub Packets( _
ByVal sender As RealTimeStylus, _
ByVal data As PacketsData _
)
C# public void Packets(
RealTimeStylus sender,
PacketsData data
);
Managed C++ public: void Packets(
RealTimeStylus *sender,
PacketsData *data
);

Parameters

sender Microsoft.StylusInput.RealTimeStylus. The RealTimeStylus which called this method.
data Microsoft.StylusInput.PluginData.PacketsData. The information about the stylus movement.

Remarks

You can modify the packet data by calling the inherited SetData method of the PacketsData object contained in the data parameter.

Note: An ArgumentException Leave Site exception is thrown by the SetData method if the length of the array in the value parameter is not a multiple of the inherited Count property.

You can cancel the packets by calling the SetData method with the value parameter set to null (Nothing in Microsoft® Visual Basic® .NET).

Examples

[C#]

This C# example is excerpted from the RealTimeStylus Plug-in Sample. It implements a Packets method that draws a small circle in the location of each new packet reveived.

public void Packets(RealTimeStylus sender,  PacketsData data)
{
  // For each new packet received, extract the x,y data
  // and draw a small circle around the result.
  for (int i = 0; i < data.Count ; i += data.PacketPropertyCount)
  {
    // Packet data always has x followed by y followed by the rest
    Point point = new Point(data[i], data[i+1]);

    // Since the packet data is in Ink Space coordinates, we need to convert to Pixels...
    point.X = (int)Math.Round((float)point.X * (float)myGraphics.DpiX/2540.0F);
    point.Y = (int)Math.Round((float)point.Y * (float)myGraphics.DpiY/2540.0F);

    // Draw a circle corresponding to the packet
    myGraphics.DrawEllipse(Pens.Green, point.X - 2, point.Y - 2, 4, 4);
  }
}

See Also