Exemple #1
0
        public static IUiElement PerformNavigateToFirstChild(this IUiElement element)
        {
            IUiElement result = null;

            var walker = new classic.TreeWalker(classic.Condition.TrueCondition);

            try {
                result = AutomationFactory.GetUiElement(walker.GetFirstChild(element.GetSourceElement() as classic.AutomationElement));
            } catch {
            }

            return(result);
        }
        public static IUiElement PerformNavigateToFirstChild(this IUiElement element)
        {
            IUiElement result = null;

            var walker = new classic.TreeWalker(classic.Condition.TrueCondition);

            try {
                result = AutomationFactory.GetUiElement(walker.GetFirstChild(element.GetSourceElement() as classic.AutomationElement));
            } catch {
            }

            return result;
        }
        protected void GetAutomationElementsChildren(IUiElement inputObject, bool firstChild)
        {
            if (!CheckAndPrepareInput(this))
            {
                return;
            }

            var walker =
                new classic.TreeWalker(
                    classic.Condition.TrueCondition);

            IUiElement sibling =
                firstChild ?
                AutomationFactory.GetUiElement(walker.GetFirstChild(inputObject.GetSourceElement() as classic.AutomationElement)) :
                AutomationFactory.GetUiElement(walker.GetLastChild(inputObject.GetSourceElement() as classic.AutomationElement));

            WriteObject(this, sibling);
        }
 protected void GetAutomationElementsChildren(IUiElement inputObject, bool firstChild)
 {
     if (!CheckAndPrepareInput(this)) { return; }
     
     var walker = 
         new classic.TreeWalker(
             classic.Condition.TrueCondition);
     
     IUiElement sibling =
         firstChild ?
             AutomationFactory.GetUiElement(walker.GetFirstChild(inputObject.GetSourceElement() as classic.AutomationElement)) :
                 AutomationFactory.GetUiElement(walker.GetLastChild(inputObject.GetSourceElement() as classic.AutomationElement));
     
     WriteObject(this, sibling);
 }
        private List<IUiElement> GetAutomationElementsWithWalker(
            IUiElement element,
            string name,
            string automationId,
            string className,
            string[] controlType,
            bool caseSensitive,
            bool onlyOneResult,
            bool onlyTopLevel)
        {
            var resultCollection = new List<IUiElement>();
            
            var walker = 
                new classic.TreeWalker(
                    classic.Condition.TrueCondition);
            
            try {
                
                IUiElement oneMoreElement = AutomationFactory.GetUiElement(walker.GetFirstChild(element.GetSourceElement() as classic.AutomationElement));
                
                resultCollection = ProcessAutomationElement(
                        oneMoreElement,
                        name,
                        automationId,
                        className,
                        controlType,
                        caseSensitive,
                        onlyOneResult,
                        onlyTopLevel);

                if ((onlyTopLevel || onlyOneResult) && (null != resultCollection) && resultCollection.Count > 0) {

                    return resultCollection;

                } else if (null != resultCollection) {

                    WriteObject(this, resultCollection);
                }
                
                while (oneMoreElement != null) {
                    
                    oneMoreElement = AutomationFactory.GetUiElement(walker.GetNextSibling(oneMoreElement.GetSourceElement() as classic.AutomationElement));
                    
                    resultCollection = ProcessAutomationElement(
                        oneMoreElement,
                        name,
                        automationId,
                        className,
                        controlType,
                        caseSensitive,
                        onlyOneResult,
                        onlyTopLevel);

                    if ((onlyTopLevel || onlyOneResult) && (null != resultCollection) && resultCollection.Count > 0) {

                        return resultCollection;

                    } else if (null != resultCollection) {

                        WriteObject(this, resultCollection);
                    }
                }
            }
            catch {}
            
            walker = null;
            
            return resultCollection;
        }
        private List <IUiElement> GetAutomationElementsWithWalker(
            IUiElement element,
            string name,
            string automationId,
            string className,
            string[] controlType,
            bool caseSensitive,
            bool onlyOneResult,
            bool onlyTopLevel)
        {
            var resultCollection = new List <IUiElement>();

            var walker =
                new classic.TreeWalker(
                    classic.Condition.TrueCondition);

            try {
                IUiElement oneMoreElement = AutomationFactory.GetUiElement(walker.GetFirstChild(element.GetSourceElement() as classic.AutomationElement));

                resultCollection = ProcessAutomationElement(
                    oneMoreElement,
                    name,
                    automationId,
                    className,
                    controlType,
                    caseSensitive,
                    onlyOneResult,
                    onlyTopLevel);

                if ((onlyTopLevel || onlyOneResult) && (null != resultCollection) && resultCollection.Count > 0)
                {
                    return(resultCollection);
                }
                else if (null != resultCollection)
                {
                    WriteObject(this, resultCollection);
                }

                while (oneMoreElement != null)
                {
                    oneMoreElement = AutomationFactory.GetUiElement(walker.GetNextSibling(oneMoreElement.GetSourceElement() as classic.AutomationElement));

                    resultCollection = ProcessAutomationElement(
                        oneMoreElement,
                        name,
                        automationId,
                        className,
                        controlType,
                        caseSensitive,
                        onlyOneResult,
                        onlyTopLevel);

                    if ((onlyTopLevel || onlyOneResult) && (null != resultCollection) && resultCollection.Count > 0)
                    {
                        return(resultCollection);
                    }
                    else if (null != resultCollection)
                    {
                        WriteObject(this, resultCollection);
                    }
                }
            }
            catch {}

            walker = null;

            return(resultCollection);
        }