示例#1
0
        private void  insertNewBranchLabel_Click(object sender, EventArgs e)
        {
            try
            {
                // get current tree node
                TreeNode          tnNode      = GetCurrentTreeNode();
                DocTreeNodeBranch docTreeNode = tnNode.Tag as DocTreeNodeBranch;
                if (null == docTreeNode)
                {
                    return;
                }

                // show dialog
                FormCreateBranch dlg = new FormCreateBranch();
                if (DialogResult.OK == dlg.ShowDialog())
                {
                    // create new branch
                    docTreeNode.AddChildBranch(dlg.BranchName, dlg.BranchDescription, dlg.BranchImage);

                    // refresh tree
                    RefreshTree();
                    SelectedNode = GetCurrentTreeNode();
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                Logger.Write(ex.ToString(), Category.General, Priority.Highest);
            }
        }
示例#2
0
        public void RefreshTree()
        {
            // turn off visual updating
            BeginUpdate();
            // clear tree
            Nodes.Clear();
            try
            {
                // insert root nodes
                List <DocTreeNode> rootNodes = DocTreeNode.getRootNodes();
                if (0 == rootNodes.Count)
                {
                    FormCreateBranch form = new FormCreateBranch();
                    if (DialogResult.OK == form.ShowDialog())
                    {
                        DocTreeNodeBranch.AddNewRootNode(form.BranchName, form.BranchDescription, form.BranchImage);
                        rootNodes = DocTreeNode.getRootNodes();
                    }
                    else
                    {
                        return;
                    }
                }

                foreach (DocTreeNode docNode in rootNodes)
                {
                    TreeNode tnRoot = new TreeNode(docNode.Name, GetImageIndex(docNode), GetSelectedImageIndex(docNode));
                    Nodes.Add(tnRoot);
                    if (docNode.IsBranch)
                    {
                        // add menu
                        tnRoot.ContextMenuStrip = GetBranchMenu();
                    }

                    tnRoot.Tag = docNode;
                    LoadChildrens(tnRoot);
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                Logger.Write(ex.ToString(), Category.General, Priority.High);
            }

            // turn on visual updating
            EndUpdate();
        }
        public void RefreshTree()
        { 
            // turn off visual updating
            BeginUpdate();
            // clear tree
            Nodes.Clear();
            try
            {
                // insert root nodes
                List<DocTreeNode> rootNodes = DocTreeNode.getRootNodes();
                if (0 == rootNodes.Count)
                {
                    FormCreateBranch form = new FormCreateBranch();
                    if (DialogResult.OK == form.ShowDialog())
                    {
                        DocTreeNodeBranch.AddNewRootNode(form.BranchName, form.BranchDescription, form.BranchImage);
                        rootNodes = DocTreeNode.getRootNodes();
                    }
                    else
                        return;
                }

                foreach (DocTreeNode docNode in rootNodes)
                { 
                    TreeNode tnRoot = new TreeNode(docNode.Name, GetImageIndex(docNode), GetSelectedImageIndex(docNode) );
                    Nodes.Add(tnRoot);
                    if (docNode.IsBranch)
                    {
                        // add menu
                        tnRoot.ContextMenuStrip = GetBranchMenu();
                    }

                    tnRoot.Tag = docNode;
                    LoadChildrens(tnRoot);
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                Logger.Write(ex.ToString(), Category.General, Priority.High);
            }
            
            // turn on visual updating
            EndUpdate();
        }
        private void  insertNewBranchLabel_Click(object sender, EventArgs e)
        {
            try
            {
                // get current tree node
                TreeNode tnNode = GetCurrentTreeNode();
                DocTreeNodeBranch docTreeNode = tnNode.Tag as DocTreeNodeBranch;
                if (null == docTreeNode) return;

                // show dialog
                FormCreateBranch dlg = new FormCreateBranch();
                if (DialogResult.OK == dlg.ShowDialog())
                {
                    // create new branch
                    docTreeNode.AddChildBranch( dlg.BranchName, dlg.BranchDescription, dlg.BranchImage);

                    // refresh tree
                    RefreshTree();
                    SelectedNode = GetCurrentTreeNode();
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                Logger.Write(ex.ToString(), Category.General, Priority.Highest);
            }
        }