CustomRecognizerNode.GetTextRangeFromNodes 方法

在已识别字符串中查找对应于作为 CustomRecognizerNode 对象后代的 ContextNode 对象集合的文本范围。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink.Analysis(在 Microsoft.Ink.Analysis.dll 中)

语法

声明
Public Sub GetTextRangeFromNodes ( _
    subTree As ContextNodeCollection, _
    <OutAttribute> ByRef start As Integer, _
    <OutAttribute> ByRef length As Integer _
)
用法
Dim instance As CustomRecognizerNode
Dim subTree As ContextNodeCollection
Dim start As Integer
Dim length As Integer

instance.GetTextRangeFromNodes(subTree, _
    start, length)
public void GetTextRangeFromNodes(
    ContextNodeCollection subTree,
    out int start,
    out int length
)
public:
void GetTextRangeFromNodes(
    ContextNodeCollection^ subTree, 
    [OutAttribute] int% start, 
    [OutAttribute] int% length
)
public void GetTextRangeFromNodes(
    ContextNodeCollection subTree,
    /** @attribute OutAttribute */ /** @ref */int start,
    /** @attribute OutAttribute */ /** @ref */int length
)
public function GetTextRangeFromNodes(
    subTree : ContextNodeCollection, 
    start : int, 
    length : int
)

参数

备注

如果 subTree 参数包含非 CustomRecognizerNode 后代的 ContextNode 对象,则会引发 ArgumentException 异常。

如果 subTree 参数包含的 ContextNode 对象不连续,则返回涵盖所有 ContextNode 对象的最小文本范围。

示例

下面的示例使用 CustomRecognizerNode (customRecognizer) 并查找最后一行。然后找到对应此行的文本范围,并将 GetRecognizedString 的值放入 TextBox, selectedResultsTextBox,然后选中对应于最后一行的文本。

Dim lines As ContextNodeCollection = _
    theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Line, customRecognizer)
Dim nLines As Integer = lines.Count

' Create a collection to hold the last line
Dim lastLineCollection As New ContextNodeCollection(theInkAnalyzer)
If nLines > 0 Then
    lastLineCollection.Add(lines(nLines - 1))
End If

' Find corresponding start and length
Dim start As Integer
Dim length As Integer
customRecognizer.GetTextRangeFromNodes(lastLineCollection, start, length)

' Select this in the text box
selectedResultsTextBox.Text = customRecognizer.GetRecognizedString()
selectedResultsTextBox.Select(start, length)
ContextNodeCollection lines = 
    theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Line, customRecognizer);
int nLines = lines.Count;

// Create a collection to hold the last line
ContextNodeCollection lastLineCollection = new ContextNodeCollection(theInkAnalyzer);
if (nLines > 0)
{
    lastLineCollection.Add(lines[nLines - 1]);
}

// Find corresponding start and length
int start, length;
customRecognizer.GetTextRangeFromNodes(lastLineCollection, out start, out length);

// Select this in the text box
selectedResultsTextBox.Text = customRecognizer.GetRecognizedString();
selectedResultsTextBox.Select(start, length);

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

CustomRecognizerNode 类

CustomRecognizerNode 成员

Microsoft.Ink 命名空间