InkAnalyzer.GetNodesFromTextRange Method (Int32, Int32, ContextNodeCollection)
Returns a collection of ContextNode objects that are relevant to the specified text range for the specified context nodes.
Namespace: Microsoft.Ink
Assembly: Microsoft.Ink.Analysis (in microsoft.ink.analysis.dll)
Syntax
'Declaration
Public Function GetNodesFromTextRange ( _
ByRef start As Integer, _
ByRef length As Integer, _
nodesToSearch As ContextNodeCollection _
) As ContextNodeCollection
'Usage
Dim instance As InkAnalyzer
Dim start As Integer
Dim length As Integer
Dim nodesToSearch As ContextNodeCollection
Dim returnValue As ContextNodeCollection
returnValue = instance.GetNodesFromTextRange(start, length, nodesToSearch)
public ContextNodeCollection GetNodesFromTextRange (
ref int start,
ref int length,
ContextNodeCollection nodesToSearch
)
public:
ContextNodeCollection^ GetNodesFromTextRange (
int% start,
int% length,
ContextNodeCollection^ nodesToSearch
)
public ContextNodeCollection GetNodesFromTextRange (
/** @ref */ int start,
/** @ref */ int length,
ContextNodeCollection nodesToSearch
)
Not applicable.
Parameters
- start
A reference to the start of the text range in the nodesToSearch portion of the recognized string.
- length
A reference to the length of the text range in the nodesToSearch portion of the recognized string.
- nodesToSearch
The ContextNode objects to which to limit the search.
Return Value
The ContextNode objects that are relevant to the specified text range for the specified context nodes.
Remarks
The specified text range should be relative to the nodesToSearch portion of the recognized string of the InkAnalyzer, rather than 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" and you call this method using the parameter values of 6 for start and 1 for length, which corresponds to the letter "a" in "late", this method returns a collection containing a single ContextNode, the InkWordNode or TextWordNode that corresponds to the word "late". For this example, this method also modifies the value of start to 5 and the value of length to 4, which corresponds to the word "late".
Note
The start parameter is relative to the recognized string of the nodesToSearch parameter.
Example
This example takes a System.Windows.Forms.TextBox, theResultsTextBox
, whose Text property has been set to the combined recognized strings of the nodes in the ContextNodeCollection, nodesToSearch
. The nodesToSearch
collection contains context nodes from the InkAnalyzer, theInkAnalyzer
. The example code takes the text box selection and marks the Strokes that correspond to that 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 Microsoft.Ink.ContextNodeCollection = _
Me.theInkAnalyzer.GetNodesFromTextRange( _
selStart, selLength, nodesToSearch)
' 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
Dim theStroke As Microsoft.Ink.Stroke
For Each theStroke In Me.theInkAnalyzer.RootNode.Strokes
theStroke.DrawingAttributes = _
New Microsoft.Ink.DrawingAttributes(Color.Black)
Next theStroke
' Next, set all selected sub nodes to red
Dim theContextNode As Microsoft.Ink.ContextNode
For Each theContextNode In selectedSubNodes
For Each theStroke In theContextNode.Strokes
theStroke.DrawingAttributes = _
New Microsoft.Ink.DrawingAttributes(Color.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
Microsoft.Ink.ContextNodeCollection selectedSubNodes =
this.theInkAnalyzer.GetNodesFromTextRange(
ref selStart, ref selLength, nodesToSearch);
// 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 (Microsoft.Ink.Stroke theStroke
in this.theInkAnalyzer.RootNode.Strokes)
{
theStroke.DrawingAttributes =
new Microsoft.Ink.DrawingAttributes(Color.Black);
}
// Next, set all selected sub nodes to red
foreach (Microsoft.Ink.ContextNode theContextNode in selectedSubNodes)
{
foreach (Microsoft.Ink.Stroke theStroke in theContextNode.Strokes)
{
theStroke.DrawingAttributes =
new Microsoft.Ink.DrawingAttributes(Color.Red);
}
}
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
InkAnalyzer Class
InkAnalyzer Members
Microsoft.Ink Namespace