How To Collect Ink

Ink collection is supported with an Ink Collector object that comes with the Tablet PC SDK. This very basic application will show you how to collect ink from the Tablet PC stylus.

Download a zip of the application.

Setting up Your Project

Start Visual Studio .Net and create a C# Windows Application. In the solution explorer, add a reference to Micrsoft Tablet PC API. Then at the top of your code add:

using Microsoft.Ink;

In your form's code, create an Ink Collector object that will handle all ink collection:

private InkCollector myInkCollector;

In Form1's constructor, initialize your Ink Collector. This involves telling it which object you will be drawing in with the pen (in this case the form) and what initial ink attributes you want to use. You then have to actually enable ink collection.

public Form1()
    {
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent();

      // connect the ink collector to the form
      myInkCollector = new InkCollector(this.Handle);
      // set the color of the ink
      myInkCollector.DefaultDrawingAttributes.Color = Color.Red;
      // set the width of the ink
      myInkCollector.DefaultDrawingAttributes.Width = 20;
      // turn on ink collection
      myInkCollector.Enabled = true;
    }

Compile and run, you're done! You should now be able to draw on your form as the Ink Collector manages your ink.