NotCondition(Condition) Конструктор
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Инициализирует новый экземпляр класса NotCondition.
public:
NotCondition(System::Windows::Automation::Condition ^ condition);
public NotCondition (System.Windows.Automation.Condition condition);
new System.Windows.Automation.NotCondition : System.Windows.Automation.Condition -> System.Windows.Automation.NotCondition
Public Sub New (condition As Condition)
Параметры
- condition
- Condition
Отрицаемое условие.
Примеры
В следующем примере используется для извлечения всех элементов, NotCondition которые не были извлечены с помощью другого Condition.
/// <summary>
/// Uses NotCondition to retrieve elements that do not match specified conditions.
/// </summary>
/// <param name="elementMainWindow">An application window element.</param>
public void NotConditionExample(AutomationElement elementMainWindow)
{
if (elementMainWindow == null)
{
throw new ArgumentException();
}
// Set up a condition that finds all buttons and radio buttons.
OrCondition conditionButtons = new OrCondition(
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button),
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.RadioButton));
// Use NotCondition to retrieve elements that are not buttons or radio buttons.
Condition conditionNotButtons = new NotCondition(conditionButtons);
AutomationElementCollection elementCollectionNotButtons = elementMainWindow.FindAll(
TreeScope.Subtree, conditionNotButtons);
Console.WriteLine("Elements other than buttons:");
foreach (AutomationElement autoElement in elementCollectionNotButtons)
{
Console.WriteLine(autoElement.Current.Name);
}
}
''' <summary>
''' Uses NotCondition to retrieve elements that do not match specified conditions.
''' </summary>
''' <param name="elementMainWindow">An application window element.</param>
Public Sub NotConditionExample(ByVal elementMainWindow As AutomationElement)
If elementMainWindow Is Nothing Then
Throw New ArgumentException()
End If
' Set up a condition that finds all buttons and radio buttons.
Dim conditionButtons As New OrCondition(New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button), New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.RadioButton))
' Use NotCondition to retrieve elements that are not buttons or radio buttons.
Dim conditionNotButtons As Condition = New NotCondition(conditionButtons)
Dim elementCollectionNotButtons As AutomationElementCollection = elementMainWindow.FindAll(TreeScope.Subtree, conditionNotButtons)
Console.WriteLine("Elements other than buttons:")
Dim autoElement As AutomationElement
For Each autoElement In elementCollectionNotButtons
Console.WriteLine(autoElement.Current.Name)
Next autoElement
End Sub