Ejemplo n.º 1
0
        public static IDictionary <int, List <VisualElement> > GetTabIndexesOnParentPage(this VisualElement element, out int countChildrensWithTabStopWithoutThis)
        {
            countChildrensWithTabStopWithoutThis = 0;

            Element parentPage = element.Parent;

            while (parentPage != null && !(parentPage is Page))
            {
                parentPage = parentPage.Parent;
            }

            var descendantsOnPage = parentPage?.VisibleDescendants();

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

            var childrensWithTabStop = new List <VisualElement>();

            foreach (var descendant in descendantsOnPage)
            {
                if (descendant is VisualElement visualElement && visualElement.IsTabStop)
                {
                    childrensWithTabStop.Add(visualElement);
                }
            }
            if (!childrensWithTabStop.Contains(element))
            {
                return(null);
            }

            countChildrensWithTabStopWithoutThis = childrensWithTabStop.Count - 1;
            return(childrensWithTabStop.GroupToDictionary(c => c.TabIndex));
        }
Ejemplo n.º 2
0
        public static IDictionary <int, List <ITabStopElement> > GetTabIndexesOnParentPage(this ITabStopElement element, out int countChildrensWithTabStopWithoutThis, bool checkContainsElement = true)
        {
            countChildrensWithTabStopWithoutThis = 0;

            Element parentPage = (element as Element)?.Parent;

            while (parentPage != null && !(parentPage is Page))
            {
                parentPage = parentPage.Parent;
            }

            var descendantsOnPage = parentPage?.VisibleDescendants();

            if (parentPage is Shell shell)
            {
                descendantsOnPage = shell.Items;
            }

            if (descendantsOnPage == null)
            {
                return(new Dictionary <int, List <ITabStopElement> >());
            }

            var childrensWithTabStop = new List <ITabStopElement>();

            foreach (var descendant in descendantsOnPage)
            {
                if (descendant is ITabStopElement visualElement && visualElement.IsTabStop)
                {
                    if (descendant is TableView tableView)
                    {
                        foreach (var child in tableView.AllChildren)
                        {
                            if (child is ITabStopElement childElement && childElement.IsTabStop)
                            {
                                childrensWithTabStop.Add(childElement);
                            }
                        }
                    }

                    childrensWithTabStop.Add(visualElement);
                }
            }

            if (checkContainsElement && !childrensWithTabStop.Contains(element))
            {
                return(new Dictionary <int, List <ITabStopElement> >());
            }

            countChildrensWithTabStopWithoutThis = childrensWithTabStop.Count - 1;
            return(childrensWithTabStop.GroupToDictionary(c => c.TabIndex));
        }
Ejemplo n.º 3
0
        public static IDictionary <int, List <ITabStopElement> > GetTabIndexesOnParentPage(this ITabStopElement element, out int countChildrenWithTabStopWithoutThis)
        {
            var empty = new Dictionary <int, List <ITabStopElement> >();

            countChildrenWithTabStopWithoutThis = 0;

            Element parentPage = (element as Element)?.Parent;

            while (parentPage != null && !(parentPage is Page))
            {
                parentPage = parentPage.Parent;
            }

            var descendantsOnPage = parentPage?.VisibleDescendants();

            if (parentPage is IShellController shell)
            {
                descendantsOnPage = shell.GetItems();
            }

            if (descendantsOnPage == null)
            {
                return(empty);
            }

            var childrenWithTabStop = new List <ITabStopElement>();

            foreach (var descendant in descendantsOnPage)
            {
                if (descendant is ITabStopElement visualElement && IsTabStop(descendant))
                {
                    childrenWithTabStop.Add(visualElement);
                }
            }

            countChildrenWithTabStopWithoutThis = childrenWithTabStop.Count - 1;
            return(childrenWithTabStop.GroupToDictionary(c => c.TabIndex));
        }