다음을 통해 공유


AndCondition.GetConditions 메서드

정의

이 조건의 하위 조건 배열을 검색합니다.

public:
 cli::array <System::Windows::Automation::Condition ^> ^ GetConditions();
public System.Windows.Automation.Condition[] GetConditions ();
member this.GetConditions : unit -> System.Windows.Automation.Condition[]
Public Function GetConditions () As Condition()

반환

Condition[]

이 조건의 하위 조건 배열입니다.

예제

다음 예제에서는 생성한 AndCondition 다음 포함된 조건 수를 표시합니다.

/// <summary>
/// Uses AndCondition to retrieve elements that match both of two conditions.
/// </summary>
/// <param name="elementMainWindow">An application window element.</param>
public void AndConditionExample(AutomationElement elementMainWindow)
{
    if (elementMainWindow == null)
    {
        throw new ArgumentException();
    }

    AndCondition conditionEnabledButtons = new AndCondition(
        new PropertyCondition(AutomationElement.IsEnabledProperty, true),
        new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button));
    AutomationElementCollection enabledButtons = elementMainWindow.FindAll(
        TreeScope.Subtree, conditionEnabledButtons);
    Console.WriteLine("\nEnabled buttons:");
    foreach (AutomationElement autoElement in enabledButtons)
    {
        Console.WriteLine(autoElement.Current.Name);
    }

    // Example of getting the conditions from the AndCondition.
    Condition[] conditions = conditionEnabledButtons.GetConditions();
    Console.WriteLine("AndCondition has " + conditions.GetLength(0) + " subconditions.");
}
''' <summary>
''' Uses AndCondition to retrieve elements that match both of two conditions.
''' </summary>
''' <param name="elementMainWindow">An application window element.</param>
Public Sub AndConditionExample(ByVal elementMainWindow As AutomationElement)
    If elementMainWindow Is Nothing Then
        Throw New ArgumentException()
    End If

    Dim conditionEnabledButtons As New AndCondition(New PropertyCondition(AutomationElement.IsEnabledProperty, True), New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button))
    Dim enabledButtons As AutomationElementCollection = elementMainWindow.FindAll(TreeScope.Subtree, conditionEnabledButtons)
    Console.WriteLine("Enabled buttons:")
    Dim autoElement As AutomationElement
    For Each autoElement In enabledButtons
        Console.WriteLine(autoElement.Current.Name)
    Next autoElement

    ' Example of getting the conditions from the AndCondition.
    Dim conditions As Condition() = conditionEnabledButtons.GetConditions()
    Console.WriteLine("AndCondition has " & conditions.GetLength(0) & " subconditions.")

End Sub

설명

반환된 배열은 복사본입니다. 수정해도 .의 AndCondition상태에는 영향을 주지 않습니다.

적용 대상