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); } }
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); } }
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); } }