共用方式為


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

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

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

語法

'宣告
Public Function GetNodesFromTextRange ( _
    ByRef start As Integer, _
    ByRef length As Integer, _
    subTree As ContextNodeCollection _
) As ContextNodeCollection
'用途
Dim instance As WritingRegionNode
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

參數

傳回值

型別:System.Windows.Ink.ContextNodeCollection
子代 ContextNode 物件,這些物件位於已辨識字串中指定的文字範圍內。這些節點限於 subTree 的子代。

備註

start 和 length 參數是可變更的參考值,用以指定與所傳回 ContextNodeCollection 相關聯的整個字串。例如,GetRecognizedString 的傳回值為 "I am late",而且您傳入 start = 6 和 length = 1 兩個值,則參數會對應於 "a" 這個字母。在這種情況下,ContextNodeCollection 可能只有一個 ContextNode,也就是對應於 "late" 一字的 InkWordNode。在此情況下,start 的值會變更為 5,而且 length 的值會變更為 4,表示對應於 "late" 這一整個字。

注意:start 參數與此 WritingRegionNode 之已辨識字串之 subTree 部分中的節點相關,而不是整個 WritingRegionNode 或整個 RootNode 的已辨識字串。在先前的範例中,如果您傳入的 subTree 參數有 "am" 和 "late" 節點但沒有 "I" 節點,則 start 參數值 3 和長度值 4 就表示 "late" 一字的文字範圍。

範例

下列範例會採用 ContextNodeCollection (lastParagraphLevelCollection)。這個集合包含對應於名為 writingRegion 之 WritingRegion 中最後一個段落的一個 ContextNode。接著會將所有的 Strokes 標記為黑色,但會將最後一個段落中的筆劃變更為紅色。

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

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

' Set strokes in the collection to red
For Each node As ContextNode In selectedNodes
    For Each stroke As Stroke In node.Strokes
        stroke.DrawingAttributes.Color = Colors.Red
    Next stroke
Next node
// Get the nodes that correspond to this start and length
ContextNodeCollection selectedNodes =
    writingRegion.GetNodesFromTextRange(ref start, ref length, lastParagraphCollection);

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

// Set strokes in the collection to red
foreach (ContextNode node in selectedNodes)
{
    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 命名空間