RealTimeStylus.GetStyluses Method

RealTimeStylus.GetStyluses Method

Returns the array of Stylus objects encountered by the RealTimeStylus.

Definition

Visual Basic .NET Public Function GetStyluses() As Stylus()
C# public Stylus[] GetStyluses();
Managed C++ public: Stylus* GetStyluses() __gc[];

Return Value

Microsoft.StylusInput.Stylus[]. The styluses encountered by the RealTimeStylus.

Exceptions

ObjectDisposedException Leave Site: The object is already disposed.

Remarks

If no stylus has yet been detected on the Tablet objects associated with the RealTimeStylus, then this method returns an empty array.

Examples

This Microsoft® Visual C#® .NET example is a snippet from a menu item's Click Leave Site event handler. The menu is part of a form on which a TextBox Leave Site object, theTextBox, is defined. If the RealTimeStylus object is disabled, the event handler exits. Otherwise, the event handler calls the RealTimeStylus object's GetStyluses method and displays information about each tablet pen in theTextBox. The form's helper method, StylusDataToString, returns a String Leave Site object containing information about a given stylus.

[C#]using Microsoft.Ink;
using Microsoft.StylusInput;
using Microsoft.StylusInput.PluginData;

// ...

// Declare the RealTimeStylus objects, the GestureRecognizer plugin,
// and the DynamicRenderer plug-in.
private Microsoft.StylusInput.RealTimeStylus thePrimaryRealTimeStylus = null;
private Microsoft.StylusInput.RealTimeStylus theSecondaryRealTimeStylus = null;
private Microsoft.StylusInput.GestureRecognizer theGestureRecognizer = null;
private Microsoft.StylusInput.DynamicRenderer theDynamicRenderer = null;

// ...

// The GetStyluses menu item's ClickEventHandler
private void theMenuItemGetStyluses_Click(object sender, System.EventArgs e)
{
    // Can not call this method while the RealTimeStylus is disabled.
    if (!this.thePrimaryRealTimeStylus.Enabled)
    {
        MessageBox.Show("The GetStyluses method of the RealTimeStylus can only be called while the RealTimeStylus is enabled.");
        return;
    }

    this.theTextBox.Text = "The Styluses encountered so far:" + Environment.NewLine;
    foreach (Stylus theStylus in this.thePrimaryRealTimeStylus.GetStyluses())
    {
        this.theTextBox.Text +=
            this.StylusDataToString(theStylus) + Environment.NewLine;
    }
}