IStylusAsyncPlugin.StylusUp 方法

通知实现插件用户已将手写笔从 Tablet 数字化仪表面拿开。

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

语法

声明
Sub StylusUp ( _
    sender As RealTimeStylus, _
    data As StylusUpData _
)
用法
Dim instance As IStylusAsyncPlugin
Dim sender As RealTimeStylus
Dim data As StylusUpData

instance.StylusUp(sender, data)
void StylusUp(
    RealTimeStylus sender,
    StylusUpData data
)
void StylusUp(
    RealTimeStylus^ sender, 
    StylusUpData^ data
)
void StylusUp(
    RealTimeStylus sender,
    StylusUpData data
)
function StylusUp(
    sender : RealTimeStylus, 
    data : StylusUpData
)

参数

备注

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

备注

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

示例

此 C# 示例摘自 RealTimeStylus Plug-in Sample。此示例演示如何将笔输入限制在指定的矩形内。

public void StylusUp(RealTimeStylus sender,  StylusUpData data)
{
    ModifyPacketData(data);
}

private void ModifyPacketData(StylusDataBase data)
{
    // For each packet in the packet data, check whether
    // its x,y values fall outside of the specified rectangle.  
    // If so, replace them with the nearest point that still
    // falls within the rectangle.
    for (int i = 0; i < data.Count ; i += data.PacketPropertyCount)
    {
        // packet data always has x followed by y followed by the rest
        int x = data[i];
        int y = data[i+1];

        // Constrain points to the input rectangle
        x = Math.Max(x, rectangle.Left);
        x = Math.Min(x, rectangle.Right);
        y = Math.Max(y, rectangle.Top);
        y = Math.Min(y, rectangle.Bottom);

        // If necessary, modify the x,y packet data
        if (x != data[i])
        {
            data[i] = x;
        }
        
        if (y != data[i+1])
        {
            data[i+1] = y;
        } 
    }
} 

此 Microsoft Visual Basic .NET 示例摘自 RealTimeStylus Plug-in Sample。此示例演示如何将笔输入限制在指定的矩形内。

Public Sub StylusUp(ByVal sender As RealTimeStylus, ByVal data As StylusUpData) _
 Implements IStylusAsyncPlugin.StylusUp
    ModifyPacketData(data)
End Sub 'StylusUp

Private Sub ModifyPacketData(ByVal data As StylusDataBase)
    ' For each packet in the packet data, check whether
    ' its x,y values fall outside of the specified rectangle.  
    ' If so, replace them with the nearest point that still
    ' falls within the rectangle.
    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 x As Integer = data(i)
        Dim y As Integer = data((i + 1))

        ' Constrain points to the input rectangle
        x = Math.Max(x, rectangle.Left)
        x = Math.Min(x, rectangle.Right)
        y = Math.Max(y, rectangle.Top)
        y = Math.Min(y, rectangle.Bottom)

        ' If necessary, modify the x,y packet data
        If x <> data(i) Then
            data(i) = x
        End If
        If y <> data((i + 1)) Then
            data((i + 1)) = y
        End If
    Next i
End Sub 'ModifyPacketData

平台

Windows Vista, Windows XP SP2, Windows Server 2003

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

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

IStylusAsyncPlugin 接口

IStylusAsyncPlugin 成员

Microsoft.StylusInput 命名空间

StylusUpData