Bagikan melalui


RecognizerContext Class

RecognizerContext Class

Enables the ability to perform ink recognition, retrieve the recognition result, and retrieve alternates. The RecognizerContext enables the various recognizers that are installed on a system to use ink recognition to process input appropriately.

Definition

Visual Basic .NET Public Class RecognizerContext
Inherits Object
Implements ICloneable, IDisposable
C# public class RecognizerContext : Object,
ICloneable, IDisposable
Managed C++ public __gc class RecognizerContext : public Object,
ICloneable, IDisposable

Members Table

The following table lists the members exposed by the object.

Events

Event Description
Recognition Occurs when the RecognizerContext has generated results from the BackgroundRecognize method.
RecognitionWithAlternates Occurs when the RecognizerContext has generated results after calling the BackgroundRecognizeWithAlternates method.

Methods

Method Description
BackgroundRecognize Causes the Recognizer object to recognize the associated Strokes collection and raise a Recognition event when recognition is complete.
BackgroundRecognizeWithAlternates Causes the Recognizer object to recognize the associated Strokes collection and raise a RecognitionWithAlternates event when recognition is complete.
Clone Creates a copy of this RecognizerContext object.
Dispose Releases resources used by the RecognizerContext object.
EndInkInput Ends ink input to the RecognizerContext object.
Equals Leave Site Determines whether two Object Leave Site instances are equal. Inherited from Object Leave Site.
Finalize Frees the resources of the current RecognizerContext object before it is reclaimed by the garbage collector.
GetHashCode Leave Site Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table. Inherited from Object Leave Site.
GetType Leave Site Gets the Type Leave Site of the current instance. Inherited from Object Leave Site.
ICloneable.Clone
IsStringSupported Returns a value that indicates whether the system dictionary, user dictionary, or word list contain a specified string.
MemberwiseClone Leave Site Creates a shallow copy of the current Object Leave Site. Inherited from Object Leave Site.
Recognize Returns a RecognitionResult object for a Strokes collection.
RecognizerContext Initializes a new instance of the RecognizerContext class.
static (Shared in Visual Basic .NET)ReferenceEquals Leave Site Determines whether the specified Object Leave Site instances are the same instance. Inherited from Object Leave Site.
StopBackgroundRecognition Ends background recognition that was started with a call to BackgroundRecognize or BackgroundRecognizeWithAlternates.
ToString Leave Site Returns a String Leave Site that represents the current Object Leave Site. Inherited from Object Leave Site.

Properties

Property Description
CharacterAutoCompletion Gets or sets the character Autocomplete mode, which determines when characters or words are recognized.
Factoid Gets or sets the string name of the factoid used by the RecognizerContext object.
Guide Gets or sets the RecognizerGuide to use for ink input.
PrefixText Gets or sets the characters that come before the Strokes collection in the RecognizerContext object.
RecognitionFlags Gets or sets the flags that specify how the recognizer interprets the ink and determines the result string.
Recognizer Gets or sets the Recognizer object used by the RecognizerContext object.
Strokes Gets or sets the Strokes collection associated with the RecognizerContext object.
SuffixText Gets or sets the characters that come after the Strokes collection in the RecognizerContext object.
WordList Gets or sets the WordList object that is used to improve the recognition results.

Inheritance Hierarchy

Object Leave Site

RecognizerContext

Remarks

Caution: To avoid a memory leak you must explicitly call the Dispose method on any RecognizerContext collection to which an event handler has been attached before the collection goes out of scope.

There are two types of recognition: background (asynchronous) or foreground (synchronous). Background recognition is started by a call to the BackgroundRecognize or BackgroundRecognizeWithAlternates methods, occurs on a background thread, and reports results to the application through an event mechanism. Foreground recognition does not return until all recognition is completed, thus making recognition results available to the calling thread without listening for the recognition event.

Ink is processed continuously in the background. If a Stroke is added to the Strokes collection to which the RecognizerContext refers, then the Stroke is then recognized immediately. See remarks in the EndInkInput method topic for more details.

All recognition occurs through a recognizer context. The context defines the settings for a single recognition session. It receives the ink that must be recognized and defines the constraints on the ink input and on the recognition output. The constraints that can be set on the context include the language, the dictionary, and grammar that is being used.

Note: Setting properties other than the Strokes or CharacterAutoCompletion properties succeeds only if the Strokes collection is null. You must set the other properties before you attach the Strokes collection to the RecognizerContext, or you must set the Strokes collection to null and then set the other properties. If you set the Strokes collection to null and then set the other properties, you may have to reattach the Strokes collection. This is because the recognition starts right after you assign the Strokes to the RecognizerContext. When a call is made to Recognize or BackgroundRecognize, call results might be already available.

To improve your application's performance, manually dispose of a RecognizerContext object when it is no longer needed.

Class Information

Namespace Microsoft.Ink
Assembly Microsoft.Ink (microsoft.ink.dll)
Strong Name Microsoft.Ink, Version=1.7.4009.0, Culture=neutral, PublicKeyToken=a2870d9cc4d021c8

See Also