Condividi tramite


Metodo InkAnalyzer.GetTextRangeFromNodes

Aggiornamento: novembre 2007

Trova l'intervallo di testo nella stringa riconosciuta corrispondente a un insieme di oggetti ContextNode.

Spazio dei nomi:  Microsoft.Ink
Assembly:  Microsoft.Ink.Analysis (in Microsoft.Ink.Analysis.dll)

Sintassi

'Dichiarazione
Public Sub GetTextRangeFromNodes ( _
    nodesToSearch As ContextNodeCollection, _
    <OutAttribute> ByRef start As Integer, _
    <OutAttribute> ByRef length As Integer _
)
'Utilizzo
Dim instance As InkAnalyzer
Dim nodesToSearch As ContextNodeCollection
Dim start As Integer
Dim length As Integer

instance.GetTextRangeFromNodes(nodesToSearch, _
    start, length)
public void GetTextRangeFromNodes(
    ContextNodeCollection nodesToSearch,
    out int start,
    out int length
)
public:
void GetTextRangeFromNodes(
    ContextNodeCollection^ nodesToSearch, 
    [OutAttribute] int% start, 
    [OutAttribute] int% length
)
public void GetTextRangeFromNodes(
    ContextNodeCollection nodesToSearch,
    /** @attribute OutAttribute */ /** @ref */int start,
    /** @attribute OutAttribute */ /** @ref */int length
)
public function GetTextRangeFromNodes(
    nodesToSearch : ContextNodeCollection, 
    start : int, 
    length : int
)

Parametri

  • start
    Tipo: System.Int32%
    Alla restituzione di questo metodo, il parametro start contiene un valore integer con segno a 32 bit che indica l'inizio dell'intervallo di testo. Questo parametro viene passato senza inizializzazione.
  • length
    Tipo: System.Int32%
    Alla restituzione di questo metodo, il parametro length contiene un valore integer con segno a 32 bit che indica la lunghezza dell'intervallo di testo. Questo parametro viene passato senza inizializzazione.

Note

Se il parametro nodesToSearch contiene oggetti ContextNode non adiacenti, questo metodo restituisce l'intervallo di testo più piccolo in cui rientrano tutti gli oggetti ContextNode.

Questo metodo genera un'eccezione System.ArgumentException quando nodesToSearch contiene un oggetto ContextNode che non è associato all'oggetto InkAnalyzer.

Esempi

In questo esempio viene definito un metodo, SelectTextRangeFromNodes, che imposta il testo dell'oggetto System.Windows.Forms.TextBox, theResultsTextBox sulla stringa di riconoscimento dell'oggetto InkAnalyzer, theInkAnalyzer. Viene quindi impostata la selezione della casella di testo per estendere il testo riconosciuto per il parametro, theContextNodes.

''' <summary>
''' Selects the text range in the TextBox, theResultsTextBox, that represents
''' the node ranges in theContextNodes.
''' </summary>
''' <param name="theContextNodes">
''' The nodes for which to select the text range.</param>
''' <remarks>
''' If <paramref name="theContextNodes"/> are not current context nodes
''' of the InkAnalyzer, theInkAnalyzer, then GetTextRangeFromNodes throws
''' an ArgumentException.
''' </remarks>
Private Sub SelectTextRangeFromNodes(ByVal theContextNodes As Microsoft.Ink.ContextNodeCollection)
    ' Set the text of theResultsTextBox.
    Me.theResultsTextBox.Text = Me.theInkAnalyzer.GetRecognizedString()

    ' Get the text range for theContextNodes.
    Dim theStart As Integer
    Dim theLength As Integer
    Try
        Me.theInkAnalyzer.GetTextRangeFromNodes( _
            theContextNodes, theStart, theLength)
        ' Check for common exceptions.
    Catch ex As ArgumentException
        Throw New ArgumentException( _
            "Invalid ContextNodeCollection", "theContextNodes", ex)
    End Try

    ' Select the text range in the TextBox.
    Me.theResultsTextBox.Select(theStart, theLength)
    Me.theResultsTextBox.Invalidate()

End Sub 'SelectTextRangeFromNodes
/// <summary>
/// Selects the text range in the TextBox, theResultsTextBox, that represents
/// the node ranges in theContextNodes.
/// </summary>
/// <param name="theContextNodes">
/// The nodes for which to select the text range.</param>
/// <remarks>
/// If <paramref name="theContextNodes"/> are not current context nodes
/// of the InkAnalyzer, theInkAnalyzer, then GetTextRangeFromNodes throws
/// an ArgumentException.
/// </remarks>
private void SelectTextRangeFromNodes(
    Microsoft.Ink.ContextNodeCollection theContextNodes)
{
    // Set the text of theResultsTextBox.
    this.theResultsTextBox.Text = this.theInkAnalyzer.GetRecognizedString();

    // Get the text range for theContextNodes.
    int theStart;
    int theLength;
    try
    {
        this.theInkAnalyzer.GetTextRangeFromNodes(
            theContextNodes, out theStart, out theLength);
    }
    // Check for common exceptions.
    catch (ArgumentException ex)
    {
        throw new ArgumentException("Invalid ContextNodeCollection",
            "theContextNodes", ex);
    }

    // Select the text range in the TextBox.
    this.theResultsTextBox.Select(theStart, theLength);
    this.theResultsTextBox.Invalidate();
}

Piattaforme

Windows Vista

.NET Framework e .NET Compact Framework non supportano tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.

Informazioni sulla versione

.NET Framework

Supportato in: 3.0

Vedere anche

Riferimenti

InkAnalyzer Classe

Membri InkAnalyzer

Spazio dei nomi Microsoft.Ink