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

返回一个 ContextNodeCollection,其中包含与指定上下文节点的指定文本范围有关的 ContextNode 对象。

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

语法

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

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

参数

返回值

类型:System.Windows.Ink.ContextNodeCollection
与指定上下文节点的指定文本范围有关的 ContextNode 对象。

备注

指定的文本范围必须相对于 InkAnalyzer 中已识别字符串的 nodesToSearch 部分。

此方法通过将文本范围扩展到最近的单词边界来修改 start 和 length 参数的值。例如,如果已识别字符串为“I am late”,并通过将参数值 6 和 1 分别用于 start 和 length(这对应于“late”中的字母“a”)来调用此方法,则此方法返回一个只包含单个 ContextNode(即 InkWordNodeTextWordNode)的集合。对于此示例,此方法还将 start 和 length 的值分别修改为 5 和 4(这对应于单词“late”)。

备注

start 参数相对于 nodesToSearch 参数的已识别字符串。

示例

此示例获取名为 theResultsTextBox 的 TextBox,其 Text 属性已设置为 ContextNodeCollection(名为 nodesToSearch)中节点的合并的已识别字符串。nodesToSearch 集合包含来自名为 theInkAnalyzer 的 InkAnalyzer 的上下文节点该示例代码获取文本框选择内容并标记与所选内容对应的 Strokes

' Find out what's been selected in the text box
Dim selStart As Integer = theResultsTextBox.SelectionStart
Dim selLength As Integer = theResultsTextBox.SelectionLength

' Get the nodes that correspond to that range
Dim selectedSubNodes As ContextNodeCollection = _
    Me.theInkAnalyzer.GetNodesFromTextRange(selStart, selLength, nodesToSearch)

' Use the new start and length value to update the
' selection in the TextBox
theResultsTextBox.SelectionStart = selStart
theResultsTextBox.SelectionLength = selLength

' First, set all strokes to black
For Each theStroke As Stroke In Me.theInkAnalyzer.RootNode.Strokes
    theStroke.DrawingAttributes.Color = Colors.Black
Next theStroke

' Next, set all selected sub nodes to red
Dim theContextNode As ContextNode
For Each theContextNode In  selectedSubNodes
    For Each theStroke As Stroke In theContextNode.Strokes
        theStroke.DrawingAttributes.Color = Colors.Red
    Next theStroke
Next theContextNode
// Find out what's been selected in the text box
int selStart = theResultsTextBox.SelectionStart;
int selLength = theResultsTextBox.SelectionLength;

// Get the nodes that correspond to that range
ContextNodeCollection selectedSubNodes =
    this.theInkAnalyzer.GetNodesFromTextRange(
        ref selStart, ref selLength, nodesToSearch);

// Use the new start and length value to update the
// selection in the TextBox
theResultsTextBox.SelectionStart = selStart;
theResultsTextBox.SelectionLength = selLength;

// First, set all strokes to black
foreach (Stroke theStroke
    in this.theInkAnalyzer.RootNode.Strokes)
{
    theStroke.DrawingAttributes.Color = Colors.Black;
}

// Next, set all selected sub nodes to red
foreach (ContextNode theContextNode in selectedSubNodes)
{
    foreach (Stroke theStroke in theContextNode.Strokes)
    {
        theStroke.DrawingAttributes.Color = Colors.Red;
    }
}

平台

Windows Vista

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

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

InkAnalyzer 类

InkAnalyzer 成员

GetNodesFromTextRange 重载

System.Windows.Ink 命名空间