InkAnalyzer.GetNodesFromTextRange (Método) (Int32%, Int32%, ContextNodeCollection)
Actualización: noviembre 2007
Devuelve una colección de objetos ContextNode que son pertinentes para el intervalo de texto indicado de los nodos de contexto especificados.
Espacio de nombres: Microsoft.Ink
Ensamblado: Microsoft.Ink.Analysis (en Microsoft.Ink.Analysis.dll)
Sintaxis
'Declaración
Public Function GetNodesFromTextRange ( _
ByRef start As Integer, _
ByRef length As Integer, _
nodesToSearch As ContextNodeCollection _
) As ContextNodeCollection
'Uso
Dim instance As InkAnalyzer
Dim start As Integer
Dim length As Integer
Dim nodesToSearch As ContextNodeCollection
Dim returnValue As ContextNodeCollection
returnValue = instance.GetNodesFromTextRange(start, _
length, nodesToSearch)
public ContextNodeCollection GetNodesFromTextRange(
ref int start,
ref int length,
ContextNodeCollection nodesToSearch
)
public:
ContextNodeCollection^ GetNodesFromTextRange(
int% start,
int% length,
ContextNodeCollection^ nodesToSearch
)
public ContextNodeCollection GetNodesFromTextRange(
/** @ref */int start,
/** @ref */int length,
ContextNodeCollection nodesToSearch
)
public function GetNodesFromTextRange(
start : int,
length : int,
nodesToSearch : ContextNodeCollection
) : ContextNodeCollection
Parámetros
- start
Tipo: System.Int32%
Referencia al inicio del intervalo de texto de la sección nodesToSearch de la cadena reconocida.
- length
Tipo: System.Int32%
Referencia a la longitud del intervalo de texto de la sección nodesToSearch de la cadena reconocida.
- nodesToSearch
Tipo: Microsoft.Ink.ContextNodeCollection
Objetos ContextNode a los que se desea limitar la búsqueda.
Valor devuelto
Tipo: Microsoft.Ink.ContextNodeCollection
Objetos ContextNode que son pertinentes para el intervalo de texto indicado de los nodos de contexto especificados.
Comentarios
El intervalo de texto especificado debe estar relacionado con la sección nodesToSearch de la cadena reconocida del objeto InkAnalyzer y no con la cadena reconocida de todo el objeto InkAnalyzer.
Este método modifica los valores de los parámetros start y length al expandir el intervalo de texto a los límites de la palabra más próximos.
Por ejemplo, si la cadena reconocida es la frase en inglés "I am late" y llama a este método utilizando los valores de parámetro 6 para start y 1 para length, que corresponde a la letra "a" de "late", este método devuelve una colección que contiene un único objeto ContextNode, InkWordNode o TextWordNode, que corresponde a la palabra "late". En este ejemplo, este método modifica también el valor de start a 5 y el valor de length a 4, lo que corresponde a la palabra "late".
Nota
El parámetro start está relacionado con la cadena reconocida del parámetro nodesToSearch.
Ejemplos
En este ejemplo se toma System.Windows.Forms.TextBoxtheResultsTextBox, cuya propiedad Text se ha establecido en las cadenas reconocidas combinadas de los nodos del objeto ContextNodeCollection, nodesToSearch. La colección nodesToSearch contiene nodos de contexto del objeto InkAnalyzer, theInkAnalyzer. El código de ejemplo toma la selección del cuadro de texto y marca la propiedad Strokes que corresponde a esa selección.
' 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 Microsoft.Ink.ContextNodeCollection = _
Me.theInkAnalyzer.GetNodesFromTextRange( _
selStart, selLength, nodesToSearch)
' 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
Dim theStroke As Microsoft.Ink.Stroke
For Each theStroke In Me.theInkAnalyzer.RootNode.Strokes
theStroke.DrawingAttributes = _
New Microsoft.Ink.DrawingAttributes(Color.Black)
Next theStroke
' Next, set all selected sub nodes to red
Dim theContextNode As Microsoft.Ink.ContextNode
For Each theContextNode In selectedSubNodes
For Each theStroke In theContextNode.Strokes
theStroke.DrawingAttributes = _
New Microsoft.Ink.DrawingAttributes(Color.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
Microsoft.Ink.ContextNodeCollection selectedSubNodes =
this.theInkAnalyzer.GetNodesFromTextRange(
ref selStart, ref selLength, nodesToSearch);
// 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 (Microsoft.Ink.Stroke theStroke
in this.theInkAnalyzer.RootNode.Strokes)
{
theStroke.DrawingAttributes =
new Microsoft.Ink.DrawingAttributes(Color.Black);
}
// Next, set all selected sub nodes to red
foreach (Microsoft.Ink.ContextNode theContextNode in selectedSubNodes)
{
foreach (Microsoft.Ink.Stroke theStroke in theContextNode.Strokes)
{
theStroke.DrawingAttributes =
new Microsoft.Ink.DrawingAttributes(Color.Red);
}
}
Plataformas
Windows Vista
.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
Información de versión
.NET Framework
Compatible con: 3.0