How To: Create a basic Windows Forms based Ink application in C#

In this posting I'm going to show you how easy it is to get started building "Ink Enabled" applications in .NET with the Tablet PC Platform SDK 1.7 using C#. I'm going to create a new Form, and attach an InkOverlay to that Form, allowing us to collect Ink with the Form's client window area. I'm going to use Visual Studio .NET 2005, but the steps are similar for any version of Visual Studio.NET (Express or otherwise)

Before proceeding, make sure you have the Tablet PC Platform SDK 1.7 installed - see the following blog entry for more detail on that: https://blogs.msdn.com/gavingear/archive/2006/08/18/706697.aspx

Step 1: Create the project
- File-->New-->Project
- Select Visual C#-->Windows-->Windows Application (Pick name and location), OK
- Compile and run the application --> Debug-->Start Without Debugging

Step 2: Add Tablet SDK reference, hook up InkOverlay
- (Right click on project references in Solution Explorer) , select Add Reference
- On the .NET tab, scroll down to "Tablet PC API"
- Click "OK"
- Right click on the client area of the Form in the designer, and select "View Code"
- In the header, add "using Microsoft.Ink;" to access the managed Ink namespace
- Handle instantiation, hookup and disposal of InkOverlay (See example code)
- Compile and run the application

Example Code:

//

// Basic Ink enabled Windows Forms application

// Gavin Gear - https://blogs.msdn.com/gavingear

// 08/2006

//

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

 

using Microsoft.Ink; // The managed Tablet PC API

 

namespace BasicInkApplication

{

    public partial class BasicInkApplication : Form

    {

        // The InkOverlay that we'll attach to our Form

        private InkOverlay inkOverlay;

 

        public BasicInkApplication()

        {

            InitializeComponent();

 

            // Create an InkOverlay object that's attached to the Form

            this.inkOverlay = new InkOverlay(this);

            // Enable the InkOverlay (default is Enabled == false)

            this.inkOverlay.Enabled = true;

 

            // The InkOverlay needs to be disposed due to unmanaged resources

            // used by the InkOverlay

            this.FormClosing += new FormClosingEventHandler(BasicInkApplication_FormClosing);

        }

 

        void BasicInkApplication_FormClosing(object sender, FormClosingEventArgs e)

        {

            this.inkOverlay.Dispose();

        }

    }

}

**Note that calling Dispose() is meaningful only if the application was going to continue running following the use of the InkOverlay, in this case, it does not accomplish much

That's all it takes to add Ink collection to your Windows Forms based application. Next time, well extend this example to take a look at basic handwriting recognition using the RecognizerContext object.

See ya!
Gavin

screenshot_ink.bmp