次の方法で共有


WritingRegionNode.GetTextRangeFromNodes メソッド

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 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
)

パラメータ

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

解説

subTree に、WritingRegionNode の子孫ではない ContextNode が含まれている場合、ArgumentException がスローされます。

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

次の例では、WritingRegionNode、writingRegion 内の最後の段落を検索します。次に、この段落に対応するテキスト範囲を検索し、TextBox、selectedResultsTextBox に値 GetRecognizedString を設定して、最後の段落に対応するテキストを選択します。

Dim paragraphs As ContextNodeCollection = theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Paragraph)
Dim lastParagraph As ParagraphNode = Nothing
Dim maxY As Integer = Integer.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(Microsoft.Ink.ContextNodeType.Paragraph);
                ParagraphNode lastParagraph = null;
                int maxY = int.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

参照

参照

WritingRegionNode クラス

WritingRegionNode メンバ

Microsoft.Ink 名前空間