Esempio n. 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);
            }
        }
Esempio n. 2
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);
     }
 }
Esempio n. 3
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);
     }
 }