CustomRecognizerNode.GetNodesFromTextRange 方法 (Int32%, Int32%)
傳回子代 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 CustomRecognizerNode
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 物件集合,這些物件都與已辨識字串中指定的文字範圍相關聯。
備註
指定的文字範圍應該相對於這個 CustomRecognizerNode 的已辨識字串,而不是整個 RootNode 的已辨識字串。
範例
下列範例會使用 TextBox (英文) (selectedResultsTextBox)。先前 Text (英文) 屬性已設定為 CustomRecognizerNode 物件 customRecognizer 之 GetRecognizedString 所傳回的值。使用者已選取 TextBox (英文) 中的部分文字。如果 InkRecognitionConfidence 等級為 Strong,則對應於該選取範圍的 Strokes 會以紅色反白顯示。
' Find out what's been selected in the text box
Dim start As Integer = selectedResultsTextBox.SelectionStart
Dim length As Integer = selectedResultsTextBox.SelectionLength
' Only highlight if strong recognition
If customRecognizer.InkRecognitionConfidence = Microsoft.Ink.InkRecognitionConfidence.Strong Then
Dim selectedNodes As ContextNodeCollection = _
customRecognizer.GetNodesFromTextRange(start, length)
' Use the new start and length value to update the
' selection in the TextBox
selectedResultsTextBox.SelectionStart = start
selectedResultsTextBox.SelectionLength = length
' Color the strokes red if part of the selected words.
' Otherwise, color them black.
Dim theStroke As Stroke
For Each theStroke In customRecognizer.Strokes
theStroke.DrawingAttributes = _
New DrawingAttributes(Color.Black)
Next theStroke
Dim selectedNode As ContextNode
For Each selectedNode In selectedNodes
For Each theStroke In selectedNode.Strokes
theStroke.DrawingAttributes = _
New DrawingAttributes(Color.Red)
Next theStroke
Next selectedNode
End If
// Find out what's been selected in the text box
int start = selectedResultsTextBox.SelectionStart;
int length = selectedResultsTextBox.SelectionLength;
// Return if no text is selected.
if (length == 0)
return;
// Only highlight if strong recognition
if (customRecognizer.InkRecognitionConfidence == Microsoft.Ink.InkRecognitionConfidence.Strong)
{
ContextNodeCollection selectedNodes =
customRecognizer.GetNodesFromTextRange(ref start, ref length);
// Use the new start and length value to update the
// selection in the TextBox
selectedResultsTextBox.SelectionStart = start;
selectedResultsTextBox.SelectionLength = length;
// Color the strokes red if part of the selected words.
// Otherwise, color them black.
foreach (Stroke stroke in customRecognizer.Strokes)
{
stroke.DrawingAttributes =
new DrawingAttributes(Color.Black);
}
foreach (ContextNode selectedNode in selectedNodes)
{
foreach (Stroke stroke in selectedNode.Strokes)
{
stroke.DrawingAttributes =
new DrawingAttributes(Color.Red);
}
}
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0