WritingRegionNode.GetTextRangeFromNodes 方法
若指定 ContextNode 物件的集合,這個方法便會在已辨識字串中尋找對應的文字範圍。
命名空間: System.Windows.Ink
組件: IAWinFX (在 IAWinFX.dll 中)
語法
'宣告
Public Sub GetTextRangeFromNodes ( _
subTree As ContextNodeCollection, _
<OutAttribute> ByRef start As Integer, _
<OutAttribute> ByRef length As Integer _
)
'用途
Dim instance As WritingRegionNode
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
型別:System.Windows.Ink.ContextNodeCollection
ContextNode 物件集合,這些物件都是 WritingRegionNode 的子代。
- start
型別:System.Int32%
文字範圍的起點。
- length
型別:System.Int32%
文字範圍的長度。
備註
如果 subTree 包含不是 InkWritingNode 之子代的 ContextNode,會擲回 ArgumentException。
如果 subTree 包含不連續的 ContextNode 物件,則會傳回涵蓋所有 ContextNode 物件的最小文字範圍。
範例
下列範例會在名為 writingRegion 的 WritingRegionNode 中尋找最後一個段落。接著會尋找對應於這個段落的文字範圍,將 GetRecognizedString 的值放入名為 selectedResultsTextBox 的 TextBox 中,然後選取對應於最後一個段落的文字。
Dim paragraphs As ContextNodeCollection = theInkAnalyzer.FindNodesOfType(ContextNodeType.Paragraph)
Dim lastParagraph As ParagraphNode = Nothing
Dim maxY As Double = Double.MinValue
Dim paragraph As ParagraphNode
For Each paragraph In paragraphs
If paragraph.Location.GetBounds().Bottom > maxY Then
maxY = paragraph.Location.GetBounds().Bottom
lastParagraph = paragraph
End If
Next paragraph
If lastParagraph Is Nothing Then
Return
End If
' Create a collection to hold this line
Dim lastParagraphCollection As New ContextNodeCollection(theInkAnalyzer)
lastParagraphCollection.Add(lastParagraph)
' Find corresponding start and length
Dim start, length As Integer
writingRegion.GetTextRangeFromNodes(lastParagraphCollection, start, length)
' Select this in the text box
selectedResultsTextBox.Text = writingRegion.GetRecognizedString()
selectedResultsTextBox.Select(start, length)
ContextNodeCollection paragraphs =
theInkAnalyzer.FindNodesOfType(ContextNodeType.Paragraph);
ParagraphNode lastParagraph = null;
double maxY = double.MinValue;
foreach (ParagraphNode paragraph in paragraphs)
{
if (paragraph.Location.GetBounds().Bottom > maxY)
{
maxY = paragraph.Location.GetBounds().Bottom;
lastParagraph = paragraph;
}
}
if (lastParagraph == null)
return;
// Create a collection to hold this line
ContextNodeCollection lastParagraphCollection = new ContextNodeCollection(theInkAnalyzer);
lastParagraphCollection.Add(lastParagraph);
// Find corresponding start and length
int start, length;
writingRegion.GetTextRangeFromNodes(lastParagraphCollection, out start, out length);
// Select this in the text box
selectedResultsTextBox.Text = writingRegion.GetRecognizedString();
selectedResultsTextBox.Select(start, length);
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0