Export (0) Print
Expand All

RecognizerContext.Recognize Method

Returns a RecognitionResult object for a Strokes collection.

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

public RecognitionResult Recognize(
	out RecognitionStatus recognitionStatus
)

Parameters

recognitionStatus
Type: Microsoft.Ink.RecognitionStatus%

A member of the RecognitionStatus enumeration that indicates whether an error occurred during recognition and, if so, which error occurred.

Return Value

Type: Microsoft.Ink.RecognitionResult
The RecognitionResult object for a recognized Strokes collection.

This method returns null (Nothing in Microsoft® Visual Basic® .NET) if the recognizer cannot compute a result for the Strokes collection.

NoteNote:

You must use a try/catch block when calling the Recognize method because an exception is thrown when the Ink object contains no strokes.

This method performs recognition synchronously. To start background, or asynchronous recognition, call the BackgroundRecognize or BackgroundRecognizeWithAlternates methods.

This C# example shows an event handler for a Button control's Click event, buttonSubmit_Click, that recognizes the ink in its RecognizerContext object, theRecognizerContext, declared in a containing scope. The example then displays the RecognitionResult object, theRecognitionResult in a TextBox control if no errors occurred.

private void buttonSubmit_Click(object sender, System.EventArgs e)
{
    RecognitionStatus theRecognitionStatus;
    theRecognizerContext.EndInkInput();
    try
    {
      theRecognitionResult = theRecognizerContext.Recognize(out theRecognitionStatus);
      if (RecognitionStatus.NoError == theRecognitionStatus)
      {
        theTextBox.Text = theRecognitionResult.TopString;
      }
      else
      {
         theTextBox.Text = "";
      }
    }
    catch
    {
      // If Ink object in theRecognizerContext contains no strokes or only
      // deleted strokes, exception is thrown.
      theTextBox.Text = "";
    }
}

This Microsoft® Visual Basic® .NET example shows an event handler for a Button control's Click event, buttonSubmit_Click, that recognizes the ink in its RecognizerContext object, theRecognizerContext, declared in a containing scope. The example then displays the RecognitionResult object, theRecognitionResult in a TextBox control if no errors occurred.

Private Sub Button1_Click( ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles Button1.Click
    theRecognizerContext.EndInkInput()
    Dim theRecognitionStatus As RecognitionStatus
    Try
        theRecognitionResult = theRecognizerContext.Recognize(theRecognitionStatus)
        If RecognitionStatus.NoError = theRecognitionStatus Then
            RichTextBox1.Text = theRecognitionResult.TopString
        Else
            'Handle the error conditions here.
            RichTextBox1.Text = ""
        End If
    Catch
        ' If Ink object in theRecognizerContext contains no strokes or only
        ' deleted strokes, exception is thrown.
        RichTextBox1.Text = ""
    End Try
End Sub

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

Community Additions

ADD
Show:
© 2015 Microsoft