RecognitionResult.Strokes 属性

获取识别器 用来生成 RecognitionResult 对象的 Strokes 集合。

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

语法

声明
Public ReadOnly Property Strokes As Strokes
用法
Dim instance As RecognitionResult
Dim value As Strokes

value = instance.Strokes
public Strokes Strokes { get; }
public:
property Strokes^ Strokes {
    Strokes^ get ();
}
/** @property */
public Strokes get_Strokes()
public function get Strokes () : Strokes

属性值

类型:Microsoft.Ink.Strokes
识别器 用来生成 RecognitionResult 对象的 Strokes 集合。

备注

默认情况下,RecognitionResult 对象未附加到 Strokes 集合。若要向 Strokes 集合分配结果,必须调用 RecognitionResult 对象的 SetResultOnStrokes 方法。

示例

此示例处理同步识别以响应用户操作(如单击菜单项或按钮)。首先,从 InkOverlay 对象的关联 Strokes 集合分配 RecognizerContext 对象的 Strokes 集合,并检查笔画计数。如果 Strokes 集合包含至少一个 Stroke 对象,则调用 Recognize 方法开始识别过程。如果识别成功,并且 TopConfidence(如果支持)不等于 RecognitionConfidencePoor(即为 IntermediateStrong),则将 TopString 添加到列表框中进行显示。

' 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)
    ' see if the recognizer used supports confidence levels
    Dim rSupportsConfidence As Boolean = RecognizerSupportsConfidence(mRecognizerContext.Recognizer)
    ' check status and TopConfidence (if supported)
    If (RecognitionStatus.NoError = status And _
        ((rSupportsConfidence And _
         rResult.TopConfidence <> RecognitionConfidence.Poor) Or _
         Not rSupportsConfidence)) Then
        listBoxRecognitionResults.Items.Add(rResult.TopString)
    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);
    // see if the recognizer used supports confidence levels
    bool rSupportsConfidence = RecognizerSupportsConfidence(mRecognizerContext.Recognizer);
    // check status and TopConfidence (if supported)
    if (RecognitionStatus.NoError == status &&
        ((rSupportsConfidence &&
         rResult.TopConfidence != RecognitionConfidence.Poor) ||
         !rSupportsConfidence))
    {
        listBoxRecognitionResults.Items.Add(rResult.TopString);
    }
}

下面的示例演示用于确定 Recognizer 是否支持置信级别的帮助器方法。

Private Function RecognizerSupportsConfidence(ByVal pRecognizer As Recognizer) As Boolean
    For Each G As Guid In pRecognizer.SupportedProperties
        If G = RecognitionProperty.ConfidenceLevel Then
            Return True
        End If
    Next
    Return False
End Function
private bool RecognizerSupportsConfidence(Recognizer pRecognizer)
{
    foreach (Guid G in pRecognizer.SupportedProperties)
    {
        if (G == RecognitionProperty.ConfidenceLevel)
        {
            return true;
        }
    }
    return false;
}

平台

Windows Vista

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

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

RecognitionResult 类

RecognitionResult 成员

Microsoft.Ink 命名空间

Strokes