Freigeben über


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

Gibt eine Auflistung von ContextNode-Nachfolgeobjekten zurück, die zu dem angegebenen Textbereich in der erkannten Zeichenfolge gehören.

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 RootNode
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

Rückgabewert

Typ: System.Windows.Ink.ContextNodeCollection
Die Auflistung von ContextNode-Nachfolgeobjekten, die sich auf den angegebenen Textbereich in der erkannten Zeichenfolge beziehen.

Hinweise

Die Parameter start und length sind Verweiswerte, die geändert werden können, sodass die gesamte Zeichenfolge angegeben wird, die der zurückgegebenen ContextNodeCollection zugeordnet sind. Wenn beispielsweise der Rückgabewert für GetRecognizedString "I am late" ist, und Sie Werte von start = 6 und length = 1 übergeben, entsprechen diese Parameter dem Buchstaben "a". Folglich enthält die ContextNodeCollection wahrscheinlich nur einen ContextNode, nämlich den InkWordNode, welcher dem Wort "late" entspricht. In diesem Beispiel wird der Wert von start zu 5, und der Wert von length zu 4 geändert. Dies entspricht dem gesamten Wort "late".

Beispiele

Im folgenden Beispiel wird die GetNodesFromTextRange-Methode verwendet, um Striche zu markieren, die ausgewähltem Text entsprechen. Der Beispielcode geht davon aus, dass die Text-Eigenschaft der TextBox namens theResultsTextBox auf den Wert festgelegt ist, der von der GetRecognizedString-Methode zurückgegeben wird, und dass der Benutzer in der theResultsTextBox Text ausgewählt hat. Außerdem wird in diesem Beispiel angenommen, dass ein InkAnalyzer mit dem Namen theInkAnalyzer vorhanden ist.

Dim theRootNode As RootNode = CType(theInkAnalyzer.RootNode, RootNode)

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

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

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

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

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

' Next, set all selected sub nodes to red
Dim node As ContextNode
For Each node In  selectedSubNodes
    Dim stroke As Stroke
    For Each stroke In  node.Strokes
        stroke.DrawingAttributes.Color = Colors.Red
    Next stroke
Next node
RootNode theRootNode = (RootNode)theInkAnalyzer.RootNode;

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

// Find out what's been selected in the text box
int selStart = theResultsTextBox.SelectionStart;
int selLength = theResultsTextBox.SelectionLength;

// Do nothing if no text is selected.
if (selLength == 0)
{
    return;
}
// Get the nodes that correspond to that range
ContextNodeCollection selectedSubNodes =
        theRootNode.GetNodesFromTextRange(ref selStart, ref selLength);


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

// 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

RootNode-Klasse

RootNode-Member

GetNodesFromTextRange-Überladung

System.Windows.Ink-Namespace