OrCondition(Condition[]) Constructor
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the OrCondition class.
public:
OrCondition(... cli::array <System::Windows::Automation::Condition ^> ^ conditions);
public OrCondition (params System.Windows.Automation.Condition[] conditions);
new System.Windows.Automation.OrCondition : System.Windows.Automation.Condition[] -> System.Windows.Automation.OrCondition
Public Sub New (ParamArray conditions As Condition())
Parameters
- conditions
- Condition[]
Two or more conditions, any one of which may be true for a match.
Examples
In the following example, an OrCondition is used to retrieve UI Automation elements that are either buttons or radio buttons.
/// <summary>
/// Uses OrCondition to retrieve elements that match either of two conditions.
/// </summary>
/// <param name="elementMainWindow">An application window element.</param>
public void OrConditionExample(AutomationElement elementMainWindow)
{
if (elementMainWindow == null)
{
throw new ArgumentException();
}
OrCondition conditionButtons = new OrCondition(
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button),
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.RadioButton));
AutomationElementCollection elementCollectionButtons = elementMainWindow.FindAll(
TreeScope.Subtree, conditionButtons);
Console.WriteLine("\nButtons and radio buttons:");
foreach (AutomationElement autoElement in elementCollectionButtons)
{
Console.WriteLine(autoElement.Current.Name);
}
// Example of getting the conditions from the OrCondition.
Condition[] conditions = conditionButtons.GetConditions();
Console.WriteLine("OrCondition has " + conditions.GetLength(0) + " subconditions.");
}
''' <summary>
''' Uses OrCondition to retrieve elements that match either of two conditions.
''' </summary>
''' <param name="elementMainWindow">An application window element.</param>
Public Sub OrConditionExample(ByVal elementMainWindow As AutomationElement)
If elementMainWindow Is Nothing Then
Throw New ArgumentException()
End If
Dim conditionButtons As New OrCondition(New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button), New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.RadioButton))
Dim elementCollectionButtons As AutomationElementCollection = elementMainWindow.FindAll(TreeScope.Subtree, conditionButtons)
Console.WriteLine("Buttons and radio buttons:")
Dim autoElement As AutomationElement
For Each autoElement In elementCollectionButtons
Console.WriteLine(autoElement.Current.Name)
Next autoElement
' Example of getting the conditions from the OrCondition.
Dim conditions As Condition() = conditionButtons.GetConditions()
Console.WriteLine("OrCondition has " & conditions.GetLength(0) & " subconditions.")
End Sub
Applies to
שתף איתנו פעולה ב- GitHub
ניתן למצוא את המקור לתוכן זה ב- GitHub, שם ניתן גם ליצור ולסקור בעיות ולמשוך בקשות. לקבלת מידע נוסף, עיין במדריך התורמים שלנו.