InkAnalyzer.GetNodesFromTextRange 方法 (Int32%, Int32%)
返回与指定文本范围有关的 ContextNode 对象的集合。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink.Analysis(在 Microsoft.Ink.Analysis.dll 中)
语法
声明
Public Function GetNodesFromTextRange ( _
ByRef start As Integer, _
ByRef length As Integer _
) As ContextNodeCollection
用法
Dim instance As InkAnalyzer
Dim start As Integer
Dim length As Integer
Dim returnValue As ContextNodeCollection
returnValue = instance.GetNodesFromTextRange(start, _
length)
public ContextNodeCollection GetNodesFromTextRange(
ref int start,
ref int length
)
public:
ContextNodeCollection^ GetNodesFromTextRange(
int% start,
int% length
)
public ContextNodeCollection GetNodesFromTextRange(
/** @ref */int start,
/** @ref */int length
)
public function GetNodesFromTextRange(
start : int,
length : int
) : ContextNodeCollection
参数
- start
类型:System.Int32%
对已识别字符串中文本范围的起点的引用。
- length
类型:System.Int32%
对已识别字符串中文本范围的长度的引用。
返回值
类型:Microsoft.Ink.ContextNodeCollection
与指定文本范围有关的 ContextNode 对象的集合。
备注
指定的文本范围应相对于整个 InkAnalyzer 的已识别字符串。
此方法通过将文本范围扩展到最近的单词边界来修改 start 和 length 参数的值。
例如,如果已识别字符串为“I am late”,且调用此方法时将 start 和 length 的值分别设置为 6 和 1(这对应于“late”中的字母“a”),则此方法返回的集合包含一个 ContextNode 以及 InkWordNode 或 TextWordNode,对应于单词“late”。对于此示例,此方法还将 start 的值修改为 5,并将 length 的值修改为 4,这对应于单词“late”。
示例
此示例使用一个 System.Windows.Forms.TextBox (theResultsTextBox),其 Text 属性事先设置为由 InkAnalyzer (theInkAnalyzer) 的 GetRecognizedString 返回的值。该示例代码获取文本框选择内容并标记与所选内容对应的 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)
' 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);
// 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