TextPattern.GetVisibleRanges Método

Definição

Recupera um array de intervalos de texto disjuntos desde um contentor de texto onde cada intervalo de texto começa com a primeira linha parcialmente visível até ao fim da última linha parcialmente visível.

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()

Devoluções

A coleção de texto visível varia dentro do contentor ou num array vazio. Null nunca é devolvido.

Exemplos

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

Observações

Intervalos de texto desconexos podem ocorrer quando qualquer conteúdo de um contentor de texto está obscurecido por uma janela sobreposta ou outro objeto, ou quando um contentor de texto com layout de várias colunas tem uma ou mais colunas parcialmente deslocadas fora de vista.

Se não houver texto visível, devolve-se um intervalo de texto degenerado (vazio). Este intervalo vazio pode ser devolvido se o recipiente de texto estiver vazio ou quando todo o texto estiver deslocado fora de vista.

Aplica-se a

Ver também