You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
3.3 KiB
105 lines
3.3 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using OnDoc.Klassen;
|
|
using Syncfusion.Windows.Forms.Grid;
|
|
using Syncfusion.Windows.Forms.Tools;
|
|
using Syncfusion.WinForms.Controls;
|
|
using System.Xml;
|
|
using System.IO;
|
|
|
|
namespace OnDoc.Diverses
|
|
{
|
|
public partial class NativVorlagen : SfForm
|
|
{
|
|
public NativVorlagen()
|
|
{
|
|
InitializeComponent();
|
|
this.Style.TitleBar.BackColor = Theaming.Titelbar();
|
|
this.Style.TitleBar.ForeColor = Theaming.TitelFontColor();
|
|
}
|
|
|
|
private void NativVorlagen_Load(object sender, EventArgs e)
|
|
{
|
|
XmlDocument xDoc = new XmlDocument();
|
|
xDoc.Load(@"E:\Software-Projekte\OnDoc\Nativ\treeview.xml");
|
|
treeViewAdv1.Nodes.Clear();
|
|
treeViewAdv1.Nodes.Add(new
|
|
TreeNodeAdv(xDoc.DocumentElement.Name));
|
|
TreeNodeAdv tNode = new TreeNodeAdv();
|
|
tNode = (TreeNodeAdv)treeViewAdv1.Nodes[0];
|
|
//We make a call to addTreeNode,
|
|
//where we'll add all of our nodes
|
|
addTreeNode(xDoc.DocumentElement, tNode);
|
|
//Expand the treeview to show all nodes
|
|
treeViewAdv1.ExpandAll();
|
|
|
|
}
|
|
private void addTreeNode(XmlNode xmlNode, TreeNodeAdv treeNode)
|
|
{
|
|
XmlNode xNode;
|
|
TreeNodeAdv tNode;
|
|
XmlNodeList xNodeList;
|
|
if (xmlNode.HasChildNodes) //The current node has children
|
|
{
|
|
xNodeList = xmlNode.ChildNodes;
|
|
for (int x = 0; x <= xNodeList.Count - 1; x++)
|
|
//Loop through the child nodes
|
|
{
|
|
xNode = xmlNode.ChildNodes[x];
|
|
treeNode.Nodes.Add(new TreeNodeAdv(xNode.Name));
|
|
tNode = treeNode.Nodes[x];
|
|
addTreeNode(xNode, tNode);
|
|
}
|
|
}
|
|
else //No children, so add the outer xml (trimming off whitespace)
|
|
treeNode.Text = xmlNode.OuterXml.Trim();
|
|
}
|
|
|
|
private XmlTextWriter xr;
|
|
|
|
public void exportToXml2(TreeViewAdv tv, string filename)
|
|
{
|
|
xr = new XmlTextWriter(filename, System.Text.Encoding.UTF8);
|
|
xr.WriteStartDocument();
|
|
//Write our root node
|
|
xr.WriteStartElement(treeViewAdv1.Nodes[0].Text);
|
|
foreach (TreeNodeAdv node in tv.Nodes)
|
|
{
|
|
saveNode2(node.Nodes);
|
|
}
|
|
//Close the root node
|
|
xr.WriteEndElement();
|
|
xr.Close();
|
|
}
|
|
|
|
private void saveNode2(TreeNodeAdvCollection tnc)
|
|
{
|
|
foreach (TreeNodeAdv node in tnc)
|
|
{
|
|
//If we have child nodes, we'll write
|
|
//a parent node, then iterrate through
|
|
//the children
|
|
if (node.Nodes.Count > 0)
|
|
{
|
|
xr.WriteStartElement(node.Text);
|
|
saveNode2(node.Nodes);
|
|
xr.WriteEndElement();
|
|
}
|
|
else //No child nodes, so we just write the text
|
|
{
|
|
xr.WriteString(node.Text);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|