Freigeben über


ParagraphNode.GetNodesFromTextRange-Methode (Int32%, Int32%)

Gibt eine ContextNodeCollection zurück, die untergeordnete ContextNode-Objekte enthält, die für den angegebenen Textbereich in der erkannten Zeichenfolge relevant sind.

Namespace:  System.Windows.Ink
Assembly:  IAWinFX (in IAWinFX.dll)

Syntax

'Declaration
Public Function GetNodesFromTextRange ( _
    ByRef start As Integer, _
    ByRef length As Integer _
) As ContextNodeCollection
'Usage
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

Parameter

  • start
    Typ: System.Int32%
    Der Anfang des Textbereichs in der erkannten Zeichenfolge.
  • length
    Typ: System.Int32%
    Die Länge des Textbereichs in der erkannten Zeichenfolge.

Rückgabewert

Typ: System.Windows.Ink.ContextNodeCollection
Eine ContextNodeCollection, die untergeordnete ContextNode-Objekte enthält, die für den angegebenen Textbereich in der erkannten Zeichenfolge relevant sind.

Hinweise

Der Textbereich sollte relativ zur erkannten Zeichenfolge des aktuellen ParagraphNode und nicht relativ zur erkannten Zeichenfolge des gesamten RootNode angegeben werden.

Beispiele

Im folgenden Beispiel wird ein TextBox, selectedResultsTextBox, erfasst, dessen Text-Eigenschaft zuvor anhand des Wertes, der von GetRecognizedString für eine ParagraphNode, paragraph zurückgegeben wurde, festgelegt wurde. Der Benutzer hat Text in der TextBox ausgewählt. Im Beispielcode wird die Auswahl erfasst, und die Strokes werden markiert, die dieser Auswahl entsprechen.

' 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;
    }
}

Plattformen

Windows Vista

.NET Framework und .NET Compact Framework unterstützen nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.

Versionsinformationen

.NET Framework

Unterstützt in: 3.0

Siehe auch

Referenz

ParagraphNode-Klasse

ParagraphNode-Member

GetNodesFromTextRange-Überladung

System.Windows.Ink-Namespace