Cet article a fait l’objet d’une traduction automatique. Pour afficher l’article en anglais, activez la case d’option Anglais. Vous pouvez également afficher le texte anglais dans une fenêtre contextuelle en faisant glisser le pointeur de la souris sur le texte traduit.
Traduction
Anglais

TextPattern.HorizontalTextAlignmentAttribute champ

 

Date de publication : novembre 2016

Identifie l'attribut HorizontalTextAlignment d'une plage de texte.

Espace de noms:   System.Windows.Automation
Assembly:  UIAutomationClient (dans UIAutomationClient.dll)

public static readonly AutomationTextAttribute HorizontalTextAlignmentAttribute

This attribute represents the horizontal text alignment applied to the paragraph(s) associated with the calling text range.

This identifier is used by UI Automation client applications. UI Automation providers should use the equivalent field in T:System.Windows.Automation.TextPatternIdentifiers.

UI Automation clients get the value of the attribute by calling M:System.Windows.Automation.Text.TextPatternRange.GetAttributeValue(System.Windows.Automation.AutomationTextAttribute).

Values for this attribute are of type T:System.Windows.Automation.Text.HorizontalTextAlignment. The default value is F:System.Windows.Automation.Text.HorizontalTextAlignment.Left

The following example shows how to obtain an attribute value for a range of text in TLA#tla_notepad.

System_CAPS_noteRemarque

Bloc-notes Microsoft is used as the text provider for example purposes only. Bloc-notes Microsoft is not guaranteed to support the attribute value being requested.

private void GetHorizontalTextAlignmentAttribute()
{
    // Start application.
    Process p = Process.Start("Notepad.exe", "text.txt");

    // target --> The root AutomationElement.
    AutomationElement target = AutomationElement.FromHandle(p.MainWindowHandle);

    // Specify the control type we're looking for, in this case 'Document'
    PropertyCondition cond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document);

    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;
    }

    Object oAttribute = textpatternPattern.DocumentRange.GetAttributeValue(TextPattern.HorizontalTextAlignmentAttribute);
    if (oAttribute == TextPattern.MixedAttributeValue)
    {
        Console.WriteLine("Mixed horizontal alignments.");
    }
    else
    {
        Console.WriteLine(oAttribute.ToString());
    }
}

.NET Framework
Disponible depuis 3.0
Retour au début
Afficher: