One of the cool capabilities of the Tablet PC InkAnalysis API is the ability to recognize shapes that a user draws on their Tablet PC. After you add strokes to an InkAnalyzer object and call Analyze() or BackgroundAnalyze(), you can then retrieve InkDrawingNodes by calling InkAnalyzer.FindNodesOfType() – you need to pass the enumerated value of ContextNodeType.InkDrawingNode to select only drawings. If you want to determine what the shape type is, call InkDrawingNode.GetShapeName().
Here are the shapes that our current InkAnalysis API can return:
If the shape can not be recognized as one of the shapes listed above, "Other" will be returned.
If you are not familiar with InkAnalysis or the Tablet PC Platform SDK 1.7 and Input Supplement 1.75 (contains InkAnslysis), see the following post:
The code listed below demonstrates a basic shape recognition application, here’s a screenshot of that application running:
// Basic Shape Recognition Application
// using the InkAnalysis API, part of the
// Tablet PC Platform SDK 1.75 Input Supplement
// Gavin Gear
public partial class Form1 : Form
private InkOverlay overlay_;
private void Form1_Load(object sender, EventArgs e)
this.overlay_ = new InkOverlay(this);
this.overlay_.Enabled = true;
private void buttonRecoShapes_Click(object sender, EventArgs e)
// Create a new InkAnalyzer referencing the strokes from
// our InkOverlay's Ink object, and synchronized to the main Form
InkAnalyzer analyzer = new InkAnalyzer(this.overlay_.Ink, this);
if (this.overlay_.Ink.Strokes.Count > 0)
AnalysisStatus status = analyzer.Analyze();
if (status.Successful == true)
ContextNodeCollection DrawingNodes = analyzer.FindNodesOfType(ContextNodeType.InkDrawing);
string shapeString = "Shapes Found:" + Environment.NewLine;
foreach (InkDrawingNode node in DrawingNodes)
shapeString += node.GetShapeName() + Environment.NewLine;
MessageBox.Show(shapeString, "Recognized Shapes");
MessageBox.Show("Analysis failed, exiting");
This is a pretty basic example of shape recognition, but it gives you a glimpse of what’s possible with the InkAnalysis API regarding shapes and drawings. There’s a lot more capabilities in InkAnalysis for shapes including HotPoint data, and perhaps we’ll dig into that later!
If you have any questions, feel free to contact me.