共用方式為


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 方法來修改封包資料。

ms585071.alert_note(zh-tw,VS.90).gif注意事項:

如果 value 參數中的陣列長度不是所繼承 PacketPropertyCount 屬性之值的倍數,SetData 方法會擲回 ArgumentException (英文) 例外狀況。

您可以呼叫 SetData 方法,並且將 value 參數設定為 null (在 Microsoft Visual Basic .NET 中為 Nothing),取消感應輸入封包。

範例

這個 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