TextPattern.CapStyleAttribute Pole

Definicja

Identyfikuje CapStyle atrybut zakresu tekstu.

public: static initonly System::Windows::Automation::AutomationTextAttribute ^ CapStyleAttribute;
public static readonly System.Windows.Automation.AutomationTextAttribute CapStyleAttribute;
 staticval mutable CapStyleAttribute : System.Windows.Automation.AutomationTextAttribute
Public Shared ReadOnly CapStyleAttribute As AutomationTextAttribute 

Wartość pola

Przykłady

W poniższym przykładzie pokazano, jak uzyskać wartość atrybutu dla zakresu tekstu w Microsoft Notatniku.

Uwaga

Microsoft Notatnik jest używany jako dostawca tekstu tylko do celów przykładowych. Microsoft Notatnik nie ma gwarancji obsługi żądanej wartości atrybutu.

private void GetCapStyleAttribute()
{
    // 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.CapStyleAttribute);
    if (oAttribute == TextPattern.MixedAttributeValue)
    {
        Console.WriteLine("Mixed cap styles.");
    }
    else
    {
        Console.WriteLine(oAttribute.ToString());
    }
}
Private Sub GetCapStyleAttribute()
    ' Start application.
    Dim p As Process = Process.Start("Notepad.exe", "text.txt")

    ' target --> The root AutomationElement.
    Dim target As AutomationElement = AutomationElement.FromHandle(p.MainWindowHandle)

    ' Specify the control type we're looking for, in this case 'Document'
    Dim cond As PropertyCondition = New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document)

    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
    End If

    Dim oAttribute As Object = textpatternPattern.DocumentRange.GetAttributeValue(TextPattern.CapStyleAttribute)
    If (oAttribute = TextPattern.MixedAttributeValue) Then
        Console.WriteLine("Mixed cap styles.")
    Else
        Console.WriteLine(oAttribute.ToString())
    End If
End Sub

Uwagi

Ten identyfikator jest używany przez aplikacje klienckie automatyzacja interfejsu użytkownika. automatyzacja interfejsu użytkownika dostawcy powinni użyć odpowiedniego pola w pliku TextPatternIdentifiers.

automatyzacja interfejsu użytkownika klienci uzyskują wartość atrybutu przez wywołanie metody GetAttributeValue.

Wartości dla tego atrybutu są typu CapStyle. Wartość domyślna to None.

Dotyczy

Zobacz też