Compartir a través de


RecognizerContextRecognitionEventArgs.Text Property

Gets a string that contains the recognition result text with the highest confidence.

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

Syntax

'Declaration
Public ReadOnly Property Text As String
'Usage
Dim instance As RecognizerContextRecognitionEventArgs
Dim value As String

value = instance.Text
public string Text { get; }
public:
property String^ Text {
    String^ get ();
}
/** @property */
public String get_Text ()
public function get Text () : String
Not applicable.

Property Value

The recognition result text with the highest confidence.

Example

This C# example is from a Form, RecognitionEventForm, that performs background recognition by calling the BackgroundRecognize method of the RecognizerContext object, theRecognizerContext, as each stroke is collected and displays the result in the ListBox control, theListBox, as they are generated.

A time stamp is used in the call to the BackgroundRecognize method. The event handler for the Recognition event, Recognition_Event, retrieves the time stamp by checking the CustomData property of the event arguments.

private Microsoft.Ink.InkCollector theInkCollector;
private Microsoft.Ink.Strokes theStrokes;
private Microsoft.Ink.RecognizerContext theRecognizerContext;

private System.Windows.Forms.ListBox theListBox;

// Event handler for the form's Load event
private void RecognitionEventForm_Load(object sender, System.EventArgs e)
{
    // Create a new ink collector and recognizer context.
    this.theInkCollector = new Microsoft.Ink.InkCollector(this.Handle);
    this.theRecognizerContext = new Microsoft.Ink.RecognizerContext();

    // Initialize the RecognizerContext object's strokes.
    this.theStrokes = this.theInkCollector.Ink.Strokes;
    this.theRecognizerContext.Strokes = this.theStrokes;

    // Attach event handlers.
    this.theInkCollector.Stroke +=
        new InkCollectorStrokeEventHandler(this.Stroke_Event);
    this.theRecognizerContext.Recognition +=
        new RecognizerContextRecognitionEventHandler(
            this.Recognition_Event);

    // Enable the ink collector
    this.theInkCollector.Enabled = true;
}

// Stroke event handler
private void Stroke_Event(object sender,
    InkCollectorStrokeEventArgs e)
{
    // When a new stroke is collected,
    // add it to the recognizer's strokes collection.
    this.theStrokes.Add(e.Stroke);

    // Tell the context to recognize its strokes.
    // Add a time stamp as custom data for the Recognition event.
    DateTime timeStamp = DateTime.Now;
    this.theRecognizerContext.BackgroundRecognize(timeStamp);
}

// Recognition Event Handler
private void Recognition_Event(
    object sender,
    RecognizerContextRecognitionEventArgs e)
{
    // Update the list box
    this.theListBox.Items.Clear();
    this.theListBox.Items.Add("The recognition status is: " + e.RecognitionStatus.ToString());
    this.theListBox.Items.Add("The time stamp is: " + ((DateTime)e.CustomData).ToString());
    this.theListBox.Items.Add("The recogniton text is: " + e.Text);
}

// Event handler for the form's closed event
private void RecognitionEventForm_Closed(object sender, System.EventArgs e)
{
    this.theInkCollector.Dispose();
    this.theInkCollector = null;
    this.theRecognizerContext.Dispose();
    this.theRecognizerContext = null;
}

This Microsoft® Visual Basic® .NET example is from a Form, RecognitionEventForm, that performs background recognition by calling the BackgroundRecognize method of the RecognizerContext object, theRecognizerContext, as each stroke is collected and displays the result in the ListBox control, theListBox, as they are generated.

A time stamp is used in the call to the BackgroundRecognize method. The event handler for the Recognition event, Recognition_Event, retrieves the time stamp by checking the CustomData property of the event arguments.

Private WithEvents theInkCollector As Microsoft.Ink.InkCollector
Private WithEvents theRecognizerContext As Microsoft.Ink.RecognizerContext
Private theStrokes As Microsoft.Ink.Strokes

' Event handler for the form's Load event.
Private Sub RecognitionEventForm_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
    ' Create a new ink collector and recognizer context.
    Me.theInkCollector = New Microsoft.Ink.InkCollector(Me.Handle)
    Me.theRecognizerContext = New Microsoft.Ink.RecognizerContext

    ' Initialize the RecognizerContext object's strokes
    Me.theStrokes = Me.theInkCollector.Ink.Strokes
    Me.theRecognizerContext.Strokes = Me.theStrokes

    ' Enable the ink collector
    Me.theInkCollector.Enabled = True
End Sub

' Stroke event handler.
Private Sub Stroke_Event(ByVal sender As Object, _
    ByVal e As Microsoft.Ink.InkCollectorStrokeEventArgs) Handles theInkCollector.Stroke

    ' When a new stroke is collected,
    ' add it to the recognizer's strokes collection.
    Me.theStrokes.Add(e.Stroke)

    ' Tell the context to recognize its strokes.
    ' Add a time stamp as custom data for the RecognitionWithAlternates event.
    Dim timeStamp As System.DateTime = DateTime.Now
    Me.theRecognizerContext.BackgroundRecognize(timeStamp)
End Sub

' Recognition Event Handler.
Private Sub Recognition_Event(ByVal sender As Object, _
    ByVal e As Microsoft.Ink.RecognizerContextRecognitionEventArgs) _
    Handles theRecognizerContext.Recognition

    ' Update the list box
    Me.theListBox.Items.Clear()
    Me.theListBox.Items.Add("The recognition status is: " & _
        e.RecognitionStatus.ToString())
    Me.theListBox.Items.Add("The time stamp is: " & _
        DirectCast(e.CustomData, System.DateTime).ToString())
    Me.theListBox.Items.Add("The recogniton text is: " & e.Text)
End Sub

' Event handler for the form's closed event.
Private Sub RecognitionEventForm_Closed(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles MyBase.Closed
    Me.theInkCollector.Dispose()
    Me.theInkCollector = Nothing
    Me.theRecognizerContext.Dispose()
    Me.theRecognizerContext = Nothing
End Sub

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

RecognizerContextRecognitionEventArgs Class
RecognizerContextRecognitionEventArgs Members
Microsoft.Ink Namespace
RecognizerContext
RecognizerContext.Recognition
Microsoft.Ink.RecognizerContext.BackgroundRecognize