public ITreeWalker GetCustomTreeWalker(ConditionBase condition)
        {
            var nativeCondition  = condition.ToNative(this.automation.NativeAutomation);
            var nativeTreeWalker = this.automation.NativeAutomation.CreateTreeWalker(nativeCondition);

            return(new UIA3TreeWalker(this.automation, nativeTreeWalker));
        }
        public override AutomationElement FindFirst(TreeScope treeScope, ConditionBase condition)
        {
            var nativeElement = this.FindFirstNative(
                treeScope,
                condition.ToNative(this.Automation.NativeAutomation));

            return(AutomationElementConverter.NativeToManaged(this.Automation, nativeElement));
        }
        public override T FindFirst <T>(TreeScope treeScope, ConditionBase condition, Func <BasicAutomationElementBase, T> wrap)
        {
            var nativeElement = this.FindFirstNative(
                treeScope,
                condition.ToNative(this.Automation.NativeAutomation));

            if (nativeElement == null)
            {
                return(null);
            }

            var basicElement = new UIA3BasicAutomationElement(this.Automation, nativeElement);

            return(wrap(basicElement));
        }
        public override IReadOnlyList <T> FindAll <T>(TreeScope treeScope, ConditionBase condition, Func <BasicAutomationElementBase, T> wrap)
        {
            var nativeFoundElements = CacheRequest.IsCachingActive
                ? this.NativeElement.FindAllBuildCache((Interop.UIAutomationClient.TreeScope)treeScope, condition.ToNative(this.Automation.NativeAutomation), CacheRequest.Current.ToNative(this.Automation))
                : this.NativeElement.FindAll((Interop.UIAutomationClient.TreeScope)treeScope, condition.ToNative(this.Automation.NativeAutomation));
            var result = new T[nativeFoundElements.Length];

            for (var i = 0; i < nativeFoundElements.Length; i++)
            {
                var nativeElement = nativeFoundElements.GetElement(i);
                var basicElement  = new UIA3BasicAutomationElement(this.Automation, nativeElement);
                result[i] = wrap(basicElement);
            }

            return(result);
        }
        public override IReadOnlyList <AutomationElement> FindAll(TreeScope treeScope, ConditionBase condition)
        {
            var nativeFoundElements = CacheRequest.IsCachingActive
                ? this.NativeElement.FindAllBuildCache((Interop.UIAutomationClient.TreeScope)treeScope, condition.ToNative(this.Automation.NativeAutomation), CacheRequest.Current.ToNative(this.Automation))
                : this.NativeElement.FindAll((Interop.UIAutomationClient.TreeScope)treeScope, condition.ToNative(this.Automation.NativeAutomation));

            return(AutomationElementConverter.NativeArrayToManaged(this.Automation, nativeFoundElements));
        }
        public override T FindIndexed <T>(TreeScope treeScope, ConditionBase condition, int index, Func <BasicAutomationElementBase, T> wrap)
        {
            var nativeFoundElements = CacheRequest.IsCachingActive
                ? this.NativeElement.FindAllBuildCache((Interop.UIAutomationClient.TreeScope)treeScope, condition.ToNative(this.Automation.NativeAutomation), CacheRequest.Current.ToNative(this.Automation))
                : this.NativeElement.FindAll((Interop.UIAutomationClient.TreeScope)treeScope, condition.ToNative(this.Automation.NativeAutomation));

            if (nativeFoundElements == null ||
                index >= nativeFoundElements.Length)
            {
                return(null);
            }

            var nativeElement = nativeFoundElements.GetElement(index);

            if (nativeElement == null)
            {
                return(null);
            }

            var basicElement = new UIA3BasicAutomationElement(this.Automation, nativeElement);

            return(wrap(basicElement));
        }
        public override AutomationElement FindIndexed(TreeScope treeScope, ConditionBase condition, int index)
        {
            var nativeFoundElements = CacheRequest.IsCachingActive
                ? this.NativeElement.FindAllBuildCache((Interop.UIAutomationClient.TreeScope)treeScope, condition.ToNative(this.Automation.NativeAutomation), CacheRequest.Current.ToNative(this.Automation))
                : this.NativeElement.FindAll((Interop.UIAutomationClient.TreeScope)treeScope, condition.ToNative(this.Automation.NativeAutomation));
            var nativeElement = nativeFoundElements.GetElement(index);

            if (nativeElement == null)
            {
                return(null);
            }

            return(AutomationElementConverter.NativeToManaged(this.Automation, nativeElement));
        }