|
//
// Basic Ink enabled Windows Forms application with
// handwriting recognition using RecognizerContext
// Gavin Gear - http://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();
}
private void buttonRecognize_Click(object sender, EventArgs e)
{
// Instantiate a RecognizerContext object
RecognizerContext context = new RecognizerContext();
// Add the strokes collected by our InkOverlay
context.Strokes = this.inkOverlay.Ink.Strokes;
// Perform recognition, pass a RecognitionStatus object
// that will give the status of the recognition
RecognitionStatus status;
RecognitionResult result = context.Recognize(out status);
MessageBox.Show(result.TopString);
context.Dispose(); // Free the unmanaged resources
}
}
} |