Condividi tramite


IStylusAsyncPlugin.StylusUp Method

IStylusAsyncPlugin.StylusUp Method

Notification occurs when the stylus is raised off of the digitizer.

Definition

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

Parameters

sender Microsoft.StylusInput.RealTimeStylus. The RealTimeStylus that sent the notification.
data Microsoft.StylusInput.PluginData.StylusUpData. Provides access to the stylus associated with the notification.

Examples

[C#]

This C# example is excerpted from the RealTimeStylus Plug-in Sample. It shows how to restrict pen input to a specified rectangle.

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

See Also