Compartir a través de


RootNode.GetTextRangeFromNodes (Método)

Actualización: noviembre 2007

Busca el intervalo de texto en la cadena reconocida que se corresponde con una colección de objetos ContextNode que son descendientes de RootNode.

Espacio de nombres:  Microsoft.Ink
Ensamblado:  Microsoft.Ink.Analysis (en Microsoft.Ink.Analysis.dll)

Sintaxis

'Declaración
Public Sub GetTextRangeFromNodes ( _
    subTree As ContextNodeCollection, _
    <OutAttribute> ByRef start As Integer, _
    <OutAttribute> ByRef length As Integer _
)
'Uso
Dim instance As RootNode
Dim subTree As ContextNodeCollection
Dim start As Integer
Dim length As Integer

instance.GetTextRangeFromNodes(subTree, _
    start, length)
public void GetTextRangeFromNodes(
    ContextNodeCollection subTree,
    out int start,
    out int length
)
public:
void GetTextRangeFromNodes(
    ContextNodeCollection^ subTree, 
    [OutAttribute] int% start, 
    [OutAttribute] int% length
)
public void GetTextRangeFromNodes(
    ContextNodeCollection subTree,
    /** @attribute OutAttribute */ /** @ref */int start,
    /** @attribute OutAttribute */ /** @ref */int length
)
public function GetTextRangeFromNodes(
    subTree : ContextNodeCollection, 
    start : int, 
    length : int
)

Parámetros

  • start
    Tipo: System.Int32%
    Comienzo del intervalo de texto.
  • length
    Tipo: System.Int32%
    Longitud del intervalo de texto.

Comentarios

Si subTree contiene un objeto ContextNode que no es ningún descendiente de RootNode, se produce una excepción ArgumentException.

Si el parámetro subTree contiene objetos ContextNode que no son consecutivos, se devuelve el intervalo de texto más pequeño que abarca todos los objetos ContextNode.

Ejemplos

En el ejemplo siguiente, se toma un RootNode, theRootNode, de un InkAnalyzer, theInkAnalyzer y se busca el último WritingRegionNode seleccionando la región de escritura que tiene los límites más bajos. Después, se busca el intervalo de texto que corresponde a esta región de escritura, se coloca el valor de GetRecognizedString en un control TextBox, theResultsTextBox y se selecciona el texto que corresponde a la última región de escritura.

Dim theRootNode As RootNode = CType(theInkAnalyzer.RootNode, RootNode)
Dim regions As ContextNodeCollection = _
    theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.WritingRegion)
Dim lastRegion As WritingRegionNode = Nothing
Dim maxY As Integer = Integer.MinValue
Dim aRegion As WritingRegionNode
For Each aRegion In regions
    If aRegion.Location.GetBounds().Bottom > maxY Then
        maxY = aRegion.Location.GetBounds().Bottom
        lastRegion = aRegion
    End If
Next aRegion

If lastRegion Is Nothing Then
    Return
End If
' Create a collection to hold this line
Dim lastRegionCollection As New ContextNodeCollection(theInkAnalyzer)
lastRegionCollection.Add(lastRegion)

' Find corresponding start and length
Dim start, length As Integer
theRootNode.GetTextRangeFromNodes(lastRegionCollection, start, length)

' Select this in the text box
theResultsTextBox.Text = theRootNode.GetRecognizedString()
theResultsTextBox.Select(start, length)
            RootNode theRootNode = (RootNode)theInkAnalyzer.RootNode;
            ContextNodeCollection regions =
                theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.WritingRegion);
            WritingRegionNode lastRegion = null;
            int maxY = int.MinValue;
            foreach (WritingRegionNode region in regions)
            {
                if (region.Location.GetBounds().Bottom > maxY)
                {
                    maxY = region.Location.GetBounds().Bottom;
                    lastRegion = region;
                }
            }

            if (lastRegion == null)
                return;

            // Create a collection to hold this line
            ContextNodeCollection lastRegionCollection = 
                new ContextNodeCollection(theInkAnalyzer);
            lastRegionCollection.Add(lastRegion);

            // Find corresponding start and length
            int start, length;
            theRootNode.GetTextRangeFromNodes(lastRegionCollection, out start, out length);

            // Select this in the text box
            theResultsTextBox.Text = theRootNode.GetRecognizedString();
            theResultsTextBox.Select(start, length);

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

Vea también

Referencia

RootNode (Clase)

RootNode (Miembros)

Microsoft.Ink (Espacio de nombres)