Condividi tramite


Metodo ParagraphNode.GetNodesFromTextRange (Int32%, Int32%)

Aggiornamento: novembre 2007

Restituisce un oggetto ContextNodeCollection contenente gli oggetti ContextNode discendenti rilevanti per l'intervallo di testo specificato nella stringa riconosciuta.

Spazio dei nomi:  System.Windows.Ink
Assembly:  IAWinFX (in IAWinFX.dll)

Sintassi

'Dichiarazione
Public Function GetNodesFromTextRange ( _
    ByRef start As Integer, _
    ByRef length As Integer _
) As ContextNodeCollection
'Utilizzo
Dim instance As ParagraphNode
Dim start As Integer
Dim length As Integer
Dim returnValue As ContextNodeCollection

returnValue = instance.GetNodesFromTextRange(start, _
    length)
public ContextNodeCollection GetNodesFromTextRange(
    ref int start,
    ref int length
)
public:
ContextNodeCollection^ GetNodesFromTextRange(
    int% start, 
    int% length
)
public ContextNodeCollection GetNodesFromTextRange(
    /** @ref */int start,
    /** @ref */int length
)
public function GetNodesFromTextRange(
    start : int, 
    length : int
) : ContextNodeCollection

Parametri

  • start
    Tipo: System.Int32%
    Inizio dell'intervallo di testo nella stringa riconosciuta.
  • length
    Tipo: System.Int32%
    Lunghezza dell'intervallo di testo nella stringa riconosciuta.

Valore restituito

Tipo: System.Windows.Ink.ContextNodeCollection
Oggetto ContextNodeCollection contenente gli oggetti ContextNode discendenti rilevanti per l'intervallo di testo specificato nella stringa riconosciuta.

Note

L'intervallo di testo specificato deve essere relativo alla stringa riconosciuta dell'oggetto ParagraphNode corrente, anziché alla stringa riconosciuta dell'intero oggetto RootNode.

Esempi

Nell'esempio seguente viene utilizzato un oggetto TextBox, selectedResultsTextBox, la cui proprietà Text è stata precedentemente impostata sul valore restituito da GetRecognizedString per un oggetto ParagraphNode, paragraph. L'utente ha selezionato un testo nell'oggetto TextBox. Nel codice di esempio viene utilizzata la selezione e viene contrassegnato l'oggetto Strokes che corrisponde a tale selezione.

' Find out what's been selected in the text box
Dim selStart As Integer = selectedResultsTextBox.SelectionStart
Dim selLength As Integer = selectedResultsTextBox.SelectionLength

' Return if no text is selected.
If selLength = 0 Then
    Return
End If

' Get the nodes that correspond to that range
Dim selectedSubNodes As ContextNodeCollection = _
    paragraph.GetNodesFromTextRange(selStart, selLength)

' Use the new start and length value to update the
' selection in the TextBox
selectedResultsTextBox.SelectionStart = selStart
selectedResultsTextBox.SelectionLength = selLength

' First, set all strokes to black
For Each Stroke As Stroke In paragraph.Strokes
    Stroke.DrawingAttributes.Color = Colors.Black
Next Stroke

' Next, set all selected sub nodes to red
For Each node As ContextNode In selectedSubNodes
    Dim stroke As Stroke
    For Each stroke In node.Strokes
        stroke.DrawingAttributes.Color = Colors.Red
    Next stroke
Next node
// Find out what's been selected in the text box
int selStart = selectedResultsTextBox.SelectionStart;
int selLength = selectedResultsTextBox.SelectionLength;

// Return if no text is selected.
if (selLength == 0)
    return;

// Get the nodes that correspond to that range
ContextNodeCollection selectedSubNodes =
        paragraph.GetNodesFromTextRange(ref selStart, ref selLength);


// Use the new start and length value to update the
// selection in the TextBox
selectedResultsTextBox.SelectionStart = selStart;
selectedResultsTextBox.SelectionLength = selLength;

// First, set all strokes to black
foreach (Stroke stroke in paragraph.Strokes)
    stroke.DrawingAttributes.Color = Colors.Black;

// Next, set all selected sub nodes to red
foreach (ContextNode node in selectedSubNodes)
{
    foreach (Stroke stroke in node.Strokes)
    {
        stroke.DrawingAttributes.Color = Colors.Red;
    }
}

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

ParagraphNode Classe

Membri ParagraphNode

Overload GetNodesFromTextRange

Spazio dei nomi System.Windows.Ink