/// <summary> /// Eine vorher Exportierte Xml Datei wieder in ein TreeView importieren /// </summary> /// <param name="path">Der Quellpfad der Xml Datei</param> /// <param name="treeView">Ein TreeView in dem der Inhalt der Xml Datei wieder angezeigt werden soll</param> /// <exception cref="FileNotFoundException">gibt an das die Datei nicht gefunden werden konnte</exception> public void XmlToTreeView(String path, TreeView treeView) { xmlDocument = new XmlDocument(); xmlDocument.Load(path); treeView.Nodes.Clear(); ElementList = new ArrayList(); TreeNode treeNode; treeNode = new TreeNode("skin"); treeView.Nodes.Add(treeNode); rootNode = treeNode.GetHashCode(); sElementList element = new sElementList(rootNode, 0, treeNode, xmlDocument.DocumentElement/*.ParentNode*/); ElementList.Add(element); XmlRekursivImport(treeNode.Nodes, xmlDocument.DocumentElement.ChildNodes); }
private void XmlRekursivImport(TreeNodeCollection elem, XmlNodeList xmlNodeList) { TreeNode treeNode; foreach (XmlNode myXmlNode in xmlNodeList) { //if (myXmlNode.Attributes != null) { if (myXmlNode.Name == "output" || myXmlNode.Name == "colors" || myXmlNode.Name == "fonts" || myXmlNode.Name == "windowstyle") continue; if(myXmlNode.Name == "#whitespace") continue; String name = myXmlNode.Name; if (myXmlNode.Attributes != null && myXmlNode.Attributes["name"] != null) name += " - " + myXmlNode.Attributes["name"].Value; String ext = XmlElementStringLookup(myXmlNode.Name); if (ext.Length > 0) { if (myXmlNode.Attributes != null && myXmlNode.Attributes[ext] != null) name += " : " + myXmlNode.Attributes[ext].Value; else name += " " + myXmlNode.Value; } treeNode = new TreeNode(name/*Attributes["value"].Value*/); if (myXmlNode.ChildNodes.Count > 0) { XmlRekursivImport(treeNode.Nodes, myXmlNode.ChildNodes); } elem.Add(treeNode); sElementList element = new sElementList(treeNode.GetHashCode(), treeNode.Parent.GetHashCode(), treeNode, myXmlNode); ElementList.Add(element); } } }
public TreeNode XmlSyncAddTreeChild(int hash, TreeNode elem, XmlNode node) { TreeNode treeNode = new TreeNode("new"/*Attributes["value"].Value*/); elem.Nodes.Add(treeNode); sElementList element = new sElementList(treeNode.GetHashCode(), treeNode.Parent.GetHashCode(), treeNode, node); ElementList.Add(element); return treeNode; }