diff --git a/DE/DE.cs b/DE/DE.cs
index b619c48..9ef2ffd 100644
--- a/DE/DE.cs
+++ b/DE/DE.cs
@@ -33,6 +33,10 @@ namespace Language
labels.Add("error_messages", "Fehlermeldungsarten");
labels.Add("error_projwrong", "Projektnummer nicht vergeben");
labels.Add("error_groundData", "Grunddaten sind nicht richtig vergeben");
+ labels.Add("mainmenu_projekt", "&Projekt");
+ labels.Add("mainmenu_projekt_new", "&Neu");
+ labels.Add("mainmenu_projekt_open", "Ö&ffnen");
+
}
}
diff --git a/Database/Database.csproj b/Database/Database.csproj
index f71398d..c7eabe5 100644
--- a/Database/Database.csproj
+++ b/Database/Database.csproj
@@ -30,8 +30,12 @@
4
+
+ ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll
+
+
@@ -50,5 +54,8 @@
KlassenBIB
+
+
+
\ No newline at end of file
diff --git a/Database/Datenbank.cs b/Database/Datenbank.cs
index bf81677..2de6dbd 100644
--- a/Database/Datenbank.cs
+++ b/Database/Datenbank.cs
@@ -5,11 +5,16 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xaml;
+using System.IO.Compression;
+using System.Diagnostics;
+using ICSharpCode.SharpZipLib.Zip;
+using ICSharpCode.SharpZipLib.Core;
namespace Database
{
public class Datenbank
{
+ public const string pfad = "./";
public static readonly Datenbank instance = new Datenbank();
public static Datenbank Instance
{
@@ -24,6 +29,8 @@ namespace Database
private string projektpfad = string.Empty;
public bool LoadProjekt(string filepath)
{
+ UnPackProject("18-850","willyteufelchen");
+ //PackSystem("./projekte/18-850.zip", "./projekte/18-850","willyteufelchen");
projektpfad = filepath;
if (File.Exists(filepath))
loadedProjekt = XamlServices.Load(filepath) as KlassenBIB.Projekt;
@@ -32,6 +39,130 @@ namespace Database
return true;
}
+ private void UnPackProject(string projekt, string password = "")
+ {
+ if (!Directory.Exists("./temp")) Directory.CreateDirectory("./temp");
+
+ ZipFile zf = null;
+ try
+ {
+ FileStream fs = File.OpenRead(Path.Combine("projekte", string.Format("{0}.zip", projekt)));
+ zf = new ZipFile(fs);
+ if (!password.Equals("")) zf.Password = password;
+ foreach(ZipEntry zipEntry in zf)
+ {
+ if (!zipEntry.IsFile) continue;
+ string entryFileName = zipEntry.Name;
+ byte[] buffer = new byte[4096];
+ Stream zipStream = zf.GetInputStream(zipEntry);
+
+ string fullZipToPath = Path.Combine("./temp/", entryFileName);
+ string directoryName = Path.GetDirectoryName(fullZipToPath);
+ if (directoryName.Length > 0) Directory.CreateDirectory(directoryName);
+ using (FileStream streamWriter = File.Create(fullZipToPath))
+ {
+ StreamUtils.Copy(zipStream, streamWriter, buffer);
+ }
+ }
+ }
+ finally
+ {
+ if(zf != null)
+ {
+ zf.IsStreamOwner = true;
+ zf.Close();
+ }
+ }
+ }
+
+ public bool CreateProjekt(string projektnummer)
+ {
+ string filepath = Path.Combine(pfad, projektnummer);
+ if (File.Exists(filepath)) return false;
+
+ using (MemoryStream memoryStream = new MemoryStream())
+ {
+ using (ZipArchive archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
+ {
+ var demoFile = archive.CreateEntry("daten/foo.txt");
+ using (var entryStream = demoFile.Open())
+ {
+ XamlServices.Save(entryStream, loadedProjekt);
+ }
+ }
+
+ using (var fileStream = new FileStream("./test.zip", FileMode.Create))
+ {
+ memoryStream.Seek(0, SeekOrigin.Begin);
+ memoryStream.CopyTo(fileStream);
+ }
+ }
+
+ return true;
+ }
+
+ private void PackSystem(string outPathName, string folderName, string password = "")
+ {
+ FileStream fsOut = File.Create(outPathName);
+ ZipOutputStream zipStream = new ZipOutputStream(fsOut);
+
+ zipStream.SetLevel(3);
+
+ if (!password.Equals("")) zipStream.Password = password;
+
+ int folderOffset = folderName.Length +(folderName.EndsWith("\\") ? 0 : 1);
+ CompressFolder(folderName, zipStream, folderOffset);
+ zipStream.IsStreamOwner = true;
+ zipStream.Close();
+ }
+
+ private void CompressFolder(string path, ZipOutputStream zipStream, int folderOffset)
+ {
+ string[] files = Directory.GetFiles(path);
+ foreach(string filename in files)
+ {
+ FileInfo fi = new FileInfo(filename);
+ string entryName = filename.Substring(folderOffset);
+ entryName = ZipEntry.CleanName(entryName);
+ ZipEntry newEntry = new ZipEntry(entryName);
+ newEntry.DateTime = fi.LastWriteTime;
+ newEntry.Size = fi.Length;
+ zipStream.PutNextEntry(newEntry);
+ byte[] buffer = new byte[4096];
+ using (FileStream streamReader = File.OpenRead(filename))
+ {
+ StreamUtils.Copy(streamReader, zipStream, buffer);
+ }
+ zipStream.CloseEntry();
+ }
+ string[] folders = Directory.GetDirectories(path);
+ foreach(string folder in folders)
+ {
+ CompressFolder(folder, zipStream, folderOffset);
+ }
+ }
+
+ public void Test()
+ {
+
+
+ using (MemoryStream memoryStream = new MemoryStream())
+ {
+ using (var fileStream = new FileStream("./test.zip", FileMode.Open))
+ {
+ fileStream.Seek(0, SeekOrigin.Begin);
+ fileStream.CopyTo(memoryStream);
+ }
+ using (ZipArchive archive = new ZipArchive(memoryStream, ZipArchiveMode.Update, true))
+ {
+ ZipArchiveEntry test = archive.CreateEntry("./datas/test.txt");
+ Debugger.Break();
+ }
+
+ Debugger.Break();
+ }
+ }
+
public void SaveProjekt()
{
XamlServices.Save(projektpfad, loadedProjekt);
diff --git a/Database/packages.config b/Database/packages.config
new file mode 100644
index 0000000..948bc60
--- /dev/null
+++ b/Database/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/SanSystem/SanSystem.csproj b/SanSystem/SanSystem.csproj
index a19298b..c3df1d8 100644
--- a/SanSystem/SanSystem.csproj
+++ b/SanSystem/SanSystem.csproj
@@ -32,6 +32,9 @@
4
+
+ ..\packages\Ionic.Zip.1.9.1.8\lib\Ionic.Zip.dll
+
@@ -93,6 +96,7 @@
True
Resources.resx
+
SettingsSingleFileGenerator
diff --git a/SanSystem/frmMain.Designer.cs b/SanSystem/frmMain.Designer.cs
index c878a02..7a8bf3f 100644
--- a/SanSystem/frmMain.Designer.cs
+++ b/SanSystem/frmMain.Designer.cs
@@ -28,23 +28,71 @@
///
private void InitializeComponent()
{
+ this.mainmenu = new System.Windows.Forms.MenuStrip();
+ this.projektToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.neuToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.öffnenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.mainmenu.SuspendLayout();
this.SuspendLayout();
//
- // frm_main
+ // mainmenu
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
+ this.mainmenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.projektToolStripMenuItem});
+ this.mainmenu.Location = new System.Drawing.Point(0, 0);
+ this.mainmenu.Name = "mainmenu";
+ this.mainmenu.Size = new System.Drawing.Size(596, 24);
+ this.mainmenu.TabIndex = 1;
+ this.mainmenu.Text = "menuStrip1";
+ //
+ // projektToolStripMenuItem
+ //
+ this.projektToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.neuToolStripMenuItem,
+ this.öffnenToolStripMenuItem});
+ this.projektToolStripMenuItem.Name = "projektToolStripMenuItem";
+ this.projektToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
+ this.projektToolStripMenuItem.Text = "Projekt";
+ //
+ // neuToolStripMenuItem
+ //
+ this.neuToolStripMenuItem.Name = "neuToolStripMenuItem";
+ this.neuToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.neuToolStripMenuItem.Text = "Neu";
+ this.neuToolStripMenuItem.Click += new System.EventHandler(this.neuToolStripMenuItem_Click);
+ //
+ // öffnenToolStripMenuItem
+ //
+ this.öffnenToolStripMenuItem.Name = "öffnenToolStripMenuItem";
+ this.öffnenToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.öffnenToolStripMenuItem.Text = "Öffnen";
+ //
+ // frmMain
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(795, 459);
+ this.ClientSize = new System.Drawing.Size(596, 373);
+ this.Controls.Add(this.mainmenu);
this.IsMdiContainer = true;
- this.Name = "frm_main";
+ this.MainMenuStrip = this.mainmenu;
+ this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.Name = "frmMain";
this.Text = "Kanalsanierungsverwaltung";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frm_main_FormClosing);
this.Load += new System.EventHandler(this.frm_main_Load);
+ this.mainmenu.ResumeLayout(false);
+ this.mainmenu.PerformLayout();
this.ResumeLayout(false);
+ this.PerformLayout();
}
#endregion
+
+ private System.Windows.Forms.MenuStrip mainmenu;
+ private System.Windows.Forms.ToolStripMenuItem projektToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem neuToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem öffnenToolStripMenuItem;
}
}
diff --git a/SanSystem/frmMain.cs b/SanSystem/frmMain.cs
index 1094a8a..882154d 100644
--- a/SanSystem/frmMain.cs
+++ b/SanSystem/frmMain.cs
@@ -18,28 +18,19 @@ namespace SanSystem
{
InitializeComponent();
Datenbank.Instance.LoadProjekt("projekt1.xaml");
+ Datenbank.Instance.CreateProjekt("");
this.Width = Screen.PrimaryScreen.WorkingArea.Width;
this.Height = Screen.PrimaryScreen.WorkingArea.Height;
this.WindowState = FormWindowState.Maximized;
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(0, 0);
+
+ projektToolStripMenuItem.Text = Global.Instance.language.Labels["mainmenu_projekt"];
+ neuToolStripMenuItem.Text = Global.Instance.language.Labels["mainmenu_projekt_new"];
+ öffnenToolStripMenuItem.Text = Global.Instance.language.Labels["mainmenu_projekt_open"];
+
}
- private void button1_Click(object sender, EventArgs e)
- {
-
- Projekt projekt = Datenbank.Instance.loadedProjekt;
-
- //dresseCollection adressen = projekt.Adressen;
- /*
- adressen[0].Objekte.Add(new Inspektionsobjekt()
- {
- Objektbezeichnung = "SW01"
- });
- */
-
- Datenbank.Instance.SaveProjekt();
- }
private void frm_main_Load(object sender, EventArgs e)
{
@@ -56,5 +47,10 @@ namespace SanSystem
{
Datenbank.Instance.SaveProjekt();
}
+
+ private void neuToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+
+ }
}
}
diff --git a/SanSystem/frmMain.resx b/SanSystem/frmMain.resx
index 1af7de1..8376617 100644
--- a/SanSystem/frmMain.resx
+++ b/SanSystem/frmMain.resx
@@ -117,4 +117,7 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 17, 17
+
\ No newline at end of file
diff --git a/SanSystem/packages.config b/SanSystem/packages.config
new file mode 100644
index 0000000..12e1c83
--- /dev/null
+++ b/SanSystem/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file