Ink Collection

Ink Collection

Description of ink collection for the Tablet PC.

Ink collection begins with the digitizer. A user places a pen on the digitizer and starts to write. You can use the ink collection features of the API to manage the collection of ink data that "flows" from the pen. You have access to information about the available hardware on Tablet PC through the Tablets collection and the Tablet object. You then use the InkCollector object to get the data that comes from the digitizer.

Tablets and the Tablet Object

A Tablet represents a digitizer device of Tablet PC. A Tablet PC may have more than one digitizer. Using the Tablet object, you can query for the available digitizer devices that are attached to Tablet PC and their respective hardware capabilities. For example, you can determine if the Tablet you are working with is integrated with the display or is a separate external device.

InkCollector Object

The InkCollector object captures ink input from available Tablet devices. The InkCollector object only collects ink and gestures that are input into a specific window. A very efficient event sink renders this input in real time. The InkCollector object captures the input and directs it into an Ink object.

Note: Simultaneously laying down ink with multiple pens may or may not work, depending on the hardware capabilities of the digitizer device.

How the Ink Collector Works

The InkCollector object attaches itself to a known application window. It then enables users to employ any available Tablet PC device (including the mouse) to lay down ink in real time on that window. The ink strokes that it collects are stored in an associated Ink object. These strokes can then be manipulated or sent to a recognizer for recognition. The InkCollector object also notifies the application when a cursor comes into range of any of the Tablet PC devices that are being used.

In applications created with Microsoft® Visual Basic® 6.0, ink entered by dragging a mouse is displayed beneath dialog box buttons. With Microsoft Foundation Classes (MFC) applications, the ink is displayed on top of the buttons until the dialog box is redrawn (for example, by minimizing and then restoring the dialog box).

For the InkCollector object to accurately set the mouse cursor within an inkable window, that window must be able to receive the WM_SETCURSOR message. This is successful for all regular windows but, for a control within a dialog box, the dialog parent of the control filters this message. For the control to receive the message, set the SS_NOTIFY style.

InkOverlay Object

The InkCollector object, discussed previously, is useful for applications to provide their own model for selecting, erasing, and other user interaction. The InkOverlay object is a superset of the InkCollector object that provides editing support. This is useful for applications to integrate ink drawing and editing into their own document canvas by using a set of standard ink selection models that the object provides.

Both the InkCollector object and the InkOverlay object (as well as the InkPicture control) use common constructs, such as the Ink object and the DrawingAttributes collection, so that the basic way to change the color of ink is the same everywhere. This enables you to reuse code and to have common programmatic access, which can be particularly important if you offer scripting support in your application.

InkOverlay is a COM object that is useful for annotation scenarios in which users are not concerned with performing recognition on ink but, instead, are interested in the size, shape, color, and position of the ink. It is well suited for taking notes and basic scribbling. The default user interface is a transparent rectangle with opaque ink.

InkOverlay extends the InkCollector class in three ways:

  • It raises events for begin-stroke, end-stroke, and ink attribute changes.
  • It enables users to select, erase, and resize ink.
  • It supports Cut, Copy, and Paste commands.

A typical scenario in which InkOverlay is useful is in marking up a presentation slide or image. The InkOverlay object enables easy implementation of the ink and layout capabilities that this scenario requires.

To work with InkOverlay, you:

  1. Instantiate an InkOverlay object.
  2. Attach the hWnd (Handle Leave Site, in managed code) of a window to the InkOverlay object's Handle property.
  3. Set the InkOverlay's Enabled property to True.

The InkOverlay object includes basic printing support, but you must implement print preview or other advanced printing capabilities.

InkOverlay persists ink in ink serialized format (ISF).

Note: If EditingMode = Delete or EditingMode = Select, other events (such as InkAdded, InkDeleted, and Stroke) are triggered. These events are useful if you want to implement your own delete or select modes.

Selecting Ink

The InkOverlay object enables users to use a lasso tool to select ink objects that are contained in a traced region. Users can also select ink by tapping any Ink object.

Use the Selection property to return a Strokes collection that you can use to manipulate a user's selection.

When an Ink object or a set of Ink objects is selected, sizing handles appear at the four corners of the ink's bounding box and at all midpoints between adjacent corners. If the user drags anywhere within the selected region, the ink becomes movable inside the control.

Default Behavior

The InkOverlay object is set to collect ink by default. Ink is 53 ink space units wide (where 1 ink space unit = 1 HIMETRIC). Ink is black if the user is not running in high-contrast mode. Otherwise, ink is set to the COLOR_WINDOWTEXT value (WindowText Leave Site in managed code). FitToCurve is False.

Cursor and Button Objects

A cursor corresponds to the tip of the pen that is used on Tablet PC, and is not be confused with System.Windows.Forms.Cursor Leave Site. For instance, a pencil has two ends. Usually, one end is used for writing and the other is used for erasing. These two ends correspond to two cursors.

On Tablet PC, a cursor is usually defined to be used either for writing or erasing. A cursor may potentially change roles if the application enables this functionality. Some Tablet PC devices allow multiple pens. Each cursor has an associated cursor ID that is unique on the system. A cursor can have zero or more associated buttons. These buttons are provided to the application as CursorButton objects. The application can provide a specific DrawingAttributes object for any given cursor.

Drawing Attributes Object

A DrawingAttributes object describes how any known set of ink is to be drawn. A DrawingAttributes object includes basic properties such as Color, Width, and PenTip. It can also encompass advanced parameters, such as variable transparency and Bezier smoothing, that can provide interesting effects or improve ink readability.

PenInputPanel Object

The PenInputPanel object allows you to easily add in-place pen input to your applications. The PenInputPanel is available as an attachable object that allows you to add Tablet PC Input Panel functionality to existing controls. The user interface is largely mandated by the current input language. You have the option of choosing the default input method for the pen input panel, either handwriting or keyboard. The end user can switch between input methods using buttons on the user interface.