Share via


TextPattern.GetVisibleRanges Método

Definición

Recupera una matriz de intervalos de texto no contiguos de un contenedor de texto donde cada intervalo comienza con la primera línea parcialmente visible y continúa hasta el final de la última línea parcialmente visible.

public:
 cli::array <System::Windows::Automation::Text::TextPatternRange ^> ^ GetVisibleRanges();
public System.Windows.Automation.Text.TextPatternRange[] GetVisibleRanges ();
member this.GetVisibleRanges : unit -> System.Windows.Automation.Text.TextPatternRange[]
Public Function GetVisibleRanges () As TextPatternRange()

Devoluciones

TextPatternRange[]

La colección de intervalos de texto visibles en el contenedor o una matriz vacía. Nunca se devuelve Null.

Ejemplos

private TextPatternRange[] CurrentVisibleRanges(AutomationElement target)
{
    // Specify the control type we're looking for, in this case 'Document'
    PropertyCondition cond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document);

    // target --> The root AutomationElement.
    AutomationElement textProvider = target.FindFirst(TreeScope.Descendants, cond);

    TextPattern textpatternPattern = textProvider.GetCurrentPattern(TextPattern.Pattern) as TextPattern;

    if (textpatternPattern == null)
    {
        Console.WriteLine("Root element does not contain a descendant that supports TextPattern.");
        return null;
    }
    return textpatternPattern.GetVisibleRanges();
}
Private Function CurrentVisibleRanges(ByVal target As AutomationElement) As TextPatternRange()
    ' Specify the control type we're looking for, in this case 'Document'
    Dim cond As PropertyCondition = New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document)

    ' target --> The root AutomationElement.
    Dim textProvider As AutomationElement = target.FindFirst(TreeScope.Descendants, cond)

    Dim textpatternPattern As TextPattern = CType(textProvider.GetCurrentPattern(TextPattern.Pattern), TextPattern)

    If (textpatternPattern Is Nothing) Then
        Console.WriteLine("Root element does not contain a descendant that supports TextPattern.")
        Return Nothing
    End If

    Return textpatternPattern.GetVisibleRanges()
End Function

Comentarios

Los intervalos de texto separados pueden producirse cuando cualquier contenido de un contenedor de texto está oculto por una ventana superpuesta u otro objeto, o cuando un contenedor de texto con un diseño de varias columnas tiene una o varias columnas parcialmente desplazadas fuera de la vista.

Si no hay texto visible, se devuelve un intervalo de texto degenerado (vacío). Este intervalo vacío se puede devolver si el contenedor de texto está vacío o cuando todo el texto se desplaza fuera de la vista.

Se aplica a

Consulte también