RecognitionResult.SetResultOnStrokes 方法

RecognitionResult 对象分配给用于生成结果的 Strokes 集合。

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

语法

声明
Public Sub SetResultOnStrokes
用法
Dim instance As RecognitionResult

instance.SetResultOnStrokes()
public void SetResultOnStrokes()
public:
void SetResultOnStrokes()
public void SetResultOnStrokes()
public function SetResultOnStrokes()

备注

如果自动为每个 Strokes 集合分配识别结果,会影响系统性能。因此,默认情况下,结果不会附加到 Strokes 集合。必须调用 Strokes 方法才能为 SetResultOnStrokes 集合分配结果。若要返回 Strokes 集合的识别结果,请使用 Strokes 集合的 RecognitionResult 属性。将结果分配给 Strokes 集合后,可将笔画 存储在 CustomStrokes 集合中。这些自定义笔画以及 RecognitionResult 可以进行保存,以备以后使用时检索。

示例

此示例处理同步识别以响应用户操作(如单击菜单项或按钮)。首先,从 InkOverlay 对象的关联 Strokes 集合分配 RecognizerContext 对象的 Strokes 集合,并检查笔画计数。如果 Strokes 集合包含至少一个 Stroke 对象,则调用 Recognize 方法开始识别过程。如果识别成功,则调用 SetResultOnStrokes 方法将 RecognizerContext 对象附加到对应的 Strokes 集合。最后,Strokes 集合保存为命名 CustomStrokes 集合。此操作同时保存附加的 RecognitionResult

' assign strokes collection from the collected strokes
Me.mRecognizerContext.Strokes = Me.mInkOverlay.Ink.Strokes
' check stroke count. Recognize() will throw exception if no strokes
If Me.mRecognizerContext.Strokes.Count > 0 Then
    Dim status As RecognitionStatus
    ' perform the recognition
    Dim rResult As RecognitionResult = Me.mRecognizerContext.Recognize(status)
    ' check status
    If RecognitionStatus.NoError = status Then
        ' attach RecognitionResult to the Strokes collection
        rResult.SetResultOnStrokes()
        ' save the strokes collection (with RecognitionResult attached)
        Try
            mInkOverlay.Ink.CustomStrokes.Add("customCollectionName", rResult.Strokes)
        Catch ex As ArgumentException
            ' this exception is raised when the named collection already exists
        End Try
    End If
End If
// assign strokes collection from the collected strokes
this.mRecognizerContext.Strokes = this.mInkOverlay.Ink.Strokes;
// check stroke count. Recognize() will throw exception if no strokes
if (this.mRecognizerContext.Strokes.Count > 0)
{
    RecognitionStatus status;
    // perform the recognition
    RecognitionResult rResult = this.mRecognizerContext.Recognize(out status);
    // check status
    if (RecognitionStatus.NoError == status)
    {
        // attach RecognitionResult to the Strokes collection
        rResult.SetResultOnStrokes();
        // save the strokes collection (with RecognitionResult attached)
        try
        {
            mInkOverlay.Ink.CustomStrokes.Add("customCollectionName", rResult.Strokes);
        }
        catch (ArgumentException)
        {
            // this exception is raised when the named collection already exists
        }
    }
}

平台

Windows Vista

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

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

RecognitionResult 类

RecognitionResult 成员

Microsoft.Ink 命名空间

Strokes

CustomStrokes