TextPattern.GetVisibleRanges Método

Definición

Recupera una matriz de intervalos de texto separados de un contenedor de texto donde cada intervalo de texto comienza con la primera línea parcialmente visible 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

Colección de intervalos de texto visibles dentro del contenedor o una matriz vacía. Null nunca se devuelve.

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