Export (0) Print
Expand All

RealTimeStylus.GetTabletFromTabletContextId Method

Returns the Tablet object that is associated with a given tablet context identifier.

Namespace:  Microsoft.StylusInput
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

public Tablet GetTabletFromTabletContextId(
	int tabletContextId
)

Parameters

tabletContextId
Type: System.Int32

The tablet context identifier for which you want the associated Tablet object.

Return Value

Type: Microsoft.Ink.Tablet
The Tablet object that is associated with a given tablet context identifier.

NoteNote:

A tablet context identifier is specific to RealTimeStylus object; however two RealTimeStylus objects may have a different context identifiers for the same Tablet object. In addition, a tablet context identifier is only valid while a RealTimeStylus object is enabled. If a RealTimeStylus object is disabled and then re-enabled, the tablet context identifier for each Tablet object may have a different value from when the RealTimeStylus object was first enabled.

This method throws an exception when the RealTimeStylus is disabled or disposed.

NoteNote:

This function can be re-entered when called within certain message handlers, causing unexpected results. Take care to avoid a reentrant call when handling any of the following messages: WM_ACTIVATE, WM_ACTIVATEAPP, WM_NCACTIVATE, WM_PAINT; WM_SYSCOMMAND if wParam is set to SC_HOTKEY or SC_TASKLIST; and WM_SYSKEYDOWN (when processing Alt-Tab or Alt-Esc key combinations). This is an issue with single-threaded apartment model applications.

This C# example is a snippet from the implementation of the IStylusAsyncPlugin interface's RealTimeStylusEnabled method. The form which implements the IStylusAsyncPlugin interface contains a TextBox object, theTextBox. The RealTimeStylusEnabled method displays information about the tablets that are available at the time the RealTimeStylus object is enabled.

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;

// ...

// Called when the RealTimeStylus is enabled, or when the plug-in is added to
// a RealTimeStylus that is already enabled.
public void RealTimeStylusEnabled(RealTimeStylus sender,
    RealTimeStylusEnabledData data)
{
    // Display the list of available tablets.
    this.theTextBox.Text = string.Format(
        "RealTimeStylus enabled ({0} tablets attached):" + Environment.NewLine,
        data.Count);
    foreach (int theContextId in data)
    {
        Tablet theTablet =
            this.thePrimaryRealTimeStylus.GetTabletFromTabletContextId(theContextId);

        this.theTextBox.Text += string.Format(
            "  ContextId = {0}, Tablet.Name = {1}" + Environment.NewLine,
            theContextId, theTablet.Name);

        this.theTextBox.Text += "   Available packet properties:" + Environment.NewLine;

        foreach(TabletPropertyDescription theTabletPropertyDescription in
            this.thePrimaryRealTimeStylus.GetTabletPropertyDescriptionCollection(theContextId))
        {
            this.theTextBox.Text += string.Format("    {0}" + Environment.NewLine,
                this.GetPacketPropertyNameFromGuid(theTabletPropertyDescription.PacketPropertyId));
        }
    }
}

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft