Ejemplo n.º 1
0
 private void btn_Click(object sender, EventArgs e)
 {
     try
     {
         Button btn = sender as Button;
         if (null == btn)
         {
             return;
         }
         DocTreeNode docNode = btn.Tag as DocTreeNode;
         if (null == docNode)
         {
             return;
         }
         if (docNode.IsBranch)
         {
             if (null != BranchSelected)
             {
                 BranchSelected(this, new DocumentTreeViewEventArgs(docNode));
             }
         }
         else
         {
             if (null != LeafSelected)
             {
                 LeafSelected(this, new DocumentTreeViewEventArgs(docNode));
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
         Logger.Write(ex.ToString(), Category.General, Priority.High);
     }
 }
Ejemplo n.º 2
0
        public void SelectNode(DocTreeNode docNode)
        {
            TreeNode node = FindByDocTreeNode(Nodes, docNode);

            SelectedNode = node;
            SelectedNode.EnsureVisible();
        }
Ejemplo n.º 3
0
        private DocTreeNode BuildTree(DirectoryInfo directory)
        {
            if (null == directory)
            {
                return(null);
            }
            DocTreeNode root = new DocTreeNode(config.GetDocPath(), directory);

            foreach (var file in directory.GetFileSystemInfos().OrderBy(i => i.Name, new FileNameComparer()))
            {
                if (file is FileInfo)
                {
                    root.AppendNode(new DocTreeNode(config.GetDocPath(), file));
                }
                else
                {
                    var dnode = BuildTree((DirectoryInfo)file);
                    if (null != dnode)
                    {
                        root.AppendNode(dnode);
                    }
                }
            }
            return(root);
        }
Ejemplo n.º 4
0
 void DocumentTreeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     try
     {
         LoadChildrens(e.Node);
         DocTreeNode node = e.Node.Tag as DocTreeNode;
         if (null == node)
         {
             return;
         }
         if (node.IsBranch && null != BranchSelected)
         {
             BranchSelected(this, new DocumentTreeViewEventArgs(node));
         }
         else if (node.IsLeaf && null != LeafSelected)
         {
             LeafSelected(this, new DocumentTreeViewEventArgs(node));
         }
     }
     catch (Pic.Data.DataException ex)
     {
         Debug.Fail(ex.ToString());
         Logger.Write(ex.ToString(), Category.General, Priority.High);
     }
     catch (System.Exception ex)
     {
         Debug.Fail(ex.ToString());
         Logger.Write(ex.ToString(), Category.General, Priority.High);
     }
 }
        ///-------------------------------------------------------------------------------------------------
        /// <summary> Documentation. </summary>
        /// <returns> Documentation in a DocTreeNode. </returns>
        ///-------------------------------------------------------------------------------------------------

        public override DocTreeNode Documentation()
        {
            DocTreeNode node = base.Documentation();

            node.AddChildField("FMaxUnassuredYears", FMaxUnassuredYears.ToString());
            return(node);
        }
        public override DocTreeNode Documentation()
        {
            DocTreeNode node = base.Documentation();

            node.AddChildField("FMaxDifference", FMaxDifference.ToString());
            node.AddChildField("FMinGPCD", FMinGPCD.ToString());
            return(node);
        }
        ///-------------------------------------------------------------------------------------------------
        /// <summary> Documentation. </summary>
        /// <returns> Documentation in a DocTreeNode. </returns>
        ///-------------------------------------------------------------------------------------------------

        public override DocTreeNode Documentation()
        {
            DocTreeNode node = base.Documentation();

            node.AddChildField("FMaxDeficit", FMaxDeficit.ToString());
            node.AddChildField("FMaxCreditDeficit", FMaxCreditDeficit.ToString());
            return(node);
        }
        ///-------------------------------------------------------------------------------------------------
        /// <summary> Documentation. </summary>
        /// <returns> Documentation in a DocTreeNode. </returns>
        ///-------------------------------------------------------------------------------------------------

        public override DocTreeNode Documentation()
        {
            DocTreeNode node = base.Documentation();

            node.AddChildField("FMaxAWS", FMaxAWS.ToString());
            node.AddChildField("FMinGPCD", FMinGPCD.ToString());
            node.AddChildField("FAnnualPercentDecline", FMinGPCD.ToString());
            return(node);
        }
Ejemplo n.º 9
0
 protected int GetSelectedImageIndex(DocTreeNode docNode)
 {
     if (docNode.IsBranch)
     {
         return(1);
     }
     if (docNode.IsLeaf)
     {
         return(2);
     }
     else
     {
         throw new Exception("Unexpected document node type");
     }
 }
Ejemplo n.º 10
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();
        }
Ejemplo n.º 11
0
        protected TreeNode FindByDocTreeNode(TreeNodeCollection nodeCollection, DocTreeNode docNode)
        {
            foreach (TreeNode node in nodeCollection)
            {
                DocTreeNode current = node.Tag as DocTreeNode;
                if (docNode == current)
                {
                    return(node);
                }
            }
            TreeNode parentNode = FindByDocTreeNode(nodeCollection, docNode.Parent);

            if (null != parentNode)
            {
                LoadChildrens(parentNode);
                return(FindByDocTreeNode(parentNode.Nodes, docNode));
            }
            return(null);
        }
Ejemplo n.º 12
0
        protected void LoadChildrens(TreeNode tn)
        {
            DocTreeNodeBranch docNodeBranch = tn.Tag as DocTreeNodeBranch;

            if (null == docNodeBranch)
            {
                return;
            }
            List <DocTreeNode> childNodes = docNodeBranch.childrens;

            foreach (DocTreeNode docNode in childNodes)
            {
                // check if node already inserted
                bool found = false;
                foreach (TreeNode tnChild in tn.Nodes)
                {
                    DocTreeNode docNodeChild = tnChild.Tag as DocTreeNode;
                    if (docNodeChild.Id == docNode.Id)
                    {
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    continue;
                }
                // insert new node
                TreeNode tnNew = new TreeNode(docNode.Name, GetImageIndex(docNode), GetSelectedImageIndex(docNode));
                tn.Nodes.Add(tnNew);
                if (docNode.IsBranch)
                {
                    tnNew.ContextMenuStrip = GetBranchMenu();
                }
                else if (docNode.IsLeaf)
                {
                    tnNew.ContextMenuStrip = GetLeafMenu();
                }
                tnNew.Tag = docNode;
            }
        }
Ejemplo n.º 13
0
 private void  deleteNode(object sender, EventArgs e)
 {
     try
     {
         // get current tree node
         TreeNode tnNode = GetCurrentTreeNode();
         // clear parent node childrens
         DocTreeNodeBranch parentBranch = tnNode.Parent.Tag as DocTreeNodeBranch;
         parentBranch.ClearChildrens();
         // remove DocumentTreeNode
         DocTreeNode docTreeNode = tnNode.Tag as DocTreeNode;
         docTreeNode.delete();
         // remove tree node
         tnNode.Remove();
     }
     catch (Exception ex)
     {
         Debug.Fail(ex.ToString());
         Logger.Write(ex.ToString(), Category.General, Priority.Highest);
     }
 }
Ejemplo n.º 14
0
 public void SelectNode(DocTreeNode docNode)
 {
     TreeNode node = FindByDocTreeNode(Nodes, docNode);
     SelectedNode = node;
     SelectedNode.EnsureVisible();
 }
Ejemplo n.º 15
0
 protected int GetSelectedImageIndex(DocTreeNode docNode)
 {
     if (docNode.IsBranch) return 1;
     if (docNode.IsLeaf) return 2;
     else throw new Exception("Unexpected document node type");
 }
Ejemplo n.º 16
0
 public DocumentTreeViewEventArgs(DocTreeNode docNode)
 {
     _docNode = docNode;
 }
Ejemplo n.º 17
0
 public DocumentTreeViewEventArgs(DocTreeNode docNode)
 {
     _docNode = docNode;
 }
Ejemplo n.º 18
0
 protected TreeNode FindByDocTreeNode(TreeNodeCollection nodeCollection, DocTreeNode docNode)
 {
     foreach (TreeNode node in nodeCollection)
     {
         DocTreeNode current = node.Tag as DocTreeNode;
         if (docNode == current)
             return node;
     }
     TreeNode parentNode = FindByDocTreeNode(nodeCollection, docNode.Parent);
     if (null != parentNode)
     {
        LoadChildrens(parentNode);
        return FindByDocTreeNode(parentNode.Nodes, docNode);
     }
     return null;
 }