共用方式為


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

從已辨識字串中指定的文字範圍傳回子代 ContextNode 物件集合。

命名空間:  System.Windows.Ink
組件:  IAWinFX (在 IAWinFX.dll 中)

語法

'宣告
Public Function GetNodesFromTextRange ( _
    ByRef start As Integer, _
    ByRef length As Integer _
) As ContextNodeCollection
'用途
Dim instance As WritingRegionNode
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 物件集合,這些物件都與已辨識字串中指定的文字範圍相關聯。

備註

指定的文字範圍應該與這個 WritingRegionNode 相關,而不是整個 RootNode 的已辨識字串。

範例

下列程式碼範例會使用 WritingRegionNode 方法,標示對應於選定文字的筆劃。範例程式碼會假設名為 theResultsTextBox 的 TextBoxText 屬性設定為 GetRecognizedString 方法所傳回的值。這個範例也會假設使用者已從 theResultsTextBox 中選取一些文字,而且有名為 theInkAnalyzer 的 InkAnalyzer

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

' Return if no text is selected.
If selectionLength = 0 Then
    Return
End If 
' Get the nodes that correspond to that range
Dim selectedRegionSubNodes As ContextNodeCollection = writingRegion.GetNodesFromTextRange(selectionStart, selectionLength)


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

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

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

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

// Get the nodes that correspond to that range
ContextNodeCollection selectedRegionSubNodes =
        writingRegion.GetNodesFromTextRange(ref selectionStart, ref selectionLength);


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

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

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求

版本資訊

.NET Framework

支援版本:3.0

請參閱

參考

WritingRegionNode 類別

WritingRegionNode 成員

GetNodesFromTextRange 多載

System.Windows.Ink 命名空間