認識された文字列の指定したテキスト範囲に関連する子孫 ContextNode オブジェクトのコレクションを返します。
名前空間 : System.Windows.Ink
アセンブリ : IAWinFX (IAWinFX.dll 内)
構文
'宣言
Public Function GetNodesFromTextRange ( _
ByRef start As Integer, _
ByRef length As Integer _
) As ContextNodeCollection
'使用
Dim instance As RootNode
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 オブジェクトのコレクション。
解説
start パラメータと length パラメータは、返された ContextNodeCollection と関連付けられた文字列全体を指定するように変更できる参照値です。たとえば、GetRecognizedString の戻り値が "I am late" で、start = 6 および length = 1 という値を渡すと、このパラメータは文字 "a" に対応します。したがって、ContextNodeCollection は、1 つの ContextNode のみを含む可能性が高くなります (つまり、"late" という語に対応する InkWordNode)。この例では、start の値は 5 に、length の値は 4 に変更されます ("late" という語全体に対応)。
例
次の例では、GetNodesFromTextRange メソッドを使用して、選択したテキストに対応するストロークをマークします。この例では、theResultsTextBox という名前の TextBox の Text プロパティが GetRecognizedString メソッドによって返される値に設定され、またユーザーが theResultsTextBox の一部のテキストを選択していることを前提にしています。この例は、theInkAnalyzer という名前の InkAnalyzer が存在することも前提としています。
Dim theRootNode As RootNode = CType(theInkAnalyzer.RootNode, RootNode)
' First, set all strokes to black
For Each stroke As Stroke In theRootNode.Strokes
stroke.DrawingAttributes.Color = Colors.Black
Next stroke
' Find out what's been selected in the text box
Dim selStart As Integer = theResultsTextBox.SelectionStart
Dim selLength As Integer = theResultsTextBox.SelectionLength
' Do nothing if no text is selected.
If selLength = 0 Then
Return
End If
' Get the nodes that correspond to that range
Dim selectedSubNodes As ContextNodeCollection = _
theRootNode.GetNodesFromTextRange(selStart, selLength)
' Use the new start and length value to update the
' selection in the TextBox
theResultsTextBox.SelectionStart = selStart
theResultsTextBox.SelectionLength = selLength
' Next, set all selected sub nodes to red
Dim node As ContextNode
For Each node In selectedSubNodes
Dim stroke As Stroke
For Each stroke In node.Strokes
stroke.DrawingAttributes.Color = Colors.Red
Next stroke
Next node
RootNode theRootNode = (RootNode)theInkAnalyzer.RootNode;
// First, set all strokes to black
foreach (Stroke stroke in theRootNode.Strokes)
stroke.DrawingAttributes.Color = Colors.Black;
// Find out what's been selected in the text box
int selStart = theResultsTextBox.SelectionStart;
int selLength = theResultsTextBox.SelectionLength;
// Do nothing if no text is selected.
if (selLength == 0)
{
return;
}
// Get the nodes that correspond to that range
ContextNodeCollection selectedSubNodes =
theRootNode.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;
// 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