次の方法で共有


LineNode.GetNodesFromTextRange メソッド (Int32%, Int32%)

認識された文字列の中の指定されたテキスト範囲に対応する子孫 ContextNode オブジェクトのコレクションを返します。

名前空間 :  Microsoft.Ink
アセンブリ :  Microsoft.Ink.Analysis (Microsoft.Ink.Analysis.dll 内)

構文

'宣言
Public Function GetNodesFromTextRange ( _
    ByRef start As Integer, _
    ByRef length As Integer _
) As ContextNodeCollection
'使用
Dim instance As LineNode
Dim start As Integer
Dim length As Integer
Dim returnValue As ContextNodeCollection

returnValue = instance.GetNodesFromTextRange(start, _
    length)
public ContextNodeCollection GetNodesFromTextRange(
    ref int start,
    ref int length
)
public:
ContextNodeCollection^ GetNodesFromTextRange(
    int% start, 
    int% length
)
public ContextNodeCollection GetNodesFromTextRange(
    /** @ref */int start,
    /** @ref */int length
)
public function GetNodesFromTextRange(
    start : int, 
    length : int
) : ContextNodeCollection

パラメータ

  • start
    型 : System.Int32%
    認識された文字列の中のテキスト範囲の開始位置。
  • length
    型 : System.Int32%
    認識された文字列の中のテキスト範囲の長さ。

戻り値

型 : Microsoft.Ink.ContextNodeCollection
認識された文字列の中の指定されたテキスト範囲に対応する子孫 ContextNode オブジェクトのコレクション。

解説

テキスト範囲は、RootNode 全体から成る認識された文字列ではなく、この LineNode から成る認識された文字列を基準として指定します。

start パラメータおよび length パラメータは、値が変更される可能性があるので、参照として渡されます。たとえば、GetRecognizedString の戻り値が "I am late" で、文字 "a" に対応する値 start = 6 および length = 1 を渡した場合、ContextNodeCollectionContextNode ("late" という語に対応する InkWordNode) は 1 つのみとなる可能性が高くなります。この場合、start の値は 5 に、length の値は 4 に変更されます ("late" という語全体に対応)。

次の例では、TextBox、selectedResultsTextBox を使用します。この TextBox.Text プロパティは、既に LineNode、line の GetRecognizedString によって返された値に設定されています。ユーザーによって、TextBox 内のテキストの一部が選択されています。コード例では、この選択内容に対応する Strokes にマークを付けます。

' Find out what's been selected in the text box
Dim start As Integer = selectedResultsTextBox.SelectionStart
Dim length As Integer = selectedResultsTextBox.SelectionLength

' Return if no text is selected.
If start = 0 Then
    Return
End If

' Get the nodes that correspond to that range
Dim selectedNodes As ContextNodeCollection
selectedNodes = line.GetNodesFromTextRange(start, length)

' Use the new start and length value to update the
' selection in the TextBox
selectedResultsTextBox.SelectionStart = start
selectedResultsTextBox.SelectionLength = length

' Color the strokes red if part of the selected words.
' Otherwise, color them black.
For Each node As ContextNode In line.SubNodes
    Dim inkStroke As Stroke
    For Each inkStroke In node.Strokes
        If selectedNodes.Contains(node) Then
            inkStroke.DrawingAttributes = New DrawingAttributes(Color.Red)
        Else
            inkStroke.DrawingAttributes = New DrawingAttributes(Color.Black)
        End If
    Next inkStroke
Next node
                    // Find out what's been selected in the text box
                    int start = selectedResultsTextBox.SelectionStart;
                    int length = selectedResultsTextBox.SelectionLength;

                    // Return if no text is selected.
                    if (length == 0)
                        return;

                    // Get the nodes that correspond to that range
                    ContextNodeCollection selectedNodes =
                        line.GetNodesFromTextRange(ref start, ref length);

                    // Use the new start and length value to update the
                    // selection in the TextBox
                    selectedResultsTextBox.SelectionStart = start;
                    selectedResultsTextBox.SelectionLength = length;

                    // Color the strokes red if part of the selected words.
                    // Otherwise, color them black.
                    foreach (ContextNode node in line.SubNodes)
                    {
                        foreach (Stroke stroke in node.Strokes)
                        {
                            if (selectedNodes.Contains(node))
                            {
                                stroke.DrawingAttributes =
                                    new DrawingAttributes(Color.Red);
                            }
                            else
                            {
                                stroke.DrawingAttributes =
                                    new DrawingAttributes(Color.Black);
                            }
                        }
                    }

プラットフォーム

Windows Vista

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 3.0

参照

参照

LineNode クラス

LineNode メンバ

GetNodesFromTextRange オーバーロード

Microsoft.Ink 名前空間