InkAnalyzer.GetNodesFromTextRange 方法 (Int32%, Int32%, ContextNodeCollection)
返回与指定上下文节点的指定文本范围有关的 ContextNode 对象的集合。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink.Analysis(在 Microsoft.Ink.Analysis.dll 中)
语法
声明
Public Function GetNodesFromTextRange ( _
ByRef start As Integer, _
ByRef length As Integer, _
nodesToSearch As ContextNodeCollection _
) As ContextNodeCollection
用法
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
)
public function GetNodesFromTextRange(
start : int,
length : int,
nodesToSearch : ContextNodeCollection
) : ContextNodeCollection
参数
- start
类型:System.Int32%
对已识别字符串的 nodesToSearch 部分中文本范围的起点的引用。
- length
类型:System.Int32%
对已识别字符串的 nodesToSearch 部分中文本范围的长度的引用。
- nodesToSearch
类型:Microsoft.Ink.ContextNodeCollection
要将搜索范围限制到的 ContextNode 对象。
返回值
类型:Microsoft.Ink.ContextNodeCollection
与指定上下文节点的指定文本范围有关的 ContextNode 对象。
备注
指定的文本范围应相对于 InkAnalyzer 的已识别字符串的 nodesToSearch 部分,而不相对于整个 InkAnalyzer 的已识别字符串。
此方法通过将文本范围扩展到最近的单词边界来修改 start 和 length 参数的值。
例如,如果已识别字符串为“I am late”,且调用此方法时将 start 和 length 的值分别设置为 6 和 1(这对应于“late”中的字母“a”),则此方法返回的集合包含一个 ContextNode 以及 InkWordNode 或 TextWordNode,对应于单词“late”。对于此示例,此方法还将 start 的值修改为 5,并将 length 的值修改为 4,这对应于单词“late”。
备注
start 参数相对于 nodesToSearch 参数的已识别字符串。
示例
此示例使用一个 System.Windows.Forms.TextBox (theResultsTextBox),其 Text 属性已设置为 ContextNodeCollection (nodesToSearch) 中节点的合并的已识别字符串。nodesToSearch 集合包含来自 InkAnalyzer (theInkAnalyzer) 的上下文节点。该示例代码获取文本框选择内容并标记与所选内容对应的 Strokes。
' 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);
}
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0