This documentation is archived and is not being maintained.

InkAnalyzer Class

Provides access to layout analysis, writing and drawing classification, and handwriting recognition.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink.Analysis (in Microsoft.Ink.Analysis.dll)

public class InkAnalyzer : IDisposable

To add or remove strokes to the InkAnalyzer for analysis, use the AddStroke, AddStrokes, InkAnalyzer.RemoveStroke, or RemoveStrokes methods. These methods update the DirtyRegion property, which is the region for which strokes are analyzed in the next analysis operation.

To analyze ink, use the Analyze or BackgroundAnalyze method. During analysis, the InkAnalyzer performs layout analysis, stroke classification, and handwriting recognition.

During analysis, the InkAnalyzer raises a number of events. Set the SynchronizingObject property to specify the thread upon which the InkAnalyzer raises events generated during background analysis. Many InkAnalyzer events support the data proxy features of the InkAnalyzer. For more information, see Data Proxy with Ink Analysis.

To stop the analysis process from within an event handler, call the Abort method.

To modify the language the ink analyzer uses to recognize handwriting, use InkAnalyzer.SetStrokeLanguageId or InkAnalyzer.SetStrokesLanguageId. To modify how the ink analyzer classifies specific strokes, use InkAnalyzer.SetStrokeType or InkAnalyzer.SetStrokesType.

The InkAnalyzer loads all of the installed ink recognizers. The GetInkRecognizersByPriority method gets an InkRecognizerCollection containing each InkRecognizer available. If more than one ink recognizer supports a specific language, use SetAsHighestPriorityInkRecognizer to set which ink recognizer handles strokes of that language.

For information about providing context for the ink analysis operation, see CreateAnalysisHint, DeleteAnalysisHint, and GetAnalysisHints.

The ink analyzer represents analysis results as a string or as a tree of ContextNode objects. To access the recognized string, use GetRecognizedString. To access the root of the tree, use the RootNode property. The ink analyzer has the following methods for finding specific context nodes or text.

To work with alternate analysis results, use GetAlternates and ModifyTopAlternate.

To save analysis results, use SaveResults. To load saved results, use Load.

For more information about using the InkAnalyzer to analyze ink, see Ink Analysis Overview.

You must explicitly call the Dispose method on any InkAnalyzer object to which an event handler has been attached before the object goes out of scope

This example does the following.

  • Initializes a new Microsoft.Ink.Ink object, theInk.

  • Attaches an Ink.InkAdded event handler, theInk_InkAdded, to theInk.

  • Initializes a new InkAnalyzer, theInkAnalyzer, that can analyze stroke data from theInk.

// Create the Ink for use with the InkCollector and attach 
// event handlers. 
this.theInk = new Microsoft.Ink.Ink();
this.theInk.InkAdded +=
    new Microsoft.Ink.StrokesEventHandler(theInk_InkAdded);

// Create the InkAnalyzer. 
this.theInkAnalyzer =
    new Microsoft.Ink.InkAnalyzer(this.theInk, this);

In this example, the theInk_InkAdded event handler then takes the strokes that have been added to the theInk and adds them to theInkAnalyzer.

/// <summary> 
/// The ink's InkAdded event handler. 
/// </summary> 
/// <param name="sender">The source of the event.</param>
/// <param name="e">The event data.</param>
void theInk_InkAdded(object sender, Microsoft.Ink.StrokesEventArgs e)
    // This event handler is attached to an Ink object.
    Microsoft.Ink.Ink theInk = sender as Microsoft.Ink.Ink;

    // Add the new strokes to the InkAnalyzer. 


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.0