Example #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);
            }
        }
Example #2
0
        public void ShowBranch(DocTreeNodeBranch branch)
        {
            Controls.Clear();
            tooltip.RemoveAll();

            try
            {
                _listDocumentNodes = branch.childrens;
            }
            catch (Exception /*ex*/)
            {
            }
            i = x = y = 0;
            timer.Start();
        }
        public void ShowBranch(DocTreeNodeBranch branch)
        {
            Controls.Clear();
            tooltip.RemoveAll();

            try
            {
                _listDocumentNodes = branch.childrens;
            }
            catch (Exception /*ex*/)
            {
            }
            i = x = y = 0;
            timer.Start();
        }
Example #4
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();
        }
Example #5
0
 static private void ProcessNode(XmlNode node, string offset, DocTreeNodeBranch parentBranch)
 {
     if ("xml" == node.Name)
     {   // parent node -> do nothing
     }
     else if ("Branch" == node.Name)
     {
         // create new branch
         string name = node.Attributes["Name"].Value;
         Console.WriteLine(offset + string.Format("Branch : {0}", name));
         string            description = node.Attributes["Description"].Value;
         string            bmpFileName = node.Attributes["BmpFileName"].Value;
         string            filePath    = bmpFileName.Length == 0 ? string.Empty : Path.Combine(_dstDirectory, bmpFileName);
         DocTreeNodeBranch newBranch   = null;
         if (null == parentBranch)
         {
             newBranch = DocTreeNodeBranch.AddNewRootNode(name, description, filePath);
         }
         else
         {
             newBranch = parentBranch.AddChildBranch(name, description, filePath);
         }
         // recursively create child nodes
         foreach (XmlNode childNode in node.ChildNodes)
         {
             try
             {
                 ProcessNode(childNode, offset + "    ", newBranch);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.ToString());
             }
         }
     }
     else if ("Leaf" == node.Name)
     {
         // create new leaf
         string name = node.Attributes["Name"].Value;
         Console.WriteLine(offset + string.Format("Leaf : {0}", name));
         string   description   = node.Attributes["Description"].Value;
         string   filePath      = Path.Combine(_dstDirectory, node.Attributes["FileName"].Value);
         Document childDocument = Document.create(DocumentType.getByName("ParametricComponent"), name, description, filePath);
         parentBranch.AddChildDocument(childDocument);
     }
 }
Example #6
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;
            }
        }
Example #7
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);
     }
 }
Example #8
0
        private void  insertNewDocumentLabel_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
                FormCreateDocument dlg = new FormCreateDocument();
                if (DialogResult.OK == dlg.ShowDialog())
                {
                    // create new document
                    Document doc = ParametricComponent.create(
                        dlg.DocumentName
                        , dlg.DocumentDescription
                        , dlg.FilePath
                        , dlg.ComponentGuid);
                    // create associated majorations
                    MajorationList.create(doc, dlg.Profile, dlg.Majorations);

                    // add child document node
                    docTreeNode.AddChildDocument(doc);

                    // Refresh tree
                    RefreshTree();
                    SelectedNode = GetCurrentTreeNode();
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                Logger.Write(ex.ToString(), Category.General, Priority.Highest);
            }
        }
Example #9
0
 static private void ProcessNode(XmlNode node, string offset, DocTreeNodeBranch parentBranch)
 {
     if ("xml" == node.Name)
     {   // parent node -> do nothing
     }
     else if ("Branch" == node.Name)
     {
         // create new branch
         string name = node.Attributes["Name"].Value;
         Console.WriteLine( offset + string.Format("Branch : {0}", name));
         string description = node.Attributes["Description"].Value;
         string bmpFileName = node.Attributes["BmpFileName"].Value;
         string filePath = bmpFileName.Length == 0 ? string.Empty : Path.Combine(_dstDirectory, bmpFileName);
         DocTreeNodeBranch newBranch = null;
         if (null == parentBranch)
             newBranch = DocTreeNodeBranch.AddNewRootNode(name, description, filePath);
         else
             newBranch = parentBranch.AddChildBranch(name, description, filePath);
         // recursively create child nodes
         foreach (XmlNode childNode in node.ChildNodes)
         {
             try
             {
                 ProcessNode(childNode, offset + "    ", newBranch);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.ToString());
             }
         }
     }
     else if ("Leaf" == node.Name)
     {
         // create new leaf
         string name = node.Attributes["Name"].Value;
         Console.WriteLine(offset + string.Format("Leaf : {0}", name));
         string description = node.Attributes["Description"].Value;
         string filePath = Path.Combine( _dstDirectory, node.Attributes["FileName"].Value );
         Document childDocument = Document.create(DocumentType.getByName("ParametricComponent"), name, description, filePath);
         parentBranch.AddChildDocument(childDocument);
     }
 }