RootNode.GetNodesFromTextRange 方法 (Int32%, Int32%, ContextNodeCollection)

返回后代 ContextNode 对象的集合,这些对象与后代节点集合内已识别字符串中的指定文本范围相关。

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

语法

声明
Public Function GetNodesFromTextRange ( _
    ByRef start As Integer, _
    ByRef length As Integer, _
    subTree As ContextNodeCollection _
) As ContextNodeCollection
用法
Dim instance As RootNode
Dim start As Integer
Dim length As Integer
Dim subTree As ContextNodeCollection
Dim returnValue As ContextNodeCollection

returnValue = instance.GetNodesFromTextRange(start, _
    length, subTree)
public ContextNodeCollection GetNodesFromTextRange(
    ref int start,
    ref int length,
    ContextNodeCollection subTree
)
public:
ContextNodeCollection^ GetNodesFromTextRange(
    int% start, 
    int% length, 
    ContextNodeCollection^ subTree
)
public ContextNodeCollection GetNodesFromTextRange(
    /** @ref */int start,
    /** @ref */int length,
    ContextNodeCollection subTree
)
public function GetNodesFromTextRange(
    start : int, 
    length : int, 
    subTree : ContextNodeCollection
) : ContextNodeCollection

参数

  • start
    类型:System.Int32%
    已识别字符串的 subTree 部分中文本范围的起点。
  • length
    类型:System.Int32%
    已识别字符串中文本范围的长度。

返回值

类型:Microsoft.Ink.ContextNodeCollection
后代 ContextNode 对象的集合,这些对象与后代节点集合内已识别字符串中的指定文本范围相关。

备注

指定的文本范围应相对于 RootNode 的已识别字符串的 subTree 部分,而不相对于整个 RootNode 的已识别字符串。

start 和 length 参数的值可以更改,因此属于引用参数。例如,GetRecognizedString 的返回值是“I am late”,并且传入的值为 start = 6 和 length = 1(对应于字母“a”)。那么 ContextNodeCollection 可能只有一个 ContextNode,即对应于单词“late”的 InkWordNode。在这种情况下,start 的值更改为 5,而 length 的值更改为 4,从而对应于整个单词“late”。

备注

start 参数相对于 subTree 参数中的节点。在上面的示例中,如果传入的 subTree 参数包含“am”和“late”的节点,而不包含“I”的节点,则 start 参数为 3、长度为 4 就对应单词“late”的文本范围。

示例

下面的示例使用 ContextNodeCollection 对象 lastRegionCollection,该对象包含对应于 RootNode (theRootNode) 中最后一个段落的 ContextNode 对象。然后,将除对应于最后一行中所选文本以外的所有 Strokes 标记为黑色,最后一行中的选定文本对应的笔画更改为红色。

' Get the nodes that correspond to this start and length
Dim selectedNodes As ContextNodeCollection = theRootNode.GetNodesFromTextRange(start, length, lastRegionCollection)

' Set all strokes to black
Dim inkStroke As Stroke
For Each inkStroke In theRootNode.Strokes
    inkStroke.DrawingAttributes = New DrawingAttributes(Color.Black)
Next inkStroke
' Set strokes in the collection to red
Dim node As ContextNode
For Each node In selectedNodes
    For Each inkStroke In node.Strokes
        inkStroke.DrawingAttributes = New DrawingAttributes(Color.Red)
    Next inkStroke
Next node
            // Get the nodes that correspond to this start and length
            ContextNodeCollection selectedNodes =
                theRootNode.GetNodesFromTextRange(ref start, ref length, lastRegionCollection);

            // Set all strokes to black
            foreach (Stroke stroke in theRootNode.Strokes)
                stroke.DrawingAttributes = new DrawingAttributes(Color.Black);

            // Set strokes in the collection to red
            foreach (ContextNode node in selectedNodes)
            {
                foreach (Stroke stroke in node.Strokes)
                {
                    stroke.DrawingAttributes = new DrawingAttributes(Color.Red);
                }
            }

平台

Windows Vista

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

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

RootNode 类

RootNode 成员

GetNodesFromTextRange 重载

Microsoft.Ink 命名空间