Exemple #1
0
        /// <summary>
        /// Explicitly loads/reloads tree contents
        /// </summary>
        public override void LoadTree()
        {
            try
            {
                this.rootCategory = this.DataBase.RootCategory;

                if (null == this.rootCategory)
                {
                    return;
                }

                this.rootCat = new TreeNodeCategory(this.DataBase, rootCategory, this);
                this.rootCat.LoadTreeNodeChilds();

                this.SelectedNode = this.rootCat;
            }
            catch (Exception ex)
            {
                ErrorMessenger.ErrorMessage(this, "Error occured while loading data", ex);
            }

            FillList();
        }
Exemple #2
0
        private bool TryDragCategory(DragEventArgs e, TreeNodeCategory c)
        {
            object fromObj = e.Data.GetData(typeof (TreeNodeCategory));

            if (null == fromObj)
            {
                return false;
            }

            if (fromObj == c)
            {
                return false;
            }

            TreeNodeCategory dragedCat = (TreeNodeCategory) fromObj;

            try
            {
                dragedCat.InternalCategory.Parent = c.InternalCategory;
            }
            catch (Exception ex)
            {
                ErrorMessenger.ErrorMessage(null, "Category can not be moved here", ex);

                return false;
            }

            return true;
        }
Exemple #3
0
        private bool TryDragBox(DragEventArgs e, TreeNodeCategory c)
        {
            object fromObj = e.Data.GetData(typeof (TreeNodeBox));

            if (null == fromObj)
            {
                return false;
            }

            if (fromObj == c)
            {
                return false;
            }

            TreeNodeBox dragedBox = (TreeNodeBox) fromObj;
            dragedBox.InternalBox.Parent = c.InternalCategory;

            return true;
        }
Exemple #4
0
        private void DragToCategory(DragEventArgs e, TreeNodeCategory c)
        {
            if (true == TryDragCategory(e, c))
            {
                return;
            }

            if (true == TryDragBox(e, c))
            {
                return;
            }
        }
Exemple #5
0
        /// <summary>
        /// Causes tree node to get its child nodes
        /// </summary>
        public override void LoadTreeNodeChilds()
        {
            if (true == this.nodesLoaded)
            {
                return;
            }

            if (true == this.cat.IsRoot)
            {
                this.trv.Nodes.Clear();
            }
            else
            {
                this.Nodes.Clear();
            }

            var lst = this.cat.ChildCategories;

            if (null != lst)
            {
                foreach (DataBase.Category c in lst)
                {
                    if (false == c.IsDeleted)
                    {
                        TreeNodeCategory cc = new TreeNodeCategory(this.db, c, this.trv);

                        if (true == this.cat.IsRoot)
                        {
                            this.trv.Nodes.Add(cc);
                        }
                        else
                        {
                            this.Nodes.Add(cc);
                        }
                    }
                }
            }

            var childBoxes = this.cat.ChildCDBoxes;

            if (null != lst)
            {
                foreach (DataBase.Box r in childBoxes)
                {
                    if (false == r.IsDeleted)
                    {
                        TreeNodeBox b = new TreeNodeBox(this.db, r, this.trv);

                        if (true == this.cat.IsRoot)
                        {
                            this.trv.Nodes.Add(b);
                        }
                        else
                        {
                            this.Nodes.Add(b);
                        }
                    }
                }
            }

            this.nodesLoaded = true;
        }
Exemple #6
0
        private TreeNodeCategory GetCategory(TreeNodeCategory parent, long id)
        {
            if (parent.InternalCategory.Id == id)
            {
                return parent;
            }

            foreach (TreeNode tn in parent.ChildNodes)
            {
                if (tn is TreeNodeCategory)
                {
                    TreeNodeCategory tnc = GetCategory((TreeNodeCategory)tn, id);

                    if (null != tnc)
                    {
                        return tnc;
                    }
                }
            }

            return null;
        }