次の方法で共有


InkAnalyzer.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 InkAnalyzer
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

パラメータ

戻り値

型 : System.Windows.Ink.ContextNodeCollection
指定したテキスト範囲に関連する ContextNode オブジェクトのコレクション。

解説

指定されたテキスト範囲は、InkAnalyzer 全体の認識された文字列に関連する必要があります。

このメソッドは、テキスト範囲を最も近い単語境界に拡張することにより、start パラメータおよび length パラメータの値を変更します。たとえば、認識された文字列が "I am late" の場合に、start にパラメータ値 6 を使用し、length にパラメータ値 1 を使用して ("late" の文字 "a" に対応する) このメソッドを呼び出します。メソッドは、単一の ContextNode、つまり InkWordNode または TextWordNode によって構成されるコレクションを返します。この例では、このメソッドはさらに start の値を 5 に変更し、length の値を 4 に変更します (単語 "late" に対応する)。

この例では、theResultsTextBox という名前の TextBoxText プロパティを、InkAnalyzer (theInkAnalyzer) の GetRecognizedString() によって返された値から、テキスト ボックスの選択内容に対応する Strokes をマークする、テキスト ボックスで選択されている新しい値にリセットします。

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

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

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

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

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

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

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

// First, set all strokes to black
foreach (Stroke theStroke
    in this.theInkAnalyzer.RootNode.Strokes)
{
    theStroke.DrawingAttributes.Color = Colors.Black;
}

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

プラットフォーム

Windows Vista

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

バージョン情報

.NET Framework

サポート対象 : 3.0

参照

参照

InkAnalyzer クラス

InkAnalyzer メンバ

GetNodesFromTextRange オーバーロード

System.Windows.Ink 名前空間