返回后代 ContextNode 对象的集合,这些对象与已识别字符串中的指定文本范围相关。
命名空间: System.Windows.Ink
程序集: IAWinFX(在 IAWinFX.dll 中)
语法
声明
Public Function GetNodesFromTextRange ( _
ByRef start As Integer, _
ByRef length As Integer _
) As ContextNodeCollection
用法
Dim instance As CustomRecognizerNode
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 对象的集合,这些对象与已识别字符串中的指定文本范围相关。
备注
指定的文本范围应相对于此 CustomRecognizerNode 的已识别字符串,而不相对于整个 RootNode 的已识别字符串。
示例
下面的示例使用名为 selectedResultsTextBox 的 TextBox。在此之前,Text 属性已设置为 CustomRecognizerNode 对象 customRecognizer 的 GetRecognizedString 所返回的值。用户已选中了 TextBox 中的一些文本。如果 InkRecognitionConfidence 级别为 Strong(),则与用户的选定内容对应的 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
' Only highlight if strong recognition
If customRecognizer.InkRecognitionConfidence = _
InkRecognitionConfidence.Strong Then
Dim selectedNodes As ContextNodeCollection = _
customRecognizer.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 Stroke As Stroke In customRecognizer.Strokes
Stroke.DrawingAttributes.Color = Colors.Black
Next Stroke
For Each selectedNode As ContextNode In selectedNodes
For Each Stroke As Stroke In selectedNode.Strokes
Stroke.DrawingAttributes.Color = Colors.Red
Next Stroke
Next selectedNode
End If
// 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;
// Only highlight if strong recognition
if (customRecognizer.InkRecognitionConfidence == InkRecognitionConfidence.Strong)
{
ContextNodeCollection selectedNodes =
customRecognizer.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 (Stroke stroke in customRecognizer.Strokes)
{
stroke.DrawingAttributes.Color = Colors.Black;
}
foreach (ContextNode selectedNode in selectedNodes)
{
foreach (Stroke stroke in selectedNode.Strokes)
{
stroke.DrawingAttributes.Color = Colors.Red;
}
}
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0