Export (0) Print
Expand All

TextPattern.IndentationFirstLineAttribute Field

Identifies the IndentationFirstLine (TextIndent) attribute of a text range.

Namespace: System.Windows.Automation
Assembly: UIAutomationClient (in uiautomationclient.dll)

public static readonly AutomationTextAttribute IndentationFirstLineAttribute
public static final AutomationTextAttribute IndentationFirstLineAttribute
public static final var IndentationFirstLineAttribute : AutomationTextAttribute
Not applicable.

This attribute represents the first-line indentation in points (GraphicsUnit) 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 TextPatternIdentifiers.

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

Values for this attribute are of type Double. The default value is zero.

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

NoteNote:

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 GetIndentationFirstLineAttribute()
{
    // 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.IndentationFirstLineAttribute);
    if (oAttribute == TextPattern.MixedAttributeValue)
    {
        Console.WriteLine("Mixed first line indents.");
    }
    else
    {
        Console.WriteLine(oAttribute.ToString());
    }
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft