Compartir a través de


RecognizerContextRecognitionEventArgs.RecognitionStatus Property

RecognizerContextRecognitionEventArgs.RecognitionStatus Property

Gets a RecognitionStatus enumeration value that indicates the recognition status as of the most recent recognition result.

Definition

Visual Basic .NET Public ReadOnly Property RecognitionStatus As RecognitionStatus
C# public RecognitionStatus RecognitionStatus { get; }
Managed C++ public: __property RecognitionStatus* get_RecognitionStatus();

Property Value

Microsoft.Ink.RecognitionStatus. The recognition status as of the most recent recognition result.

This property is read-only. This property has no default value.

NoError0 Indicates no errors occurred.
Interrupted1 Indicates the recognition was interrupted by a call to StopBackgroundRecognition.
ProcessFailed2 Indicates the ink recognition process failed.
InkAddedFailed4 Indicates the ink could not be added.
SetAutoCompletionModeFailed8 Indicates the character Autocomplete mode could not be set.
SetStrokesFailed16 Indicates the strokes could not be set.
SetGuideFailed32 Indicates the recognition guide could not be set.
SetFlagsFailed64 Indicates the flags could not be set.
SetFactoidFailed128 Indicates the factoid could not be set.
SetPrefixSuffixFailed256 Indicates the suffix or the prefix could not be set.
SetWordListFailed512 Indicates the word list could not be set.

Examples

[C#]

This C# example is from a Form Leave Site, RecognitionEventForm, that performs background recognition by calling the BackgroundRecognize method of the RecognizerContext object, theRecognizerContext, as each stroke is collected and displays the result in the ListBox Leave Site control, theListBox, as they are generated.

A time stamp is used in the call to the BackgroundRecognize method. The event handler for the Recognition event, Recognition_Event, retrieves the time stamp by checking the CustomData property of the event arguments.

private Microsoft.Ink.InkCollector theInkCollector;
private Microsoft.Ink.Strokes theStrokes;
private Microsoft.Ink.RecognizerContext theRecognizerContext;

private System.Windows.Forms.ListBox theListBox;

// Event handler for the form's Load event
private void RecognitionEventForm_Load(object sender, System.EventArgs e)
{
    // Create a new ink collector and recognizer context.
    this.theInkCollector = new Microsoft.Ink.InkCollector(this.Handle);
    this.theRecognizerContext = new Microsoft.Ink.RecognizerContext();

    // Initialize the RecognizerContext object's strokes.
    this.theStrokes = this.theInkCollector.Ink.Strokes;
    this.theRecognizerContext.Strokes = this.theStrokes;

    // Attach event handlers.
    this.theInkCollector.Stroke +=
        new InkCollectorStrokeEventHandler(this.Stroke_Event);
    this.theRecognizerContext.Recognition +=
        new RecognizerContextRecognitionEventHandler(
            this.Recognition_Event);

    // Enable the ink collector
    this.theInkCollector.Enabled = true;
}

// Stroke event handler
private void Stroke_Event(object sender,
    InkCollectorStrokeEventArgs e)
{
    // When a new stroke is collected,
    // add it to the recognizer's strokes collection.
    this.theStrokes.Add(e.Stroke);

    // Tell the context to recognize its strokes.
    // Add a time stamp as custom data for the Recognition event.
    DateTime timeStamp = DateTime.Now;
    this.theRecognizerContext.BackgroundRecognize(timeStamp);
}

// Recognition Event Handler
private void Recognition_Event(
    object sender,
    RecognizerContextRecognitionEventArgs e)
{
    // Update the list box
    this.theListBox.Items.Clear();
    this.theListBox.Items.Add("The recognition status is: " + e.RecognitionStatus.ToString());
    this.theListBox.Items.Add("The time stamp is: " + ((DateTime)e.CustomData).ToString());
    this.theListBox.Items.Add("The recogniton text is: " + e.Text);
}

// Event handler for the form's closed event
private void RecognitionEventForm_Closed(object sender, System.EventArgs e)
{
    this.theInkCollector.Dispose();
    this.theInkCollector = null;
    this.theRecognizerContext.Dispose();
    this.theRecognizerContext = null;
}

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example is from a Form Leave Site, RecognitionEventForm, that performs background recognition by calling the BackgroundRecognize method of the RecognizerContext object, theRecognizerContext, as each stroke is collected and displays the result in the ListBox Leave Site control, theListBox, as they are generated.

A time stamp is used in the call to the BackgroundRecognize method. The event handler for the Recognition event, Recognition_Event, retrieves the time stamp by checking the CustomData property of the event arguments.

Private WithEvents theInkCollector As Microsoft.Ink.InkCollector
Private WithEvents theRecognizerContext As Microsoft.Ink.RecognizerContext
Private theStrokes As Microsoft.Ink.Strokes

' Event handler for the form's Load event.
Private Sub RecognitionEventForm_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
    ' Create a new ink collector and recognizer context.
    Me.theInkCollector = New Microsoft.Ink.InkCollector(Me.Handle)
    Me.theRecognizerContext = New Microsoft.Ink.RecognizerContext

    ' Initialize the RecognizerContext object's strokes
    Me.theStrokes = Me.theInkCollector.Ink.Strokes
    Me.theRecognizerContext.Strokes = Me.theStrokes

    ' Enable the ink collector
    Me.theInkCollector.Enabled = True
End Sub

' Stroke event handler.
Private Sub Stroke_Event(ByVal sender As Object, _
    ByVal e As Microsoft.Ink.InkCollectorStrokeEventArgs) Handles theInkCollector.Stroke

    ' When a new stroke is collected,
    ' add it to the recognizer's strokes collection.
    Me.theStrokes.Add(e.Stroke)

    ' Tell the context to recognize its strokes.
    ' Add a time stamp as custom data for the RecognitionWithAlternates event.
    Dim timeStamp As System.DateTime = DateTime.Now
    Me.theRecognizerContext.BackgroundRecognize(timeStamp)
End Sub

' Recognition Event Handler.
Private Sub Recognition_Event(ByVal sender As Object, _
    ByVal e As Microsoft.Ink.RecognizerContextRecognitionEventArgs) _
    Handles theRecognizerContext.Recognition

    ' Update the list box
    Me.theListBox.Items.Clear()
    Me.theListBox.Items.Add("The recognition status is: " & _
        e.RecognitionStatus.ToString())
    Me.theListBox.Items.Add("The time stamp is: " & _
        DirectCast(e.CustomData, System.DateTime).ToString())
    Me.theListBox.Items.Add("The recogniton text is: " & e.Text)
End Sub

' Event handler for the form's closed event.
Private Sub RecognitionEventForm_Closed(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles MyBase.Closed
    Me.theInkCollector.Dispose()
    Me.theInkCollector = Nothing
    Me.theRecognizerContext.Dispose()
    Me.theRecognizerContext = Nothing
End Sub

See Also