RootNode.GetTextRangeFromNodes Method
Finds the text range in the recognized string that corresponds to a collection of ContextNode objects that are descendants of the RootNode.
Namespace: System.Windows.Ink
Assembly: IAWinFX (in IAWinFX.dll)
Syntax
'Declaration
Public Sub GetTextRangeFromNodes ( _
subTree As ContextNodeCollection, _
<OutAttribute> ByRef start As Integer, _
<OutAttribute> ByRef length As Integer _
)
'Usage
Dim instance As RootNode
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
subTree
Type: System.Windows.Ink.ContextNodeCollectionThe collection of ContextNode objects that are descendants of the RootNode.
start
Type: System.Int32%The start of the text range.
length
Type: System.Int32%The length of the text range.
Remarks
If the subTree contains a ContextNode object that is not a descendant of the RootNode, 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 RootNode, theRootNode, from an InkAnalyzer named theInkAnalyzer, and finds the last WritingRegionNode by selecting the writing region with the lowest bounds. It then: finds the text range that corresponds to the current writing region; puts the value of GetRecognizedString into a TextBox named theResultsTextBox; and selects the text corresponding to that last writing region.
Dim theRootNode As RootNode = CType(theInkAnalyzer.RootNode, RootNode)
Dim regions As ContextNodeCollection = theInkAnalyzer.FindNodesOfType(ContextNodeType.WritingRegion)
Dim lastRegion As WritingRegionNode = Nothing
Dim maxY As Double = Double.MinValue
Dim region As WritingRegionNode
For Each region In regions
If [region].Location.GetBounds().Bottom > maxY Then
maxY = [region].Location.GetBounds().Bottom
lastRegion = [region]
End If
Next region
If lastRegion Is Nothing Then
Return
End If
' Create a collection to hold this line
Dim lastRegionCollection As New ContextNodeCollection(theInkAnalyzer)
lastRegionCollection.Add(lastRegion)
' Find corresponding start and length
Dim start, length As Integer
theRootNode.GetTextRangeFromNodes(lastRegionCollection, start, length)
' Select this in the text box
theResultsTextBox.Text = theRootNode.GetRecognizedString()
theResultsTextBox.Select(start, length)
RootNode theRootNode = (RootNode)theInkAnalyzer.RootNode;
ContextNodeCollection regions =
theInkAnalyzer.FindNodesOfType(ContextNodeType.WritingRegion);
WritingRegionNode lastRegion = null;
double maxY = double.MinValue;
foreach (WritingRegionNode region in regions)
{
if (region.Location.GetBounds().Bottom > maxY)
{
maxY = region.Location.GetBounds().Bottom;
lastRegion = region;
}
}
if (lastRegion == null)
return;
// Create a collection to hold this line
ContextNodeCollection lastRegionCollection =
new ContextNodeCollection(theInkAnalyzer);
lastRegionCollection.Add(lastRegion);
// Find corresponding start and length
int start, length;
theRootNode.GetTextRangeFromNodes(lastRegionCollection, out start, out length);
// Select this in the text box
theResultsTextBox.Text = theRootNode.GetRecognizedString();
theResultsTextBox.Select(start, length);
Platforms
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
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