StylusButtons.GetID Method

StylusButtons.GetID Method

Gets the globally unique identifier (GUID) of the button at the given index.

Definition

Visual Basic .NET Public Function GetID( _
ByVal index As Integer _
) As Guid
C# public Guid GetID(
int index
);
Managed C++ public: Guid* GetID(
int *index
);

Parameters

index System.Int32. The index of the button.

Return Value

System.Guid. Returns the globally unique identifier (GUID) for the specified button.

Exceptions

ArgumentOutOfRangeException Leave Site:

Remarks

The globally unique identifier (GUID) is defined by the manufacturer of the digitizer.

Examples

This Microsoft® Visual C#® .NET example is a snippet from a form's helper method, StylusDataToString. The helper method takes a Stylus object and returns a string containing information about the stylus and its buttons.

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

// ...

// Returns information about a given stylus.
private string StylusDataToString(Stylus theStylus)
{
    System.Text.StringBuilder result = new System.Text.StringBuilder();

    // Add information about the tablet pen.
    result.Append(
        string.Format("  Name = {0}, Id = {1}, ContextId = {2}, Inverted = {3}, Button Count = {4}."
        + Environment.NewLine, theStylus.Name, theStylus.Id,
        theStylus.TabletContextId, theStylus.Inverted, theStylus.Buttons.Count));

    // Add information about each of the tabet pen's buttons.
    for (int i=0; i<theStylus.Buttons.Count; i++)
    {
        result.Append(
            string.Format("    Button {0}: Name = {1}, Id = {2}" + Environment.NewLine,
            i, theStylus.Buttons.GetName(i), theStylus.Buttons.GetId(i)));
    }

    return result.ToString();
}