返回后代 ContextNode 对象的集合,这些对象与已识别字符串中的指定文本范围相关。
命名空间: System.Windows.Ink
程序集: IAWinFX(在 IAWinFX.dll 中)
语法
声明
Public Function GetNodesFromTextRange ( _
ByRef start As Integer, _
ByRef length As Integer _
) As ContextNodeCollection
用法
Dim instance As LineNode
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%
已识别字符串中文本范围的长度。
返回值
类型:System.Windows.Ink.ContextNodeCollection
后代 ContextNode 对象的集合,这些对象与已识别字符串中的指定文本范围相关。
备注
指定的文本范围应相对于当前 LineNode 的已识别字符串,而不相对于整个 RootNode 的已识别字符串。
start 和 length 参数的值可以更改,因此属于引用参数。例如,如果 GetRecognizedString 的返回值为“I am late”,并且传入值 start = 6 和 length = 1(对应于字母“a”),则 ContextNodeCollection 可能只有一个 ContextNode,即对应于单词“late”的 InkWordNode。在这种情况下,start 的值更改为 5,而 length 的值更改为 4,从而对应于整个单词“late”。
示例
下面的示例使用一个 TextBox (selectedResultsTextBox),其 Text 属性曾经设置为由 LineNode (line) 的 GetRecognizedString 返回的值。用户已经选中了 [System.Windows.Controls.TextBox] 中的部分文本。该示例代码使用所选内容并标记与所选内容对应的 Strokes。
' Find out what's been selected in the text box
Dim start As Integer = selectedResultsTextBox.SelectionStart
Dim length As Integer = selectedResultsTextBox.SelectionLength
' Return if no text is selected.
If length = 0 Then
Return
End If
' Get the nodes that correspond to that range
Dim selectedNodes As ContextNodeCollection = _
line.GetNodesFromTextRange(start, length)
' Use the new start and length value to update the
' selection in the TextBox
selectedResultsTextBox.SelectionStart = start
selectedResultsTextBox.SelectionLength = length
' Color the strokes red if part of the selected words.
' Otherwise, color them black.
For Each node As ContextNode In line.SubNodes
For Each stroke As Stroke In node.Strokes
If selectedNodes.Contains(node) Then
stroke.DrawingAttributes.Color = Colors.Red
Else
stroke.DrawingAttributes.Color = Colors.Black
End If
Next stroke
Next node
// Find out what's been selected in the text box
int start = selectedResultsTextBox.SelectionStart;
int length = selectedResultsTextBox.SelectionLength;
// Return if no text is selected.
if (length == 0)
return;
// Get the nodes that correspond to that range
ContextNodeCollection selectedNodes =
line.GetNodesFromTextRange(ref start, ref length);
// Use the new start and length value to update the
// selection in the TextBox
selectedResultsTextBox.SelectionStart = start;
selectedResultsTextBox.SelectionLength = length;
// Color the strokes red if part of the selected words.
// Otherwise, color them black.
foreach (ContextNode node in line.SubNodes)
{
foreach (Stroke stroke in node.Strokes)
{
if (selectedNodes.Contains(node))
{
stroke.DrawingAttributes.Color = Colors.Red;
}
else
{
stroke.DrawingAttributes.Color = Colors.Black;
}
}
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0