Home > Articles > Home & Office Computing > Entertainment/Gaming/Gadgets

  • Print
  • + Share This
Like this article? We recommend

Working with the InkCollector class

To demonstrate the basics of using TabletPC to perform handwriting recognition, I created a sample application, CogArtTechTabletSample, which enables you to write text on a WinForm and then perform handwriting recognition upon the Ink that you have written (see Figure 6). You perform handwriting recognition by selecting Recognize from the form’s File menu.

Figure 06

Figure 6 The Simple Handwriting WinForm application demonstrates how to program TabletPC for handwriting recognition.

The first thing that you need to do when writing a TabletPC application is to have a way to gather stylus input. There are a number of ways to do this, but the simplest way to gather input is to attach an InkCollector to a WinForm control.

The InkCollector class is the mechanism that enables Ink gathering. You "attach" an InkCollector to a WinForm control by passing into the InkCollector’s constructor the handle of the control that will accept stylus input. Listing 2 shows you how to create an InkCollector. (In this case, we’ll use a Panel as the control to which the InkCollector is attached.) Once an InkCollector() object is created, you must set the Enabled property to true to activate the capability to accept Ink.

Listing 2 Instantiating an InkCollector object within a form’s constructor

public Form1()
{
 InitializeComponent();
 // Create a new ink collector that uses pnlHandwritingSurface as
 //the handwriting surface.
 inkCollector = new InkCollector(pnlWritingSurface.Handle);

 // Turn the ink collector on
 inkCollector.Enabled = true;
}
  • + Share This
  • 🔖 Save To Your Account