Поделиться через


InkAnalyzer.GetNodesFromTextRange - метод (Int32%, Int32%)

Обновлен: Ноябрь 2007

Returns a ContextNodeCollection that contains ContextNode objects pertaining to the specified text range.

Пространство имен:  System.Windows.Ink
Сборка:  IAWinFX (в IAWinFX.dll)

Синтаксис

'Декларация
Public Function GetNodesFromTextRange ( _
    ByRef start As Integer, _
    ByRef length As Integer _
) As ContextNodeCollection
'Применение
Dim instance As InkAnalyzer
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

Параметры

Возвращаемое значение

Тип: System.Windows.Ink.ContextNodeCollection
The collection of ContextNode objects that are relevant to the specified text range.

Заметки

The specified text range should be relative to the recognized string of the entire InkAnalyzer.

This method modifies the values of the start and length parameters by expanding the text range to the nearest word boundaries. For example, if the recognized string is "I am late", you call this method using parameter values of 6 for start and 1 for length(corresponding to the letter "a" in "late"). The method returns a collection comprised by a single ContextNode, namely the InkWordNode or the TextWordNode. The method in this example also modifies the value of start to 5 and the value of length to 4 (which corresponds to the word "late").

Примеры

This example resets the Text property of a TextBox named theResultsTextBox, from the value returned by GetRecognizedString() for the InkAnalyzer (theInkAnalyzer), to new values in the text box selection that mark the Strokes corresponding to the text box selection.

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

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

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

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

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

// Get the nodes that correspond to that range
ContextNodeCollection selectedSubNodes =
    this.theInkAnalyzer.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;

// First, set all strokes to black
foreach (Stroke theStroke
    in this.theInkAnalyzer.RootNode.Strokes)
{
    theStroke.DrawingAttributes.Color = Colors.Black;
}

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

Платформы

Windows Vista

Среды .NET Framework и .NET Compact Framework поддерживают не все версии каждой платформы. Поддерживаемые версии перечислены в разделе Требования к системе для .NET Framework.

Сведения о версии

.NET Framework

Поддерживается в версии: 3.0

См. также

Ссылки

InkAnalyzer Класс

InkAnalyzer - члены

GetNodesFromTextRange - перегрузка

System.Windows.Ink - пространство имен