CustomRecognizerNode.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 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%
已识别字符串中文本范围的长度。
返回值
类型:Microsoft.Ink.ContextNodeCollection
返回后代 ContextNode 对象的集合,这些对象与已识别字符串中的指定文本范围相关。
备注
指定的文本范围应相对于此 CustomRecognizerNode 的已识别字符串,而不相对于整个 RootNode 的已识别字符串。
示例
下面的示例使用 TextBox (selectedResultsTextBox)。此前,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
' Only highlight if strong recognition
If customRecognizer.InkRecognitionConfidence = Microsoft.Ink.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.
Dim theStroke As Stroke
For Each theStroke In customRecognizer.Strokes
theStroke.DrawingAttributes = _
New DrawingAttributes(Color.Black)
Next theStroke
Dim selectedNode As ContextNode
For Each selectedNode In selectedNodes
For Each theStroke In selectedNode.Strokes
theStroke.DrawingAttributes = _
New DrawingAttributes(Color.Red)
Next theStroke
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 == Microsoft.Ink.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 =
new DrawingAttributes(Color.Black);
}
foreach (ContextNode selectedNode in selectedNodes)
{
foreach (Stroke stroke in selectedNode.Strokes)
{
stroke.DrawingAttributes =
new DrawingAttributes(Color.Red);
}
}
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0