Поделиться через


RecognitionResult.SetResultOnStrokes - метод

Обновлен: Ноябрь 2007

Assigns the RecognitionResult object to the Strokes collection that was used to generate the results.

Пространство имен:  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()

Заметки

System performance suffers if recognition results are automatically assigned to every Strokes collection. Therefore results are not attached to a Strokes collection by default. To assign results to a Strokes collection, you must call the SetResultOnStrokes method. To return the recognition results for a Strokes collection, use the RecognitionResult property of the Strokes collection. After you assign results to a Strokes collection, you can then store the strokes in a CustomStrokes collection. These custom strokes, as well as the RecognitionResult, can be persisted and retrieved for later use.

Примеры

In this example, synchronous recognition is handled in response to a user action such as clicking on a menu item or a button. First, the Strokes collection of a RecognizerContext object is assigned from the Strokes collection associated with an InkOverlay object, and checked for stroke count. If the Strokes collection contains at least one Stroke object, the recognition process begins with a call to the Recognize method. If recognition is successful, the SetResultOnStrokes method is called to attach the RecognizerContext object to its corresponding Strokes collection. Finally, the Strokes collection is saved as a named CustomStrokes collection. This saves the attached RecognitionResult as well.

' 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