針對子代節點集合,傳回子代 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 RootNode
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 物件集合,這些物件都對應於已辨識字串中指定的文字範圍。
備註
start 和 length 參數是可變更的參考值,用以指定與所傳回 ContextNodeCollection 相關聯的整個字串。例如,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" 一字的文字範圍。 |
範例
下列程式碼範例會使用 GetNodesFromTextRange 方法,標示對應於選定文字的筆劃。範例程式碼會假設名為 theResultsTextBox 的 TextBox 之 Text 屬性設定為 GetRecognizedString 方法所傳回的值。這個範例也會假設使用者已在 theResultsTextBox 中選取一些文字,而且有名為 theInkAnalyzer 的 InkAnalyzer。
' Get the nodes that correspond to this start and length
Dim selectedNodes As ContextNodeCollection = _
theRootNode.GetNodesFromTextRange(start, length, lastRegionCollection)
' Set all strokes to black
For Each stroke As Stroke In theRootNode.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
End Sub 'showLastWritingRegion_Click
// Get the nodes that correspond to this start and length
ContextNodeCollection selectedNodes =
theRootNode.GetNodesFromTextRange(ref start, ref length, lastRegionCollection);
// Set all strokes to black
foreach (Stroke stroke in theRootNode.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
注意事項: