次の方法で共有


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

認識された文字列の指定したテキスト範囲に関連する子孫 ContextNode オブジェクトを格納している ContextNodeCollection を返します。

名前空間 :  System.Windows.Ink
アセンブリ :  IAWinFX (IAWinFX.dll 内)

構文

'宣言
Public Function GetNodesFromTextRange ( _
    ByRef start As Integer, _
    ByRef length As Integer _
) As ContextNodeCollection
'使用
Dim instance As ParagraphNode
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%
    認識された文字列のテキスト範囲の長さ。

戻り値

型 : System.Windows.Ink.ContextNodeCollection
認識された文字列の指定したテキスト範囲に関連する子孫 ContextNode オブジェクトを格納している ContextNodeCollection

解説

指定したテキスト範囲は、RootNode 全体の認識された文字列ではなく、現在の ParagraphNode の認識された文字列に関連しています。

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

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

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

' Get the nodes that correspond to that range
Dim selectedSubNodes As ContextNodeCollection = _
    paragraph.GetNodesFromTextRange(selStart, selLength)

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

' First, set all strokes to black
For Each Stroke As Stroke In paragraph.Strokes
    Stroke.DrawingAttributes.Color = Colors.Black
Next Stroke

' Next, set all selected sub nodes to red
For Each node As ContextNode In selectedSubNodes
    Dim stroke As Stroke
    For Each stroke In node.Strokes
        stroke.DrawingAttributes.Color = Colors.Red
    Next stroke
Next node
// Find out what's been selected in the text box
int selStart = selectedResultsTextBox.SelectionStart;
int selLength = selectedResultsTextBox.SelectionLength;

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

// Get the nodes that correspond to that range
ContextNodeCollection selectedSubNodes =
        paragraph.GetNodesFromTextRange(ref selStart, ref selLength);


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

// First, set all strokes to black
foreach (Stroke stroke in paragraph.Strokes)
    stroke.DrawingAttributes.Color = Colors.Black;

// Next, set all selected sub nodes to red
foreach (ContextNode node in selectedSubNodes)
{
    foreach (Stroke stroke in node.Strokes)
    {
        stroke.DrawingAttributes.Color = Colors.Red;
    }
}

プラットフォーム

Windows Vista

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

バージョン情報

.NET Framework

サポート対象 : 3.0

参照

参照

ParagraphNode クラス

ParagraphNode メンバ

GetNodesFromTextRange オーバーロード

System.Windows.Ink 名前空間