update 20240925
This commit is contained in:
226
NativVorlagen/Form1.cs
Normal file
226
NativVorlagen/Form1.cs
Normal file
@@ -0,0 +1,226 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Syncfusion.Drawing;
|
||||
using Syncfusion.Windows.Forms.Grid;
|
||||
using Syncfusion.Windows.Forms.Tools;
|
||||
using Syncfusion.WinForms.Controls;
|
||||
using static Syncfusion.Windows.Forms.Tools.Navigation.Bar;
|
||||
|
||||
namespace NativVorlagen
|
||||
{
|
||||
public partial class Form1 : SfForm
|
||||
{
|
||||
public string VorlagenPath { get; set; } = "";
|
||||
private int TotalKlassifizierung = 0;
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (VorlagenPath == "") { VorlagenPath = Properties.Settings.Default.Vorlagen; }
|
||||
string line = "";
|
||||
int i = 1;
|
||||
StreamReader sr = new StreamReader(VorlagenPath + @"\klassifizierung.txt");
|
||||
line = sr.ReadLine();
|
||||
while (line != null)
|
||||
{
|
||||
RadioButton rb = new RadioButton();
|
||||
rb.Name = "rb" + i.ToString();
|
||||
rb.Text = line;
|
||||
rb.Left = label1.Left;
|
||||
rb.Top = label1.Top + (i * 25);
|
||||
rb.Width = 180;
|
||||
i++;
|
||||
this.Controls.Add(rb);
|
||||
line = sr.ReadLine();
|
||||
}
|
||||
sr.Close();
|
||||
TotalKlassifizierung = i - 1;
|
||||
try
|
||||
{
|
||||
RadioButton rb = this.Controls.Find("rb1", true).FirstOrDefault() as RadioButton;
|
||||
rb.Checked = true;
|
||||
}
|
||||
catch { }
|
||||
|
||||
string ext = "";
|
||||
DirectoryInfo directoryInfo = new DirectoryInfo(VorlagenPath);
|
||||
if (directoryInfo.Exists)
|
||||
{
|
||||
try
|
||||
{
|
||||
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 && file.Name != "klassifizierung.txt")
|
||||
{
|
||||
|
||||
ext = System.IO.Path.GetExtension(file.Name);
|
||||
TreeNode tnnew = new TreeNode();
|
||||
tnnew.Text = file.Name;
|
||||
tnnew.Tag = file.FullName;
|
||||
tnnew.ImageIndex = 4;
|
||||
|
||||
if (ext.Length > 2)
|
||||
{
|
||||
ext = ext.Substring(0, 2).ToUpper();
|
||||
tnnew.ImageIndex = 4;
|
||||
tnnew.SelectedImageIndex = 4;
|
||||
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 && file.Name != "klassifizierung.txt")
|
||||
{
|
||||
TreeNode tnnew = new TreeNode();
|
||||
tnnew.Text = file.Name;
|
||||
tnnew.Tag = file.FullName;
|
||||
tnnew.ImageIndex = 4;
|
||||
ext = System.IO.Path.GetExtension(tnnew.Text);
|
||||
if (ext.Length > 2)
|
||||
{
|
||||
ext = ext.Substring(0, 2).ToUpper();
|
||||
tnnew.ImageIndex = 4;
|
||||
tnnew.SelectedImageIndex = 4;
|
||||
|
||||
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 void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
Execute(this.treeView.SelectedNode);
|
||||
}
|
||||
|
||||
private void Execute(TreeNode treeNode)
|
||||
{
|
||||
string klassifizierung = "";
|
||||
try
|
||||
{
|
||||
for (int i = 1; i < TotalKlassifizierung + 1; i++)
|
||||
{
|
||||
RadioButton rb = this.Controls.Find("rb" + i.ToString(), true).FirstOrDefault() as RadioButton;
|
||||
if (rb != null)
|
||||
{
|
||||
if (rb.Checked)
|
||||
{
|
||||
klassifizierung = rb.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
string tempfilename = treeNode.Tag.ToString();
|
||||
if (tempfilename == "") { return; }
|
||||
|
||||
//string tempdir = AppParams.tempdir + "\nativdoks";
|
||||
|
||||
string ext = System.IO.Path.GetExtension(tempfilename);
|
||||
if (ext.Length > 2)
|
||||
{
|
||||
ext = ext.Substring(0, 2).ToUpper();
|
||||
string tempfilename1 = "";
|
||||
switch (ext)
|
||||
{
|
||||
case ".D":
|
||||
DOCGEN.Klassen.SyncFWord sf = new DOCGEN.Klassen.SyncFWord();
|
||||
tempfilename1 = System.IO.Path.GetFileName(tempfilename);
|
||||
tempfilename1 = Properties.Settings.Default.UserDir + "" + DateTime.Now.ToString("yyyyMMddhhmmss") + tempfilename1;
|
||||
sf.create_nativ("Klassifikation", klassifizierung, "", tempfilename, tempfilename1);
|
||||
System.Diagnostics.Process.Start("winword.exe", " /t" + tempfilename1);
|
||||
|
||||
//System.Diagnostics.Process.Start("winword.exe", " /t" + tempfilename);
|
||||
break;
|
||||
case ".X":
|
||||
DOCGEN.Klassen.SynFExcel ef = new DOCGEN.Klassen.SynFExcel();
|
||||
tempfilename1 = System.IO.Path.GetFileName(tempfilename);
|
||||
tempfilename1 = Properties.Settings.Default.UserDir + "" + DateTime.Now.ToString("yyyyMMddhhmmss") + tempfilename1;
|
||||
|
||||
ef.create_nativ("Klassifikation", klassifizierung, "", tempfilename, tempfilename1);
|
||||
|
||||
System.Diagnostics.Process.Start("excel.exe", " /t " + tempfilename1);
|
||||
break;
|
||||
case ".P":
|
||||
DOCGEN.Klassen.SyncFPowerPoint pf = new DOCGEN.Klassen.SyncFPowerPoint();
|
||||
tempfilename1 = System.IO.Path.GetFileName(tempfilename);
|
||||
tempfilename1 = Properties.Settings.Default.UserDir + "" + DateTime.Now.ToString("yyyyMMddhhmmss") + tempfilename1;
|
||||
pf.create_nativ("Klassifikation", klassifizierung, "", tempfilename, tempfilename1);
|
||||
System.Diagnostics.Process.Start("POWERPNT.EXE", " /N " + tempfilename1);
|
||||
break;
|
||||
default:
|
||||
tempfilename1 = System.IO.Path.GetFileName(tempfilename);
|
||||
tempfilename1 = Properties.Settings.Default.UserDir + "" + DateTime.Now.ToString("yyyyMMddhhmmss") + tempfilename1;
|
||||
System.IO.File.Copy(tempfilename, tempfilename1, true);
|
||||
Process.Start(tempfilename1);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user