InkAnalyzer Class
Provides access to layout analysis, writing and drawing classification, and handwriting recognition.
Namespace: System.Windows.Ink
Assembly: IAWinFX (in IAWinFX.dll)
Syntax
'Declaration
Public Class InkAnalyzer _
Implements IDisposable
'Usage
Dim instance As InkAnalyzer
public class InkAnalyzer : IDisposable
public ref class InkAnalyzer : IDisposable
public class InkAnalyzer implements IDisposable
Remarks
To add or remove strokes to the InkAnalyzer for analysis, use the AddStroke, AddStrokes, RemoveStroke, or RemoveStrokes methods. These methods update the DirtyRegion property, which defines the region that contains the strokes that 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 where the InkAnalyzer will raise the events that are 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 that the ink analyzer uses to recognize handwriting, use SetStrokeLanguageId or SetStrokesLanguageId. To modify how the ink analyzer classifies specific strokes, use SetStrokeType or SetStrokesType.
The InkAnalyzer loads all of the installed ink recognizers. The InkRecognizersByPriority property gets an InkRecognizerCollection containing each InkRecognizer available. If more than one ink recognizer supports a specific language, use SetHighestPriorityInkRecognizer(InkRecognizer) to designate the ink recognizer that is responsible for handling strokes for a given 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.
GetNodesFromTextRange(Int32, Int32)
GetTextRangeFromNodes(ContextNodeBaseCollection, Int32, Int32)
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 is attached, before the object goes out of scope
Examples
The following example creates a new InkAnalyzer and attaches the StrokesChanged event handler to the Strokes property on the InkCanvas named theInkCanvas.
theInkAnalyzer = New InkAnalyzer()
AddHandler theInkCanvas.Strokes.StrokesChanged, AddressOf Strokes_StrokesChanged
theInkAnalyzer = new InkAnalyzer();
theInkCanvas.Strokes.StrokesChanged +=
new StrokeCollectionChangedEventHandler(Strokes_StrokesChanged);
The following example defines the Strokes_StrokesChanged event handler, which adds strokes to theInkAnalyzer if they were already added to theInkCanvas. It also removes strokes from theInkAnalyzer if they were already removed from theInkCanvas.
' This event occurs whenever a stroke is added, removed, or partially erased
' from the InkCanvas.
Sub Strokes_StrokesChanged(ByVal sender As Object, ByVal e As StrokeCollectionChangedEventArgs)
If e.Added.Count > 0 Then
theInkAnalyzer.AddStrokes(e.Added)
End If
If e.Removed.Count > 0 Then
theInkAnalyzer.RemoveStrokes(e.Removed)
End If
End Sub 'Strokes_StrokesChanged
// This event occurs whenever a stroke is added, removed, or partially erased
// from the InkCanvas.
void Strokes_StrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
{
if (e.Added.Count > 0)
{
theInkAnalyzer.AddStrokes(e.Added);
}
if (e.Removed.Count > 0)
{
theInkAnalyzer.RemoveStrokes(e.Removed);
}
}
Inheritance Hierarchy
System.Object
System.Windows.Ink.InkAnalyzer
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
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.
Version Information
.NET Framework
Supported in: 3.0
See Also
Reference
System.Windows.Ink.AnalysisAlternate
System.Windows.Ink.AnalysisHintNode
System.Windows.Ink.AnalysisStatus