CustomRecognizerNode.GetTextRangeFromNodes 方法
在已辨識的字串中尋找對應於 ContextNode 物件集合的文字範圍,這些物件都是 CustomRecognizerNode 物件的子代。
命名空間: Microsoft.Ink
組件: Microsoft.Ink.Analysis (在 Microsoft.Ink.Analysis.dll 中)
語法
'宣告
Public Sub GetTextRangeFromNodes ( _
subTree As ContextNodeCollection, _
<OutAttribute> ByRef start As Integer, _
<OutAttribute> ByRef length As Integer _
)
'用途
Dim instance As CustomRecognizerNode
Dim subTree As ContextNodeCollection
Dim start As Integer
Dim length As Integer
instance.GetTextRangeFromNodes(subTree, _
start, length)
public void GetTextRangeFromNodes(
ContextNodeCollection subTree,
out int start,
out int length
)
public:
void GetTextRangeFromNodes(
ContextNodeCollection^ subTree,
[OutAttribute] int% start,
[OutAttribute] int% length
)
public void GetTextRangeFromNodes(
ContextNodeCollection subTree,
/** @attribute OutAttribute */ /** @ref */int start,
/** @attribute OutAttribute */ /** @ref */int length
)
public function GetTextRangeFromNodes(
subTree : ContextNodeCollection,
start : int,
length : int
)
參數
- subTree
型別:Microsoft.Ink.ContextNodeCollection
ContextNode 物件集合,這些物件都是 CustomRecognizerNode 的子代。
- start
型別:System.Int32%
文字範圍的起點。
- length
型別:System.Int32%
文字範圍的長度。
備註
如果 subTree 參數包含不屬於 CustomRecognizerNode 之子代的 ContextNode 物件,則會擲回 ArgumentException (英文) 例外狀況。
如果 subTree 參數包含不連續的 ContextNode 物件,則會傳回涵蓋所有 ContextNode 物件的最小文字範圍。
範例
下列範例會採用 CustomRecognizerNode (customRecognizer) 並尋找最後一行。接著會尋找對應於該行的文字範圍,並將 GetRecognizedString 的值放入 TextBox (英文) (selectedResultsTextBox) 中,然後選取對應於最後一行的文字。
Dim lines As ContextNodeCollection = _
theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Line, customRecognizer)
Dim nLines As Integer = lines.Count
' Create a collection to hold the last line
Dim lastLineCollection As New ContextNodeCollection(theInkAnalyzer)
If nLines > 0 Then
lastLineCollection.Add(lines(nLines - 1))
End If
' Find corresponding start and length
Dim start As Integer
Dim length As Integer
customRecognizer.GetTextRangeFromNodes(lastLineCollection, start, length)
' Select this in the text box
selectedResultsTextBox.Text = customRecognizer.GetRecognizedString()
selectedResultsTextBox.Select(start, length)
ContextNodeCollection lines =
theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Line, customRecognizer);
int nLines = lines.Count;
// Create a collection to hold the last line
ContextNodeCollection lastLineCollection = new ContextNodeCollection(theInkAnalyzer);
if (nLines > 0)
{
lastLineCollection.Add(lines[nLines - 1]);
}
// Find corresponding start and length
int start, length;
customRecognizer.GetTextRangeFromNodes(lastLineCollection, out start, out length);
// Select this in the text box
selectedResultsTextBox.Text = customRecognizer.GetRecognizedString();
selectedResultsTextBox.Select(start, length);
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0