本文整理汇总了C#中System.Windows.Automation.PropertyCondition类的典型用法代码示例。如果您正苦于以下问题:C# PropertyCondition类的具体用法?C# PropertyCondition怎么用?C# PropertyCondition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyCondition类属于System.Windows.Automation命名空间,在下文中一共展示了PropertyCondition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetControls
public void GetControls()
{
//window = AutomationElement.FromHandle(new IntPtr(window.Current.NativeWindowHandle));
var autoIds = new string[] {
"12005",
"12006",
"12007",
"2010"};
var types = new TradeContorlTypes[] {
TradeContorlTypes.BuyCode,
TradeContorlTypes.BuyMoney,
TradeContorlTypes.BuyAmount,
TradeContorlTypes.BuyButton };
PropertyCondition propertyCondition = null;
for (var i = 0; i < autoIds.Length; i++)
{
propertyCondition = new PropertyCondition(AutomationElement.AutomationIdProperty, autoIds[i]);
var control = window.FindFirst(TreeScope.Subtree, propertyCondition);
if (control != null)
{
TradeControls.Instance().AddControl(types[i], control);
}
}
}
示例2: ButtonClick
private static bool ButtonClick(AutomationElement inElement, string automationId)
{
PropertyCondition btnCondition = new PropertyCondition(AutomationElement.AutomationIdProperty, automationId);
Console.WriteLine("Searching for the {0} button...", automationId);
AutomationElement control = inElement.FindFirst(TreeScope.Descendants, btnCondition);
if (control != null)
{
Console.WriteLine("Clicking the {0} button", automationId);
object controlType = control.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty);
if (controlType == ControlType.Button)
{
InvokePattern clickCommand = control.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
clickCommand.Invoke();
}
else if (controlType == ControlType.RadioButton)
{
SelectionItemPattern radioCheck = control.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;
radioCheck.Select();
}
System.Threading.Thread.Sleep(2000);
Console.WriteLine("Button {0} clicked.", automationId);
return true;
}
else
{
Console.WriteLine("Could not find button {0} ", automationId);
return false;
}
}
示例3: ShouldDescribeNegatedCompoundsUsingNot
public void ShouldDescribeNegatedCompoundsUsingNot()
{
var nameCondition = new PropertyCondition(AutomationElement.NameProperty, "Wooble");
const string expected = "not Name='Wooble'";
Assert.AreEqual(expected, new ConditionDescriber().Describe(new NotCondition(nameCondition)));
}
示例4: getScreenshotForWindowwithTitle
public static void getScreenshotForWindowwithTitle(string partorfulltext, string screenshotlocation)
{
AutomationElement root = AutomationElement.RootElement;
Condition cndwindows = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window);
AutomationElementCollection ActiveWindows = root.FindAll(TreeScope.Descendants, cndwindows);
AutomationElement ActiveWindow = null;
foreach (AutomationElement windw in ActiveWindows)
{
if (windw.Current.Name.Contains(partorfulltext))
{
ActiveWindow = windw;
break;
}
}
ActiveWindow.SetFocus();
WindowPattern wndptn = (WindowPattern)ActiveWindow.GetCurrentPattern(WindowPattern.Pattern);
wndptn.SetWindowVisualState(WindowVisualState.Maximized);
System.Threading.Thread.Sleep(2000);
Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height);
Graphics graphics = Graphics.FromImage(bitmap as Image);
graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);
bitmap.Save( Path.Combine(screenshotlocation, Guid.NewGuid() + ".jpg"), ImageFormat.Jpeg);
}
示例5: ShouldDescribeAPropertyConditionWithConditionAndValue
public void ShouldDescribeAPropertyConditionWithConditionAndValue()
{
var condition = new PropertyCondition(AutomationElement.NameProperty, "Wibble");
const string expected = "Name='Wibble'";
Assert.AreEqual(expected, new ConditionDescriber().Describe(condition));
}
示例6: FindApplicationByTitle
/// <summary>
/// Find application from desktop
/// </summary>
/// <param name="appPath"></param>
/// <param name="arguments"></param>
/// <returns></returns>
public static AutomationElement FindApplicationByTitle(string titile)
{
Helper.ValidateArgumentNotNull(titile, "Title");
var desktop = AutomationElement.RootElement;
Condition condition = new PropertyCondition(AutomationElement.NameProperty, titile);
return desktop.FindFirst(TreeScope.Descendants,condition);
}
示例7: ConditionSetByConstructor
public void ConditionSetByConstructor()
{
var automationProperty = AutomationElement.NameProperty;
var valueProvider = CreateValueProvider(automationProperty);
var condition = new PropertyCondition(automationProperty, "");
var def = CreateElementDefinition(TreeScope.Descendants, automationProperty, valueProvider, condition);
Assert.IsTrue(ReferenceEquals(condition, def.Condition));
}
示例8: GetNamePropertyOf
public static string GetNamePropertyOf(this AutomationElement dialogWindow, string type)
{
if (dialogWindow == null) throw new ArgumentNullException("dialogWindow");
var controlTypePropertyCondition = new PropertyCondition(AutomationElement.LocalizedControlTypeProperty, type);
var firstResultOfCondition = dialogWindow.FindFirst(TreeScope.Children, controlTypePropertyCondition);
return firstResultOfCondition.GetCurrentPropertyValue(AutomationElement.NameProperty) as string;
}
示例9: FindElementByAutomationId
/// <summary>
/// Finds a descendent of the focused element that has the specified
/// className, controlType and automationID
/// </summary>
/// <param name="focusedElement"></param>
/// <param name="className">class name </param>
/// <param name="controlType">controlType</param>
/// <param name="automationId">automation id </param>
/// <returns>automation element if found null otherwise</returns>
public static AutomationElement FindElementByAutomationId(AutomationElement focusedElement, String className, object controlType, String automationId)
{
var controlTypeProperty = new PropertyCondition(AutomationElement.ControlTypeProperty, controlType);
var automationIdProperty = new PropertyCondition(AutomationElement.AutomationIdProperty, automationId);
var classNameProperty = new PropertyCondition(AutomationElement.ClassNameProperty, className);
var findControl = new AndCondition(controlTypeProperty, automationIdProperty, classNameProperty);
var retVal = focusedElement.FindFirst(TreeScope.Descendants, findControl);
return retVal;
}
示例10: FindElementById
public static AutomationElement FindElementById(AutomationElement parentElement, string automationID, ControlType type)
{
PropertyCondition typeCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, type);
PropertyCondition IDCondition = new PropertyCondition(AutomationElement.AutomationIdProperty, automationID);
AndCondition andCondition = new AndCondition(typeCondition, IDCondition);
return parentElement.FindFirst(TreeScope.Element | TreeScope.Descendants, andCondition);
}
示例11: FindWindowByName
public static AutomationElement FindWindowByName(AutomationElement rootElement, string name, ControlType type)
{
PropertyCondition nameCondition = new PropertyCondition(AutomationElement.NameProperty, name);
PropertyCondition typeCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, type);
AndCondition andCondition = new AndCondition(nameCondition, typeCondition);
return rootElement.FindFirst(TreeScope.Element | TreeScope.Descendants, andCondition);
}
示例12: ShouldDescribeCompoundConditionsUsingOr
public void ShouldDescribeCompoundConditionsUsingOr()
{
var nameCondition = new PropertyCondition(AutomationElement.NameProperty, "Wubble");
var controlTypeCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window);
var condition = new OrCondition(nameCondition, controlTypeCondition);
var expected = "(Name='Wubble' or ControlType='" + ControlType.Window.Id + "')";
Assert.AreEqual(expected, new ConditionDescriber().Describe(condition));
}
示例13: ConditionTest
public void ConditionTest ()
{
AssertRaises<ArgumentNullException> (
() => new TreeWalker (null),
"passing null to TreeWalker constructor");
Condition buttonCondition = new PropertyCondition (AEIds.ControlTypeProperty, ControlType.Button);
TreeWalker buttonWalker = new TreeWalker (buttonCondition);
Assert.AreEqual (buttonCondition, buttonWalker.Condition, "Condition");
}
示例14: FindElementByClassName
public static AutomationElementCollection FindElementByClassName(AutomationElement parentElement, string className, ControlType type)
{
PropertyCondition typeCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, type);
PropertyCondition IDCondition = new PropertyCondition(AutomationElement.ClassNameProperty, className);
AndCondition andCondition = new AndCondition(typeCondition, IDCondition);
return parentElement.FindAll(TreeScope.Element | TreeScope.Descendants, andCondition);
}
示例15: GetFirstChildTest
public void GetFirstChildTest ()
{
Condition buttonCondition = new PropertyCondition (AEIds.ControlTypeProperty, ControlType.Button);
TreeWalker buttonWalker = new TreeWalker (buttonCondition);
AssertRaises<ArgumentNullException> (
() => buttonWalker.GetFirstChild (null),
"passing null to TreeWalker.GetFirstChild");
VerifyGetFirstChild (buttonWalker, groupBox1Element, button7Element);
}