当前位置: 首页>>代码示例>>C#>>正文


C# Automation.ControlType类代码示例

本文整理汇总了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;
        }
开发者ID:GraemeF,项目名称:Fluid,代码行数:7,代码来源:AutomationExtensions.cs

示例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);
 }
开发者ID:brogersyh,项目名称:.NET-WindowsUI-AutomationElementsTest,代码行数:16,代码来源:UIAUtility.cs

示例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));
                */
            }
            
        }
开发者ID:MatkoHanus,项目名称:STUPS,代码行数:60,代码来源:SearchByContainsTextViaUiaTextFixture.cs

示例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;
 }
开发者ID:NeilRobbins,项目名称:Silverlight.Driver,代码行数:7,代码来源:AutomationElementExtensions.cs

示例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;
        }
开发者ID:xia-sava,项目名称:PVCtrl,代码行数:9,代码来源:PvCtrlUtil.cs

示例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;
 }
开发者ID:softek,项目名称:WinUIScraper,代码行数:9,代码来源:AutomationExtensions.cs

示例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);
        }
开发者ID:tankxiao,项目名称:tankproject,代码行数:10,代码来源:AutomationBuild.cs

示例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);
        }
开发者ID:tankxiao,项目名称:tankproject,代码行数:10,代码来源:AutomationBuild.cs

示例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);
        }
开发者ID:mkolisnyk,项目名称:Sirius,代码行数:10,代码来源:CustomConditions.cs

示例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);
        }
开发者ID:tankxiao,项目名称:tankproject,代码行数:10,代码来源:AutomationBuild.cs

示例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;
 }
开发者ID:modulexcite,项目名称:Tx,代码行数:10,代码来源:AutomationElementExtensions.cs

示例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;
 }
开发者ID:tmandersson,项目名称:FastGTD,代码行数:12,代码来源:ControlDictionaryItem.cs

示例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;
 }
开发者ID:boomuuh,项目名称:cobra-winldtp,代码行数:52,代码来源:Text.cs

示例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;
     }
 }
开发者ID:hxhlb,项目名称:wwt-tile-sdk,代码行数:17,代码来源:SharingServiceTestCases.cs

示例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;
     }
 }
开发者ID:boomuuh,项目名称:cobra-winldtp,代码行数:13,代码来源:Scrollbar.cs


注:本文中的System.Windows.Automation.ControlType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。