CustomRecognizerNode.GetTextRangeFromNodes Method
Finds the text range in the recognized string that corresponds to a collection of ContextNode objects that are descendants of the CustomRecognizerNode object.
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 CustomRecognizerNode
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 void GetTextRangeFromNodes (
ContextNodeCollection subTree,
/** @attribute OutAttribute() */ /** @ref */ int start,
/** @attribute OutAttribute() */ /** @ref */ int length
)
Not applicable.
Parameters
- subTree
The collection of ContextNode objects that are descendants of the CustomRecognizerNode.
- start
The start of the text range.
- length
The length of the text range.
Remarks
If the subTree parameter contains a ContextNode object that is not a descendant of the CustomRecognizerNode, 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.
Example
The following example takes a CustomRecognizerNode, customRecognizer
, 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 lines As ContextNodeCollection = _
theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Line, customRecognizer)
Dim nLines As Integer = lines.Count
' Create a collection to hold the last line
Dim lastLineCollection As New ContextNodeCollection(theInkAnalyzer)
If nLines > 0 Then
lastLineCollection.Add(lines(nLines - 1))
End If
' Find corresponding start and length
Dim start As Integer
Dim length As Integer
customRecognizer.GetTextRangeFromNodes(lastLineCollection, start, length)
' Select this in the text box
selectedResultsTextBox.Text = customRecognizer.GetRecognizedString()
selectedResultsTextBox.Select(start, length)
ContextNodeCollection lines =
theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Line, customRecognizer);
int nLines = lines.Count;
// Create a collection to hold the last line
ContextNodeCollection lastLineCollection = new ContextNodeCollection(theInkAnalyzer);
if (nLines > 0)
{
lastLineCollection.Add(lines[nLines - 1]);
}
// Find corresponding start and length
int start, length;
customRecognizer.GetTextRangeFromNodes(lastLineCollection, out start, out length);
// Select this in the text box
selectedResultsTextBox.Text = customRecognizer.GetRecognizedString();
selectedResultsTextBox.Select(start, length);
Platforms
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
Version Information
.NET Framework
Supported in: 3.0
See Also
Reference
CustomRecognizerNode Class
CustomRecognizerNode Members
Microsoft.Ink Namespace