Пример #1
0
        /// <summary>
        ///     Adds an element as a child of this one, while updating its parent and oldparent field
        /// </summary>
        /// <param name="elem">The element in question</param>
        internal void AddChild(BrowserInternalElement elem)
        {

            elem.OldParent = elem.Parent;
            if (elem.Parent != null)
                elem.Parent.Items.Remove(elem);

            elem.Parent = this;
            this.Items.Add(elem);
        }
Пример #2
0
        /// <summary>
        ///     Adds an element as a child of this one, while updating its parent and oldparent field
        /// </summary>
        /// <param name="elem">The element in question</param>
        public void AddChild(BrowserInternalElement elem)
        {
            elem.OldParent = elem.Parent;
            if (elem.Parent != null)
            {
                elem.Parent.Items.Remove(elem);
            }

            elem.Parent = this;
            this.Items.Add(elem);
        }
Пример #3
0
        public void CanRemoveRootCategoryWithInternalElements()
        {
            var root = (BrowserRootElement)_search.TryAddRootCategory("Peter");
            var leafCat = new BrowserInternalElement("Boyer", root);
            root.Items.Add(leafCat);

            Assert.Contains( leafCat, root.Items );
            Assert.Contains(root, _search.BrowserRootCategories);

            _search.RemoveCategory("Peter");
            Assert.False(_search.BrowserRootCategories.Contains(root));
        }
Пример #4
0
        public void CanAddCategory()
        {
            var root = _search.TryAddRootCategory("Peter");
            var leafCat = new BrowserInternalElement("Boyer", root);
            root.Items.Add(leafCat);

            Assert.Contains( leafCat, root.Items );
            Assert.Contains(root, _search.BrowserRootCategories);
            
        }
Пример #5
0
            public void Execute(object parameters)
            {
                if (item is PackageManagerSearchElement)
                {
                    item.IsExpanded = !item.IsExpanded;
                    return;
                }

                if (item is SearchElementBase)
                {
                    ((SearchElementBase)item).Execute();
                    return;
                }
                var endState = !item.IsExpanded;

                if (item is BrowserInternalElement)
                {
                    BrowserInternalElement element = (BrowserInternalElement)item;
                    foreach (var ele in element.Siblings)
                    {
                        ele.IsExpanded = false;
                    }

                    //Walk down the tree expanding anything nested one layer deep
                    //this can be removed when we have the hierachy implemented properly
                    if (element.Items.Count == 1)
                    {
                        BrowserItem subElement = element.Items[0];

                        while (subElement.Items.Count == 1)
                        {
                            subElement.IsExpanded = true;
                            subElement            = subElement.Items[0];
                        }

                        subElement.IsExpanded = true;
                    }
                }

                if (item is BrowserRootElement)
                {
                    BrowserRootElement element = (BrowserRootElement)item;
                    foreach (var ele in element.Siblings)
                    {
                        ele.IsExpanded = false;
                    }


                    //Walk down the tree expanding anything nested one layer deep
                    //this can be removed when we have the hierachy implemented properly
                    if (element.Items.Count == 1)
                    {
                        BrowserItem subElement = element.Items[0];

                        while (subElement.Items.Count == 1)
                        {
                            subElement.IsExpanded = true;
                            subElement            = subElement.Items[0];
                        }

                        subElement.IsExpanded = true;
                    }
                }
                item.IsExpanded = endState;
            }