예제 #1
0
        public IEnumerable <WiniumElement> Find(TreeScope scope, Predicate <FrameworkElement> predicate)
        {
            if (!Enum.IsDefined(typeof(TreeScope), scope))
            {
                throw new ArgumentException("One of TreeScope.Children or TreeScope.Descendants should be set");
            }

            // yield main visual tree
            if (predicate(this.VisualRoot.Element))
            {
                yield return(this.VisualRoot);
            }

            if (scope.HasFlag(TreeScope.Descendants))
            {
                foreach (var element in this.VisualRoot.Find(scope, predicate))
                {
                    yield return(element);
                }
            }

            // yield popups (AppBar, etc.)
            foreach (var popupChild in this.OpenPopups)
            {
                if (predicate(popupChild.Element))
                {
                    yield return(popupChild);
                }

                if (scope.HasFlag(TreeScope.Descendants))
                {
                    foreach (var popupElement in popupChild.Find(scope, predicate))
                    {
                        yield return(popupElement);
                    }
                }
            }
        }
        public IEnumerable<WiniumElement> Find(TreeScope scope, Predicate<FrameworkElement> predicate)
        {
            if (!Enum.IsDefined(typeof(TreeScope), scope))
            {
                throw new ArgumentException("One of TreeScope.Children or TreeScope.Descendants should be set");
            }

            // yield main visual tree
            if (predicate(this.VisualRoot.Element))
            {
                yield return this.VisualRoot;
            }

            if (scope.HasFlag(TreeScope.Descendants))
            {
                foreach (var element in this.VisualRoot.Find(scope, predicate))
                {
                    yield return element;
                }
            }

            // yield popups (AppBar, etc.)
            foreach (var popupChild in this.OpenPopups)
            {
                if (predicate(popupChild.Element))
                {
                    yield return popupChild;
                }

                if (scope.HasFlag(TreeScope.Descendants))
                {
                    foreach (var popupElement in popupChild.Find(scope, predicate))
                    {
                        yield return popupElement;
                    }
                }
            }
        }
        public IEnumerable<WiniumElement> Find(TreeScope scope, Predicate<FrameworkElement> predicate)
        {
            if (!Enum.IsDefined(typeof(TreeScope), scope))
            {
                throw new ArgumentException("One of TreeScope.Children or TreeScope.Descendants should be set");
            }

            foreach (var descendant in IterDescendants(this.Element, !scope.HasFlag(TreeScope.Descendants)))
            {
                if (predicate(descendant))
                {
                    yield return new WiniumElement(descendant);
                }
            }
        }
예제 #4
0
        public IEnumerable <WiniumElement> Find(TreeScope scope, Predicate <FrameworkElement> predicate)
        {
            if (!Enum.IsDefined(typeof(TreeScope), scope))
            {
                throw new ArgumentException("One of TreeScope.Children or TreeScope.Descendants should be set");
            }

            foreach (var descendant in IterDescendants(this.Element, !scope.HasFlag(TreeScope.Descendants)))
            {
                if (predicate(descendant))
                {
                    yield return(new WiniumElement(descendant));
                }
            }
        }