Share via


ParagraphNode.GetTextRangeFromNodes Method

Finds the text range in the recognized string that corresponds to a collection of ContextNode objects that are descendants of the ParagraphNode.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink.Analysis (in Microsoft.Ink.Analysis.dll)

Syntax

'Declaration
Public Sub GetTextRangeFromNodes ( _
    subTree As ContextNodeCollection, _
    <OutAttribute> ByRef start As Integer, _
    <OutAttribute> ByRef length As Integer _
)
'Usage
Dim instance As ParagraphNode 
Dim subTree As ContextNodeCollection 
Dim start As Integer 
Dim length As Integer

instance.GetTextRangeFromNodes(subTree, _
    start, length)
public void GetTextRangeFromNodes(
    ContextNodeCollection subTree,
    out int start,
    out int length
)
public:
void GetTextRangeFromNodes(
    ContextNodeCollection^ subTree, 
    [OutAttribute] int% start, 
    [OutAttribute] int% length
)
public function GetTextRangeFromNodes(
    subTree : ContextNodeCollection, 
    start : int, 
    length : int
)

Parameters

Remarks

If the subTree parameter contains a ContextNode object that is not a descendant of the ParagraphNode, then an ArgumentException exception is thrown.

If the subTree parameter contains ContextNode objects that are not consecutive, then the smallest text range that covers all of the ContextNode objects is returned.

Examples

The following example takes a ParagraphNode, paragraph, and finds the last line. It then finds the text range that corresponds to this line, puts the value of GetRecognizedString into a TextBox, selectedResultsTextBox, and selects the text that corresponds to the last line.

Dim nLines As Integer = paragraph.SubNodes.Count
Dim lastLine As LineNode = CType(paragraph.SubNodes(nLines - 1), LineNode)

' Create a collection to hold this line 
Dim lastLineCollection As New ContextNodeCollection(theInkAnalyzer)
lastLineCollection.Add(lastLine)

' Find corresponding start and length 
Dim start, length As Integer
paragraph.GetTextRangeFromNodes(lastLineCollection, start, length)

' Select this in the text box
selectedResultsTextBox.Text = paragraph.GetRecognizedString()
selectedResultsTextBox.Select(start, length)
                int nLines = paragraph.SubNodes.Count;
                LineNode lastLine = (LineNode)paragraph.SubNodes[nLines - 1];

                // Create a collection to hold this line
                ContextNodeCollection lastLineCollection = new ContextNodeCollection(theInkAnalyzer);
                lastLineCollection.Add(lastLine);

                // Find corresponding start and length 
                int start, length;
                paragraph.GetTextRangeFromNodes(lastLineCollection, out start, out length);

                // Select this in the text box
                selectedResultsTextBox.Text = paragraph.GetRecognizedString();
                selectedResultsTextBox.Select(start, length);

Platforms

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

ParagraphNode Class

ParagraphNode Members

Microsoft.Ink Namespace