RecognizerContext.Recognize 方法

Strokes 集合返回 RecognitionResult 对象。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public Function Recognize ( _
    <OutAttribute> ByRef recognitionStatus As RecognitionStatus _
) As RecognitionResult
用法
Dim instance As RecognizerContext
Dim recognitionStatus As RecognitionStatus
Dim returnValue As RecognitionResult

returnValue = instance.Recognize(recognitionStatus)
public RecognitionResult Recognize(
    out RecognitionStatus recognitionStatus
)
public:
RecognitionResult^ Recognize(
    [OutAttribute] RecognitionStatus% recognitionStatus
)
public RecognitionResult Recognize(
    /** @attribute OutAttribute */ /** @ref */RecognitionStatus recognitionStatus
)
public function Recognize(
    recognitionStatus : RecognitionStatus
) : RecognitionResult

参数

返回值

类型:Microsoft.Ink.RecognitionResult
已识别的 Strokes 集合的 RecognitionResult 对象。

备注

如果识别器 无法计算 Strokes 集合的结果,则此方法返回 null(在 Microsoft(R) Visual Basic(R) .NET 中为 Nothing)。

备注

调用 Recognize 方法时必须使用 try/catch 块,这是因为在 Ink 对象不包含笔画的情况下将引发异常。

此方法以同步方式执行识别。若要启动后台识别(即异步识别),请调用 BackgroundRecognizeBackgroundRecognizeWithAlternates 方法。

示例

此 C# 示例演示 Button 控件的 Click 事件的事件处理程序 buttonSubmit_Click,该事件处理程序识别其 RecognizerContext 对象 theRecognizerContext(在包含范围中声明)中的墨迹。然后,该示例在不发生错误的情况下将 RecognitionResult 对象 theRecognitionResult 显示在 TextBox 控件中。

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 = "";
    }
}

此 Microsoft(R) Visual Basic(R) .NET 示例演示 Button 控件的 Click 事件的事件处理程序 buttonSubmit_Click,该事件处理程序识别其 RecognizerContext 对象 theRecognizerContext(在包含范围中声明)中的墨迹。然后,该示例在不发生错误的情况下将 RecognitionResult 对象 theRecognitionResult 显示在 TextBox 控件中。

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 Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

RecognizerContext 类

RecognizerContext 成员

Microsoft.Ink 命名空间

RecognizerContext.BackgroundRecognize

RecognizerContext.BackgroundRecognizeWithAlternates

Ink

Strokes

RecognitionResult.Strokes