LineNode.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 LineNode
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
參數
- start
型別:System.Int32%
- length
型別:System.Int32%
- subTree
型別:System.Windows.Ink.ContextNodeCollection
要縮小搜尋範圍的子代 ContextNode 物件。
傳回值
型別:System.Windows.Ink.ContextNodeCollection
子代節點集合中的子代 ContextNode 物件集合,這些物件都與已辨識字串中指定的文字範圍相關聯。
備註
指定的文字範圍應該與目前 LineNode 之已辨識字串的 subTree 部分相關,而不是完整 LineNode 或完整 RootNode 之已辨識字串的一部分。
start 和 length 參數都是參考,因為它們的值可以變更。例如,GetRecognizedString 的傳回值為 "I am late",而且您傳入 start = 6 和 length = 1 兩個值 (表示對應於 "a" 這個字母),則 ContextNodeCollection 可能只有一個 ContextNode,這是對應於 "late" 一字的 InkWordNode。在此情況下,start 的值會變更為 5,而且 length 的值會變更為 4,表示對應於 "late" 這一整個字。
![]() |
---|
start 參數是相對於 subTree 參數中的節點。在前述範例中,如果您傳入的 subTree 參數有 "am" 和 "late" 節點,但沒有 "I" 節點,則 start 參數值 3 和 length 參數值 4 就是 "late" 一字的文字範圍。 |
範例
下列範例會採用 ContextNodeCollection 物件 lastWordCollection,其中包含對應於 LineNode (line) 中最後一字的一個 ContextNode。接著會將所有 Strokes 標示為黑色,但會將對應於最後一行選定文字的那些筆劃變更為紅色。
' Get the nodes that correspond to this start and length
Dim selectedNodes As ContextNodeCollection = line.GetNodesFromTextRange(start, length, lastWordCollection)
' Set all strokes to black
For Each Stroke As Stroke In line.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 =
line.GetNodesFromTextRange(ref start, ref length, lastWordCollection);
// Set all strokes to black
foreach (Stroke stroke in line.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