傳回與已辨識字串中指定之文字範圍相關聯的子代 ContextNode 物件集合。
命名空間: Microsoft.Ink
組件: Microsoft.Ink.Analysis (在 Microsoft.Ink.Analysis.dll 中)
語法
'宣告
Public Function GetNodesFromTextRange ( _
ByRef start As Integer, _
ByRef length As Integer _
) As ContextNodeCollection
'用途
Dim instance As ParagraphNode
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%
已辨識字串中文字範圍的長度。
傳回值
型別:Microsoft.Ink.ContextNodeCollection
傳回與已辨識字串中指定之文字範圍相關聯的子代 ContextNode 物件集合。
備註
指定的文字範圍應該相對於這個 ParagraphNode 的已辨識字串,而不是整個 RootNode 的已辨識字串。
範例
下列範例會取得 TextBox, selectedResultsTextBox,它的 Text 屬性先前已設定為 ParagraphNode, paragraph 的 GetRecognizedString 所傳回的值。使用者已選取 TextBox (英文) 中的部分文字。這個範例程式碼會採用該選取範圍,並且將與其對應的 Strokes 加上標記。
' Find out what's been selected in the text box
Dim selStart As Integer = selectedResultsTextBox.SelectionStart
Dim selLength As Integer = selectedResultsTextBox.SelectionLength
' Return if no text is selected.
If selLength = 0 Then
Return
End If
' Get the nodes that correspond to that range
Dim selectedSubNodes As ContextNodeCollection = paragraph.GetNodesFromTextRange(selStart, selLength)
' Use the new start and length value to update the
' selection in the TextBox
selectedResultsTextBox.SelectionStart = selStart
selectedResultsTextBox.SelectionLength = selLength
' First, set all strokes to black
Dim inkStroke As Stroke
For Each inkStroke In paragraph.Strokes
inkStroke.DrawingAttributes = New DrawingAttributes(Color.Black)
Next inkStroke
' Next, set all selected sub nodes to red
Dim node As ContextNode
For Each node In selectedSubNodes
For Each inkStroke In node.Strokes
inkStroke.DrawingAttributes = New DrawingAttributes(Color.Red)
Next inkStroke
Next node
// Find out what's been selected in the text box
int selStart = selectedResultsTextBox.SelectionStart;
int selLength = selectedResultsTextBox.SelectionLength;
// Return if no text is selected.
if (selLength == 0)
return;
// Get the nodes that correspond to that range
ContextNodeCollection selectedSubNodes =
paragraph.GetNodesFromTextRange(ref selStart, ref selLength);
// Use the new start and length value to update the
// selection in the TextBox
selectedResultsTextBox.SelectionStart = selStart;
selectedResultsTextBox.SelectionLength = selLength;
// First, set all strokes to black
foreach (Stroke stroke in paragraph.Strokes)
stroke.DrawingAttributes =
new DrawingAttributes(Color.Black);
// Next, set all selected sub nodes to red
foreach (ContextNode node in selectedSubNodes)
{
foreach (Stroke stroke in node.Strokes)
{
stroke.DrawingAttributes =
new DrawingAttributes(Color.Red);
}
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0