RootNode の子孫である ContextNode オブジェクトのコレクションに対応する、認識された文字列内のテキスト範囲を求めます。
名前空間 : 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 RootNode
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
RootNode の子孫である ContextNode オブジェクトのコレクション。
- start
型 : System.Int32%
テキスト範囲の開始位置。
- length
型 : System.Int32%
テキスト範囲の長さ。
解説
subTree に、RootNode の子孫ではない ContextNode オブジェクトが含まれている場合、ArgumentException 例外がスローされます。
subTree パラメータに、連続していない ContextNode オブジェクトが含まれる場合、すべてのContextNode オブジェクトが含まれる最小のテキスト範囲が返されます。
例
次の例では、InkAnalyzer、theInkAnalyzer から RootNode、theRootNode を受け取り、下限が最も小さい手書き領域を選択して最後の WritingRegionNode を探します。次に、手書き領域に対応するテキスト範囲を検索し、TextBox、theResultsTextBox に値 GetRecognizedString を設定して、最後の手書き領域に対応するテキストを選択します。
Dim theRootNode As RootNode = CType(theInkAnalyzer.RootNode, RootNode)
Dim regions As ContextNodeCollection = _
theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.WritingRegion)
Dim lastRegion As WritingRegionNode = Nothing
Dim maxY As Integer = Integer.MinValue
Dim aRegion As WritingRegionNode
For Each aRegion In regions
If aRegion.Location.GetBounds().Bottom > maxY Then
maxY = aRegion.Location.GetBounds().Bottom
lastRegion = aRegion
End If
Next aRegion
If lastRegion Is Nothing Then
Return
End If
' Create a collection to hold this line
Dim lastRegionCollection As New ContextNodeCollection(theInkAnalyzer)
lastRegionCollection.Add(lastRegion)
' Find corresponding start and length
Dim start, length As Integer
theRootNode.GetTextRangeFromNodes(lastRegionCollection, start, length)
' Select this in the text box
theResultsTextBox.Text = theRootNode.GetRecognizedString()
theResultsTextBox.Select(start, length)
RootNode theRootNode = (RootNode)theInkAnalyzer.RootNode;
ContextNodeCollection regions =
theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.WritingRegion);
WritingRegionNode lastRegion = null;
int maxY = int.MinValue;
foreach (WritingRegionNode region in regions)
{
if (region.Location.GetBounds().Bottom > maxY)
{
maxY = region.Location.GetBounds().Bottom;
lastRegion = region;
}
}
if (lastRegion == null)
return;
// Create a collection to hold this line
ContextNodeCollection lastRegionCollection =
new ContextNodeCollection(theInkAnalyzer);
lastRegionCollection.Add(lastRegion);
// Find corresponding start and length
int start, length;
theRootNode.GetTextRangeFromNodes(lastRegionCollection, out start, out length);
// Select this in the text box
theResultsTextBox.Text = theRootNode.GetRecognizedString();
theResultsTextBox.Select(start, length);
プラットフォーム
Windows Vista
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 3.0