共用方式為


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

傳回包含 ContextNode 物件的 ContextNodeCollection,這些物件都屬於指定之內容節點的指定文字範圍。

命名空間:  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",而且您呼叫這個方法時將 start 參數的值設定為 6,以及將 length 參數的值設定為 1 (表示對應至 "late" 中的字母 "a"),則方法會傳回包含單一 ContextNodeInkWordNodeTextWordNode 的集合。在這個範例中,這個方法也會將 start 的值修改為 5 並將 length 的值修改為 4 (表示對應於 "late" 一字)。

ms590335.alert_note(zh-tw,VS.90).gif注意事項:

start 參數相對於 nodesToSearch 參數的已辨識字串。

範例

這個範例會採用名為 theResultsTextBox 的 TextBox,它的 Text 屬性已設定為 ContextNodeCollection (名為 nodesToSearch) 中節點的合併辨識字串。nodesToSearch 集合包含來自 InkAnalyzer (名為 theInkAnalyzer) 的內容節點。這個範例程式碼會取得文字方塊選取範圍,並且將對應至該選取範圍的 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 命名空間