RootNode.GetTextRangeFromNodes 方法

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

命名空间:  System.Windows.Ink
程序集:  IAWinFX(在 IAWinFX.dll 中)

语法

声明
Public Sub GetTextRangeFromNodes ( _
    subTree As ContextNodeCollection, _
    <OutAttribute> ByRef start As Integer, _
    <OutAttribute> ByRef length As Integer _
)
用法
Dim instance As RootNode
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 包含的某个 ContextNode 对象不是 RootNode 的后代,则引发 ArgumentException 异常。

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

示例

下面的示例使用来自 InkAnalyzer(名为 theInkAnalyzer)的 RootNode (theRootNode),并通过选择具有最低边界的书写区域查找最后一个 WritingRegionNode。然后,查找对应于当前书写区域的文本范围;将 GetRecognizedString 的值放入一个名为 theResultsTextBox 的 TextBox 中;然后选择对应于最后一个书写区域的文本。

Dim theRootNode As RootNode = CType(theInkAnalyzer.RootNode, RootNode)
Dim regions As ContextNodeCollection = theInkAnalyzer.FindNodesOfType(ContextNodeType.WritingRegion)
Dim lastRegion As WritingRegionNode = Nothing
Dim maxY As Double = Double.MinValue
Dim region As WritingRegionNode
For Each region In  regions
    If [region].Location.GetBounds().Bottom > maxY Then
        maxY = [region].Location.GetBounds().Bottom
        lastRegion = [region]
    End If
Next region

If lastRegion Is Nothing Then
    Return
End If 
' Create a collection to hold this line
Dim lastRegionCollection As New ContextNodeCollection(theInkAnalyzer)
lastRegionCollection.Add(lastRegion)

' Find corresponding start and length
Dim start, length As Integer
theRootNode.GetTextRangeFromNodes(lastRegionCollection, start, length)

' Select this in the text box
theResultsTextBox.Text = theRootNode.GetRecognizedString()
theResultsTextBox.Select(start, length)
RootNode theRootNode = (RootNode)theInkAnalyzer.RootNode;
ContextNodeCollection regions =
    theInkAnalyzer.FindNodesOfType(ContextNodeType.WritingRegion);
WritingRegionNode lastRegion = null;
double maxY = double.MinValue;
foreach (WritingRegionNode region in regions)
{
    if (region.Location.GetBounds().Bottom > maxY)
    {
        maxY = region.Location.GetBounds().Bottom;
        lastRegion = region;
    }
}

if (lastRegion == null)
    return;

// Create a collection to hold this line
ContextNodeCollection lastRegionCollection =
    new ContextNodeCollection(theInkAnalyzer);
lastRegionCollection.Add(lastRegion);

// Find corresponding start and length
int start, length;
theRootNode.GetTextRangeFromNodes(lastRegionCollection, out start, out length);

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

平台

Windows Vista

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

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

RootNode 类

RootNode 成员

System.Windows.Ink 命名空间