update 20240812

This commit is contained in:
Stefan Hutter
2024-08-12 16:35:06 +02:00
parent 43c44e0aad
commit fc8811829d
7922 changed files with 205978 additions and 91947 deletions

View File

@@ -13,6 +13,11 @@ using Syncfusion.Windows.Forms.Tools;
using Syncfusion.WinForms.Controls;
using System.Xml;
using System.IO;
using System.Configuration;
using System.Xml.Linq;
using Syncfusion.Compression.Zip;
using static System.Net.Mime.MediaTypeNames;
using System.Diagnostics;
namespace OnDoc.Diverses
{
@@ -23,82 +28,176 @@ namespace OnDoc.Diverses
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
string ext = "";
DirectoryInfo directoryInfo = new DirectoryInfo(Properties.Settings.Default.NativVorlagen);
if (directoryInfo.Exists)
{
xNodeList = xmlNode.ChildNodes;
for (int x = 0; x <= xNodeList.Count - 1; x++)
//Loop through the child nodes
try
{
xNode = xmlNode.ChildNodes[x];
treeNode.Nodes.Add(new TreeNodeAdv(xNode.Name));
tNode = treeNode.Nodes[x];
addTreeNode(xNode, tNode);
TreeNode root = new TreeNode();
root.Text = "Vorlagen";
root.ImageIndex = 3;
root.SelectedImageIndex = 3;
treeView.Nodes.Add(root);
DirectoryInfo[] directories = directoryInfo.GetDirectories();
foreach (FileInfo file in directoryInfo.GetFiles())
{
if (file.Exists)
{
ext = System.IO.Path.GetExtension(file.Name);
TreeNode tnnew = new TreeNode();
tnnew.Text = file.Name;
if (ext.Length > 2)
{
ext = ext.Substring(0, 2).ToUpper();
if (ext == ".D") { tnnew.ImageIndex = 0; tnnew.SelectedImageIndex = 0; };
if (ext == ".X") { tnnew.ImageIndex = 1; tnnew.SelectedImageIndex = 1; };
if (ext == ".P") { tnnew.ImageIndex = 2; tnnew.SelectedImageIndex = 2; };
}
else
{
tnnew.ImageIndex = 3; tnnew.SelectedImageIndex = 3;
}
TreeNode treeNode = treeView.Nodes[0];
treeNode.Nodes.Add(tnnew);
//TreeNode nodes = treeView.Nodes[0].Nodes.Add(file.Name);
}
}
if (directories.Length > 0)
{
foreach (DirectoryInfo directory in directories)
{
TreeNode node = treeView.Nodes[0].Nodes.Add(directory.Name);
node.ImageIndex = node.SelectedImageIndex = 3;
foreach (FileInfo file in directory.GetFiles())
{
if (file.Exists)
{
TreeNode tnnew = new TreeNode();
tnnew.Text = file.Name;
tnnew.Tag = file.FullName;
ext = System.IO.Path.GetExtension(tnnew.Text);
if (ext.Length > 2)
{
ext = ext.Substring(0, 2).ToUpper();
if (ext == ".D") { tnnew.ImageIndex = 0; tnnew.SelectedImageIndex = 0; };
if (ext == ".X") { tnnew.ImageIndex = 1; tnnew.SelectedImageIndex = 1; };
if (ext == ".P") { tnnew.ImageIndex = 2; tnnew.SelectedImageIndex = 2; };
}
else
{
tnnew.ImageIndex = 3; tnnew.SelectedImageIndex = 3;
tnnew.Tag = "";
}
TreeNode tnnew2 = treeView.Nodes[0].Nodes[node.Index];
tnnew2.Nodes.Add(tnnew);
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
treeView.ExpandAll();
}
}
private static void ListDirectory(TreeViewAdv treeView, string path)
{
treeView.Nodes.Clear();
var stack = new Stack<TreeNodeAdv>();
var rootDirectory = new DirectoryInfo(path);
var node = new TreeNodeAdv(rootDirectory.Name) { Tag = rootDirectory };
string ext = System.IO.Path.GetExtension(node.Text);
{ node.RightImageIndices = new int[] { 3 }; }
stack.Push(node);
while (stack.Count > 0)
{
var currentNode = stack.Pop();
var directoryInfo = (DirectoryInfo)currentNode.Tag;
foreach (var directory in directoryInfo.GetDirectories())
{
var childDirectoryNode = new TreeNodeAdv(directory.Name) { Tag = directory };
currentNode.Nodes.Add(childDirectoryNode);
{ childDirectoryNode.RightImageIndices = new int[] { 3 }; }
stack.Push(childDirectoryNode);
foreach (var file in directoryInfo.GetFiles())
{
TreeNodeAdv tnnew = new TreeNodeAdv(file.Name);
ext = System.IO.Path.GetExtension(tnnew.Text);
if (ext.Length > 2)
{
ext = ext.Substring(0, 2).ToUpper();
if (ext == ".D") { tnnew.LeftImageIndices = new int[] { 0 }; };
if (ext == ".X") { tnnew.LeftImageIndices = new int[] { 1 }; };
if (ext == ".P") { tnnew.LeftImageIndices = new int[] { 2 }; };
}
else
{ tnnew.RightImageIndices = new int[] { 3 }; }
currentNode.Nodes.Add(tnnew);
}
}
}
else //No children, so add the outer xml (trimming off whitespace)
treeNode.Text = xmlNode.OuterXml.Trim();
treeView.Nodes.Add(node);
}
private XmlTextWriter xr;
public void exportToXml2(TreeViewAdv tv, string filename)
private void treeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
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();
Execute(e.Node);
}
private void saveNode2(TreeNodeAdvCollection tnc)
private void toolStripButton1_Click(object sender, EventArgs e)
{
foreach (TreeNodeAdv node in tnc)
this.Close();
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
Execute(treeView.SelectedNode);
}
private void Execute(TreeNode treeNode)
{
try
{
//If we have child nodes, we'll write
//a parent node, then iterrate through
//the children
if (node.Nodes.Count > 0)
string tempfilename = treeNode.Tag.ToString();
if (tempfilename == "") { return; }
//string tempdir = AppParams.tempdir + "\nativdoks";
string ext = System.IO.Path.GetExtension(tempfilename);
if (ext.Length > 2)
{
xr.WriteStartElement(node.Text);
saveNode2(node.Nodes);
xr.WriteEndElement();
}
else //No child nodes, so we just write the text
{
xr.WriteString(node.Text);
ext = ext.Substring(0, 2).ToUpper();
if (ext == ".D") { System.Diagnostics.Process.Start("winword.exe", " /t" + tempfilename); };
if (ext == ".X") { System.Diagnostics.Process.Start("excel.exe", " /t " + tempfilename); };
if (ext == ".P") { System.Diagnostics.Process.Start("POWERPNT.EXE", " /N " + tempfilename); };
}
}
catch { }
}
}
}