TextPattern.HorizontalTextAlignmentAttribute Campo

Definizione

Identifica l'attributo HorizontalTextAlignment di un intervallo di testo.

C#
public static readonly System.Windows.Automation.AutomationTextAttribute HorizontalTextAlignmentAttribute;

Valore del campo

AutomationTextAttribute

Esempio

Nell'esempio seguente viene illustrato come ottenere un valore di attributo per un intervallo di testo in Microsoft Blocco note.

Nota

Microsoft Blocco note viene usato solo come provider di testo. Microsoft Blocco note non è garantito supportare il valore dell'attributo richiesto.

C#
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());
    }
}

Commenti

Questo attributo rappresenta l'allineamento orizzontale del testo applicato ai paragrafi associati all'intervallo di testo chiamante.

Questo identificatore viene usato dalle applicazioni client Automazione interfaccia utente. Automazione interfaccia utente provider devono usare il campo equivalente in TextPatternIdentifiers.

Automazione interfaccia utente client ottengono il valore dell'attributo chiamando GetAttributeValue.

I valori per questo attributo sono di tipo HorizontalTextAlignment. Il valore predefinito è Left

Si applica a

Prodotto Versioni
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

Vedi anche