Esporta (0) Stampa
Espandi tutto

Campo TextPattern.OutlineStylesAttribute

Identifies the OutlineStyles (OutlineStyles) attribute of a text range.

Spazio dei nomi: System.Windows.Automation
Assembly: UIAutomationClient (in uiautomationclient.dll)

public static readonly AutomationTextAttribute OutlineStylesAttribute
public static final AutomationTextAttribute OutlineStylesAttribute
public static final var OutlineStylesAttribute : AutomationTextAttribute
Non applicabile.

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

UI Automation clients get the value of the attribute by calling GetAttributeValue.

Values for this attribute are of type OutlineStyles. The default value is None.

The following example shows how to obtain an attribute value for a range of text in Microsoft Notepad.

NotaNota:

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

private void GetOutlineStylesAttribute()
{
    // 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.OutlineStylesAttribute);
    if (oAttribute == TextPattern.MixedAttributeValue)
    {
        Console.WriteLine("Mixed outline styles.");
    }
    else
    {
        Console.WriteLine(oAttribute.ToString());
    }
}

Microsoft .NET Framework 3.0 è supportato in Windows Vista, Microsoft Windows XP SP2 e Windows Server 2003 SP1.

.NET Framework

Supportato in:

Aggiunte alla community

AGGIUNGI
Mostra:
© 2014 Microsoft