本文整理汇总了C#中System.Windows.Automation.ControlType类的典型用法代码示例。如果您正苦于以下问题:C# ControlType类的具体用法?C# ControlType怎么用?C# ControlType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ControlType类属于System.Windows.Automation命名空间,在下文中一共展示了ControlType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindChildByControlType
public static AutomationElement FindChildByControlType(this AutomationElement element, ControlType controlType)
{
AutomationElement result =
element.FindChildByCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, controlType));
return result;
}
示例2: FindElementByNameFilteredByControlTypeAndMouseClick
/// <summary>
/// Get automationelement by name, filtered by classname - mouse click if found
/// </summary>
/// <param name="parent"></param>
/// <param name="automationName">case-insensitive automation name</param>
/// <param name="controlType"></param>
/// <param name="controlType2"></param>
/// <exception cref="ApplicationException">if matching element not found</exception>
/// <exception cref="ApplicationException">if specified element is not enabled</exception>
public static void FindElementByNameFilteredByControlTypeAndMouseClick(AutomationElement parent, string automationName, ControlType controlType, ControlType controlType2, TimeSpan mouseClickDelay, TreeScope treeScope)
{
FindElementByNameFilteredByControlTypeWithTimeoutAndMouseClick(parent, automationName, controlType, controlType2,
AddinTestUtility.FindRibbonButtonsTimeout, //findDelay
mouseClickDelay,
treeScope);
}
示例3: TestParametersAgainstCollection
private void TestParametersAgainstCollection(
ControlType controlType,
string searchString,
IEnumerable<IUiElement> collection,
int expectedNumberOfElements)
{
// Arrange
string controlTypeString = string.Empty;
if (null != controlType) {
controlTypeString = controlType.ProgrammaticName.Substring(12);
}
GetControlCmdletBase cmdlet =
FakeFactory.Get_GetControlCmdletBase(controlType, searchString);
Condition condition =
ControlSearcher.GetTextSearchCondition(searchString, new string[]{ controlTypeString }, false);
IUiElement element =
FakeFactory.GetElement_ForFindAll(
collection,
condition);
// Act
var resultList = RealCodeCaller.GetResultList_TextSearch(element, condition);
// Assert
MbUnit.Framework.Assert.Count(expectedNumberOfElements, resultList);
Xunit.Assert.Equal(expectedNumberOfElements, resultList.Count);
if (!string.IsNullOrEmpty(searchString)) {
MbUnit.Framework.Assert.ForAll(
resultList.Cast<IUiElement>().ToList<IUiElement>(),
// 20140312
// x => x.Current.Name == searchString || x.Current.AutomationId == searchString || x.Current.ClassName == searchString ||
x => x.GetCurrent().Name == searchString || x.GetCurrent().AutomationId == searchString || x.GetCurrent().ClassName == searchString ||
(null != (x.GetCurrentPattern<IValuePattern>(ValuePattern.Pattern) as IValuePattern) && (x.GetCurrentPattern<IValuePattern>(ValuePattern.Pattern) as IValuePattern).Current.Value == searchString));
/*
(null != (x.GetCurrentPattern<IValuePattern>(ValuePattern.Pattern) as IValuePattern) ?
// (x.GetCurrentPattern<IValuePattern, ValuePattern>(ValuePattern.Pattern) as IValuePattern).Current.Value == searchString :
(x.GetCurrentPattern<IValuePattern>(ValuePattern.Pattern) as IValuePattern).Current.Value == searchString :
false));
*/
}
// if (null != controlType) {
// MbUnit.Framework.Assert.ForAll(resultList.Cast<IUiElement>().ToList<IUiElement>(), x => x.Current.ControlType == controlType);
// }
Xunit.Assert.Equal(expectedNumberOfElements, resultList.Count);
if (!string.IsNullOrEmpty(searchString)) {
resultList.All(
// 20140312
// x => x.Current.Name == searchString || x.Current.AutomationId == searchString || x.Current.ClassName == searchString ||
x => x.GetCurrent().Name == searchString || x.GetCurrent().AutomationId == searchString || x.GetCurrent().ClassName == searchString ||
(null != (x.GetCurrentPattern<IValuePattern>(ValuePattern.Pattern) as IValuePattern) && (x.GetCurrentPattern<IValuePattern>(ValuePattern.Pattern) as IValuePattern).Current.Value == searchString));
/*
(null != (x.GetCurrentPattern<IValuePattern>(ValuePattern.Pattern) as IValuePattern) ?
(x.GetCurrentPattern<IValuePattern>(ValuePattern.Pattern) as IValuePattern).Current.Value == searchString :
false));
*/
}
}
示例4: ThrowInvalidOperationExceptionIfNotOf
public static AutomationElement ThrowInvalidOperationExceptionIfNotOf(this AutomationElement automationElement, ControlType controlType)
{
if (!automationElement.Current.ControlType.Equals(controlType))
throw new InvalidOperationException(string.Format("The AutomationElement provided has the ControlType '{0}', which is not a '{1}'.",
automationElement.Current.ControlType, controlType));
return automationElement;
}
示例5: getAutomationElement
public static AutomationElement getAutomationElement(AutomationElement parent, TreeScope scope, ControlType type, string name)
{
var element = parent.FindFirst(scope, new AndCondition(
new PropertyCondition(AutomationElement.ControlTypeProperty, type),
new PropertyCondition(AutomationElement.NameProperty, name),
Automation.ControlViewCondition));
return element;
}
示例6: FindFirstAncestorByControlType
public static AutomationElement FindFirstAncestorByControlType(this AutomationElement ae, ControlType className)
{
var ancestor = TreeWalker.ControlViewWalker.GetParent(ae);
for (; ancestor != null && className != ancestor.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty);
ancestor = TreeWalker.ControlViewWalker.GetParent(ancestor))
{
}
return ancestor;
}
示例7: 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);
}
示例8: 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);
}
示例9: ByTypeAndName
public static Condition ByTypeAndName(ControlType type, String name)
{
Condition[] locators =
{
new PropertyCondition(AutomationElement.NameProperty, name),
new PropertyCondition(AutomationElement.ControlTypeProperty, type)
};
return new AndCondition(locators);
}
示例10: 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);
}
示例11: FindInDepth
public static AutomationElement FindInDepth(this AutomationElement root, ControlType type, int levels)
{
AutomationElement result = root;
for (int i = 0; i < levels; i++)
{
Thread.Sleep(100);
result = result.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, type));
}
return result;
}
示例12: ControlDictionaryItem
public ControlDictionaryItem(Type testControlType, ControlType controlType, string className, bool identifiedByClassName, bool isPrimary,
bool isExcluded, string frameworkId, bool hasPrimaryChildren)
{
this.testControlType = testControlType;
this.controlType = controlType;
this.className = className;
this.identifiedByClassName = identifiedByClassName;
this.isPrimary = isPrimary;
this.isExcluded = isExcluded;
this.frameworkId = frameworkId;
this.hasPrimaryChildren = hasPrimaryChildren;
}
示例13: SetTextValue
public int SetTextValue(String windowName, String objName, String value)
{
AutomationElement childHandle = GetObjectHandle(windowName,
objName);
if (!utils.IsEnabled(childHandle))
{
childHandle = null;
throw new XmlRpcFaultException(123,
"Object state is disabled");
}
object valuePattern = null;
try
{
if (childHandle.Current.ControlType == ControlType.ComboBox)
{
AutomationElement o = null;
ArrayList objectList = new ArrayList();
ControlType[] type = new ControlType[1] { ControlType.Edit };
// NOTE: Using "*" for object name, which returns the first
// matching Edit control type
o = utils.InternalGetObjectHandle(childHandle,
"*", type, ref objectList);
if (o != null)
childHandle = o;
objectList = null;
}
// Reference: http://msdn.microsoft.com/en-us/library/ms750582.aspx
if (!childHandle.TryGetCurrentPattern(ValuePattern.Pattern,
out valuePattern))
{
childHandle.SetFocus();
SendKeys.SendWait(value);
}
else
((ValuePattern)valuePattern).SetValue(value);
}
catch (Exception ex)
{
LogMessage(ex);
if (ex is XmlRpcFaultException)
throw;
else
throw new XmlRpcFaultException(123,
"Unhandled exception: " + ex.Message);
}
finally
{
childHandle = null;
valuePattern = null;
}
return 1;
}
示例14: GetChildElement
/// <summary>
/// This method gets the list of ChildElements of the control type in the Window.
/// </summary>
/// <param name="type">Control type</param>
public static bool GetChildElement(ControlType type)
{
try
{
CommonHelperMethods.GetElement(AutomationElement.RootElement, type);
return true;
}
catch (ElementNotAvailableException ex)
{
Console.WriteLine(ex);
return false;
}
}
示例15: GetObjectHandle
private AutomationElement GetObjectHandle(string windowName,
string objName)
{
ControlType[] type = new ControlType[1] { ControlType.ScrollBar };
try
{
return utils.GetObjectHandle(windowName, objName, type);
}
finally
{
type = null;
}
}