IStylusSyncPlugin.Packets 方法

通知实现 IStylusSyncPlugin 接口的对象手写笔将移动到数字化仪表面上。

命名空间:  Microsoft.StylusInput
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Sub Packets ( _
    sender As RealTimeStylus, _
    data As PacketsData _
)
用法
Dim instance As IStylusSyncPlugin
Dim sender As RealTimeStylus
Dim data As PacketsData

instance.Packets(sender, data)
void Packets(
    RealTimeStylus sender,
    PacketsData data
)
void Packets(
    RealTimeStylus^ sender, 
    PacketsData^ data
)
void Packets(
    RealTimeStylus sender,
    PacketsData data
)
function Packets(
    sender : RealTimeStylus, 
    data : PacketsData
)

参数

备注

可以通过调用包含在 data 参数中的 PacketsData 对象的继承的 SetData 方法来修改数据包数据。

备注

如果 value 参数中数组的长度不是继承的 PacketPropertyCount 属性值的倍数,则 SetData 方法将引发 ArgumentException 异常。

可以通过调用将 value 参数设置为 null(在 Microsoft Visual Basic .NET 中为 Nothing)的 SetData 方法来取消数据包。

示例

此 C# 示例摘自 RealTimeStylus Plug-in Sample。此示例实现 Packets 方法,该方法在收到的每个新数据包的位置画一个小圈。

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

此 Visual Basic .NET 示例摘自 RealTimeStylus Plug-in Sample。此示例实现 Packets 方法,该方法在收到的每个新数据包的位置画一个小圈。

Public Sub Packets(ByVal sender As RealTimeStylus, ByVal data As PacketsData) _
 Implements IStylusSyncPlugin.Packets
    ' For each new packet received, extract the x,y data
    ' and draw a small circle around the result.
    Dim i As Integer
    For i = 0 To data.Count - data.PacketPropertyCount Step data.PacketPropertyCount
        ' Packet data always has x followed by y followed by the rest
        Dim point As New Point(data(i), data((i + 1)))

        ' Since the packet data is in Ink Space coordinates,
        ' we need to convert to Pixels...
        point.X = Math.Round((System.Convert.ToSingle(point.X) * _
              System.Convert.ToSingle(myGraphics.DpiX) / 2540.0F))
        point.Y = Math.Round((System.Convert.ToSingle(point.Y) * _
              System.Convert.ToSingle(myGraphics.DpiY) / 2540.0F))

        ' Draw a circle corresponding to the packet
        myGraphics.DrawEllipse(Pens.Green, point.X - 2, point.Y - 2, 4, 4)
    Next i
End Sub 'Packets

平台

Windows Vista, Windows XP SP2, Windows Server 2003

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

IStylusSyncPlugin 接口

IStylusSyncPlugin 成员

Microsoft.StylusInput 命名空间

RealTimeStylus

Microsoft.StylusInput.PluginData.PacketsData