ParagraphNode.GetNodesFromTextRange 方法 (Int32%, Int32%)

返回包含后代 ContextNode 对象的 ContextNodeCollection,这些对象与已识别字符串中的指定文本范围相关。

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

语法

声明
Public Function GetNodesFromTextRange ( _
    ByRef start As Integer, _
    ByRef length As Integer _
) As ContextNodeCollection
用法
Dim instance As ParagraphNode
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%
    已识别字符串中文本范围的长度。

返回值

类型:System.Windows.Ink.ContextNodeCollection
包含后代 ContextNode 对象的 ContextNodeCollection,这些对象与已识别字符串中的指定文本范围相关。

备注

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

示例

下面的示例使用一个 TextBox (selectedResultsTextBox),其 Text 属性事先设置为由 ParagraphNode (paragraph) 的 GetRecognizedString 返回的值。用户已经选中了 TextBox 中的部分文本。该示例代码使用所选内容并标记与所选内容对应的 Strokes

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

' Return if no text is selected.
If selLength = 0 Then
    Return
End If

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

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

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

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

// Return if no text is selected.
if (selLength == 0)
    return;

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


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

// First, set all strokes to black
foreach (Stroke stroke in paragraph.Strokes)
    stroke.DrawingAttributes.Color = Colors.Black;

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

平台

Windows Vista

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

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

ParagraphNode 类

ParagraphNode 成员

GetNodesFromTextRange 重载

System.Windows.Ink 命名空间