次の方法で共有


RootNode.GetTextRangeFromNodes メソッド

RootNode の子孫である 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 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
)

パラメータ

  • start
    型 : System.Int32%
    テキスト範囲の開始点。

解説

subTree に、RootNode の子孫ではない ContextNode オブジェクトが含まれている場合、ArgumentException 例外がスローされます。

subTree パラメータに、連続していない ContextNode オブジェクトが含まれる場合、すべての ContextNode オブジェクトが含まれる最小のテキスト範囲が返されます。

次の例では、theInkAnalyzer という名前の InkAnalyzer から RootNode、theRootNode を受け取り、下限が最も小さい手書き領域を選択して最後の WritingRegionNode を探します。次に、現在の手書き領域に対応するテキスト範囲を検索し、theResultsTextBox という名前の TextBox に値 GetRecognizedString を設定して、最後の手書き領域に対応するテキストを選択します。

Dim theRootNode As RootNode = CType(theInkAnalyzer.RootNode, RootNode)
Dim regions As ContextNodeCollection = theInkAnalyzer.FindNodesOfType(ContextNodeType.WritingRegion)
Dim lastRegion As WritingRegionNode = Nothing
Dim maxY As Double = Double.MinValue
Dim region As WritingRegionNode
For Each region In  regions
    If [region].Location.GetBounds().Bottom > maxY Then
        maxY = [region].Location.GetBounds().Bottom
        lastRegion = [region]
    End If
Next region

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(ContextNodeType.WritingRegion);
WritingRegionNode lastRegion = null;
double maxY = double.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

参照

参照

RootNode クラス

RootNode メンバ

System.Windows.Ink 名前空間