傳回 ContextNodeCollection,其中包含屬於指定之文字範圍的 ContextNode 物件。
命名空間: System.Windows.Ink
組件: IAWinFX (在 IAWinFX.dll 中)
語法
'宣告
Public Function GetNodesFromTextRange ( _
ByRef start As Integer, _
ByRef length As Integer _
) As ContextNodeCollection
'用途
Dim instance As InkAnalyzer
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 物件集合,這些物件都與指定的文字範圍相關聯。
備註
指定的文字範圍應該與整個 InkAnalyzer 的已辨識字串相關聯。
這個方法會將文字範圍擴充至最接近的文字界限,修改 start 和 length 參數的值。例如,已辨識的字串為 "I am late",您便可以設定 start = 6 和 length = 1 兩個參數值 (表示對應於 "late" 的 "a" 這個字母),並呼叫這個方法。方法會傳回由單一 ContextNode (即 InkWordNode 或 TextWordNode) 所組成的集合。在這個範例中,這個方法也會將 start 的值修改為 5 並將 length 的值修改為 4 (表示對應於 "late" 一字)。
範例
這個範例會重設 TextBox (名為 theResultsTextBox) 的 Text 屬性,將它從 InkAnalyzer (theInkAnalyzer) 的 GetRecognizedString() 所傳回的值設定為文字方塊選取範圍中,標示對應於文字方塊選取範圍之 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)
' 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
For Each theContextNode As ContextNode 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);
// 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