From 78ccc768dfc7afc8cb2dc923d436bd4e0b3792c6 Mon Sep 17 00:00:00 2001 From: Husky Date: Sun, 1 Jul 2018 16:28:13 +0200 Subject: [PATCH] =?UTF-8?q?Bilder=20k=C3=B6nnen=20jetzt=20hinterlegt=20wer?= =?UTF-8?q?den?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KlassenBIB/BilderCollection.cs | 12 ++ KlassenBIB/KlassenBIB.csproj | 2 + KlassenBIB/SavedBilder.cs | 20 +++ KlassenBIB/SchachtAnbindung.cs | 10 ++ SanSystem/SanSystem.csproj | 9 ++ SanSystem/UCInliner.Designer.cs | 37 +++--- SanSystem/UCInliner.cs | 12 ++ SanSystem/UCSchachtanbindung.Designer.cs | 155 +++++++++++++++++++++++ SanSystem/UCSchachtanbindung.cs | 100 +++++++++++++++ SanSystem/UCSchachtanbindung.resx | 123 ++++++++++++++++++ SanSystem/frmObjektEdit.cs | 8 +- 11 files changed, 468 insertions(+), 20 deletions(-) create mode 100644 KlassenBIB/BilderCollection.cs create mode 100644 KlassenBIB/SavedBilder.cs create mode 100644 SanSystem/UCSchachtanbindung.Designer.cs create mode 100644 SanSystem/UCSchachtanbindung.cs create mode 100644 SanSystem/UCSchachtanbindung.resx diff --git a/KlassenBIB/BilderCollection.cs b/KlassenBIB/BilderCollection.cs new file mode 100644 index 0000000..80bc8e2 --- /dev/null +++ b/KlassenBIB/BilderCollection.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace KlassenBIB +{ + public class BilderCollection : List + { + } +} diff --git a/KlassenBIB/KlassenBIB.csproj b/KlassenBIB/KlassenBIB.csproj index 0860559..0cdd5e0 100644 --- a/KlassenBIB/KlassenBIB.csproj +++ b/KlassenBIB/KlassenBIB.csproj @@ -42,6 +42,7 @@ + @@ -51,6 +52,7 @@ + diff --git a/KlassenBIB/SavedBilder.cs b/KlassenBIB/SavedBilder.cs new file mode 100644 index 0000000..cb248ba --- /dev/null +++ b/KlassenBIB/SavedBilder.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace KlassenBIB +{ + public class SavedBilder + { + public string Bildname { get; set; } + public string Speicherpfad { get; set; } + public string Bemerkung { get; set; } + + public override string ToString() + { + return Bildname; + } + } +} diff --git a/KlassenBIB/SchachtAnbindung.cs b/KlassenBIB/SchachtAnbindung.cs index 4f29d7f..dcce6c2 100644 --- a/KlassenBIB/SchachtAnbindung.cs +++ b/KlassenBIB/SchachtAnbindung.cs @@ -9,11 +9,21 @@ namespace KlassenBIB { public class SchachtAnbindung : Sanieren { + string schachtNummer; + BilderCollection savedBilders; + + #region GettersSetters + public string SchachtNummer { get => schachtNummer; set => schachtNummer = value; } + public BilderCollection SavedBilders { get => savedBilders; set => savedBilders = value; } + #endregion + public SchachtAnbindung() { Verzeichnispfad = "Schachtanbindung"; + SavedBilders = new BilderCollection(); } + public override string CheckVerzeichnisse(string projektpfad) { string path = Path.Combine(projektpfad, PfadZurSan); diff --git a/SanSystem/SanSystem.csproj b/SanSystem/SanSystem.csproj index f66b18d..3c3984b 100644 --- a/SanSystem/SanSystem.csproj +++ b/SanSystem/SanSystem.csproj @@ -87,6 +87,12 @@ UCInliner.cs + + UserControl + + + UCSchachtanbindung.cs + frmObjektEdit.cs @@ -114,6 +120,9 @@ UCInliner.cs + + UCSchachtanbindung.cs + diff --git a/SanSystem/UCInliner.Designer.cs b/SanSystem/UCInliner.Designer.cs index 749f829..4a4687d 100644 --- a/SanSystem/UCInliner.Designer.cs +++ b/SanSystem/UCInliner.Designer.cs @@ -30,6 +30,8 @@ { this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage2 = new System.Windows.Forms.TabPage(); + this.label1 = new System.Windows.Forms.Label(); + this.dt_eingebaut = new System.Windows.Forms.DateTimePicker(); this.cb_fertig = new System.Windows.Forms.CheckBox(); this.cbb_wetter = new System.Windows.Forms.ComboBox(); this.label24 = new System.Windows.Forms.Label(); @@ -65,8 +67,6 @@ this.label11 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); - this.dt_eingebaut = new System.Windows.Forms.DateTimePicker(); - this.label1 = new System.Windows.Forms.Label(); this.tabControl1.SuspendLayout(); this.tabPage2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -109,6 +109,22 @@ this.tabPage2.Text = "Vorraussetzungen"; this.tabPage2.UseVisualStyleBackColor = true; // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(47, 439); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(108, 20); + this.label1.TabIndex = 27; + this.label1.Text = "Eingebaut am"; + // + // dt_eingebaut + // + this.dt_eingebaut.Location = new System.Drawing.Point(205, 434); + this.dt_eingebaut.Name = "dt_eingebaut"; + this.dt_eingebaut.Size = new System.Drawing.Size(291, 26); + this.dt_eingebaut.TabIndex = 26; + // // cb_fertig // this.cb_fertig.AutoSize = true; @@ -167,6 +183,7 @@ this.btn_get_temp.TabIndex = 4; this.btn_get_temp.Text = "Von Anlage holen"; this.btn_get_temp.UseVisualStyleBackColor = true; + this.btn_get_temp.Click += new System.EventHandler(this.btn_get_temp_Click); // // txt_temp_kanal // @@ -494,22 +511,6 @@ this.label9.TabIndex = 0; this.label9.Text = "Harz"; // - // dt_eingebaut - // - this.dt_eingebaut.Location = new System.Drawing.Point(205, 434); - this.dt_eingebaut.Name = "dt_eingebaut"; - this.dt_eingebaut.Size = new System.Drawing.Size(291, 26); - this.dt_eingebaut.TabIndex = 26; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(47, 439); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(108, 20); - this.label1.TabIndex = 27; - this.label1.Text = "Eingebaut am"; - // // UCInliner // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); diff --git a/SanSystem/UCInliner.cs b/SanSystem/UCInliner.cs index 9b2ddcf..a131af2 100644 --- a/SanSystem/UCInliner.cs +++ b/SanSystem/UCInliner.cs @@ -10,6 +10,7 @@ using System.Windows.Forms; using KlassenBIB; using System.Diagnostics; using System.IO; +using SanShared; namespace SanSystem { @@ -102,5 +103,16 @@ namespace SanSystem { destinationPath = inliner.CheckVerzeichnisse(Global.Instance.projektpfad); } + + private void btn_get_temp_Click(object sender, EventArgs e) + { + ITemperature temperature = TempCAN.TemperaturBuilder.Temperatur(TempCAN.TemperaturSchnittstellen.TINKERFORGE); + + double temperatur = temperature.GetTemperatur(); + inliner.TempAusen = temperatur; + + + txt_temp_aussen.Update(); + } } } diff --git a/SanSystem/UCSchachtanbindung.Designer.cs b/SanSystem/UCSchachtanbindung.Designer.cs new file mode 100644 index 0000000..d127d5a --- /dev/null +++ b/SanSystem/UCSchachtanbindung.Designer.cs @@ -0,0 +1,155 @@ +namespace SanSystem +{ + partial class UCSchachtanbindung + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Komponenten-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.label1 = new System.Windows.Forms.Label(); + this.txt_schachtnummer = new System.Windows.Forms.TextBox(); + this.pt_box = new System.Windows.Forms.PictureBox(); + this.btn_add_bild = new System.Windows.Forms.Button(); + this.lb_pictures = new System.Windows.Forms.ListBox(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.bearbeitenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.löschenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.cb_erledigt = new System.Windows.Forms.CheckBox(); + ((System.ComponentModel.ISupportInitialize)(this.pt_box)).BeginInit(); + this.contextMenuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(9, 18); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(126, 20); + this.label1.TabIndex = 0; + this.label1.Text = "Schachtnummer"; + // + // txt_schachtnummer + // + this.txt_schachtnummer.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txt_schachtnummer.Location = new System.Drawing.Point(252, 15); + this.txt_schachtnummer.Name = "txt_schachtnummer"; + this.txt_schachtnummer.Size = new System.Drawing.Size(232, 26); + this.txt_schachtnummer.TabIndex = 1; + // + // pt_box + // + this.pt_box.Location = new System.Drawing.Point(13, 47); + this.pt_box.Name = "pt_box"; + this.pt_box.Size = new System.Drawing.Size(600, 326); + this.pt_box.TabIndex = 2; + this.pt_box.TabStop = false; + // + // btn_add_bild + // + this.btn_add_bild.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btn_add_bild.Location = new System.Drawing.Point(628, 197); + this.btn_add_bild.Name = "btn_add_bild"; + this.btn_add_bild.Size = new System.Drawing.Size(73, 176); + this.btn_add_bild.TabIndex = 3; + this.btn_add_bild.Text = "Bild Laden"; + this.btn_add_bild.UseVisualStyleBackColor = true; + this.btn_add_bild.Click += new System.EventHandler(this.btn_add_bild_Click); + // + // lb_pictures + // + this.lb_pictures.FormattingEnabled = true; + this.lb_pictures.Location = new System.Drawing.Point(620, 47); + this.lb_pictures.Name = "lb_pictures"; + this.lb_pictures.Size = new System.Drawing.Size(81, 147); + this.lb_pictures.TabIndex = 4; + this.lb_pictures.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lb_pictures_MouseDown); + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.bearbeitenToolStripMenuItem, + this.löschenToolStripMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(131, 48); + // + // bearbeitenToolStripMenuItem + // + this.bearbeitenToolStripMenuItem.Name = "bearbeitenToolStripMenuItem"; + this.bearbeitenToolStripMenuItem.Size = new System.Drawing.Size(130, 22); + this.bearbeitenToolStripMenuItem.Text = "Bearbeiten"; + // + // löschenToolStripMenuItem + // + this.löschenToolStripMenuItem.Name = "löschenToolStripMenuItem"; + this.löschenToolStripMenuItem.Size = new System.Drawing.Size(130, 22); + this.löschenToolStripMenuItem.Text = "Löschen"; + this.löschenToolStripMenuItem.Click += new System.EventHandler(this.löschenToolStripMenuItem_Click); + // + // cb_erledigt + // + this.cb_erledigt.AutoSize = true; + this.cb_erledigt.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cb_erledigt.Location = new System.Drawing.Point(512, 10); + this.cb_erledigt.Name = "cb_erledigt"; + this.cb_erledigt.Size = new System.Drawing.Size(93, 28); + this.cb_erledigt.TabIndex = 6; + this.cb_erledigt.Text = "Erledigt"; + this.cb_erledigt.UseVisualStyleBackColor = true; + // + // UCSchachtanbindung + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.cb_erledigt); + this.Controls.Add(this.lb_pictures); + this.Controls.Add(this.btn_add_bild); + this.Controls.Add(this.pt_box); + this.Controls.Add(this.txt_schachtnummer); + this.Controls.Add(this.label1); + this.Name = "UCSchachtanbindung"; + this.Size = new System.Drawing.Size(712, 389); + this.Load += new System.EventHandler(this.UCSchachtanbindung_Load); + ((System.ComponentModel.ISupportInitialize)(this.pt_box)).EndInit(); + this.contextMenuStrip1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox txt_schachtnummer; + private System.Windows.Forms.PictureBox pt_box; + private System.Windows.Forms.Button btn_add_bild; + private System.Windows.Forms.ListBox lb_pictures; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem bearbeitenToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem löschenToolStripMenuItem; + private System.Windows.Forms.CheckBox cb_erledigt; + } +} diff --git a/SanSystem/UCSchachtanbindung.cs b/SanSystem/UCSchachtanbindung.cs new file mode 100644 index 0000000..075ac57 --- /dev/null +++ b/SanSystem/UCSchachtanbindung.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using KlassenBIB; +using System.Diagnostics; +using System.IO; + +namespace SanSystem +{ + public partial class UCSchachtanbindung : UserControl + { + SchachtAnbindung schacht = null; + string mydestination = string.Empty; + public UCSchachtanbindung(SchachtAnbindung schacht) + { + InitializeComponent(); + this.schacht = schacht; + } + + private void UCSchachtanbindung_Load(object sender, EventArgs e) + { + txt_schachtnummer.DataBindings.Add(new Binding("Text", schacht, "Schachtnummer")); + cb_erledigt.DataBindings.Add(new Binding("Checked", schacht, "Fertig")); + lb_pictures.DataSource = schacht.SavedBilders; + + mydestination = schacht.CheckVerzeichnisse(""); + + if(schacht.SavedBilders.Count > 0) + { + + //pt_box.Image = Image.FromFile(Path.Combine("temp",schacht.SavedBilders[0].Speicherpfad)); + pt_box.Load(Path.Combine("temp", schacht.SavedBilders[0].Speicherpfad)); + pt_box.SizeMode = PictureBoxSizeMode.StretchImage; + } + } + + private void btn_add_bild_Click(object sender, EventArgs e) + { + using (OpenFileDialog openFileDialog = new OpenFileDialog()) + { + if(openFileDialog.ShowDialog() == DialogResult.OK) + { + string source = openFileDialog.FileName; + SavedBilder bilder = new SavedBilder(); + + string targetname = string.Format("{0}.jpg",Guid.NewGuid()); + + try + { + if (pt_box == null) throw new Exception(); + string speicherpfad = Path.Combine(mydestination, targetname); + File.Copy(source, Path.Combine("temp",speicherpfad)); + bilder.Bildname = "Anbindung"; + bilder.Speicherpfad = speicherpfad; + schacht.SavedBilders.Add(bilder); + pt_box.Load(Path.Combine("temp", schacht.SavedBilders[0].Speicherpfad)); + pt_box.SizeMode = PictureBoxSizeMode.StretchImage; + lb_pictures.DataSource = null; + lb_pictures.DataSource = schacht.SavedBilders; + } + catch(Exception ex) + { + MessageBox.Show(ex.Message.ToString()); + } + } + } + + + } + + private void lb_pictures_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + contextMenuStrip1.Show(Cursor.Position); + } + + private void löschenToolStripMenuItem_Click(object sender, EventArgs e) + { + if (lb_pictures.SelectedItems.Count < 1) return; + if(MessageBox.Show("Sicher dass du diesen Eintrag löschen möchtest?","Sicher", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) + { + + SavedBilder bild = (lb_pictures.SelectedItem as SavedBilder); + schacht.SavedBilders.Remove(bild); + pt_box.Image = null; + pt_box.Dispose(); + File.Delete(Path.Combine(Global.Instance.projektpfad, bild.Speicherpfad)); + lb_pictures.DataSource = null; + lb_pictures.DataSource = schacht.SavedBilders; + } + + } + } +} diff --git a/SanSystem/UCSchachtanbindung.resx b/SanSystem/UCSchachtanbindung.resx new file mode 100644 index 0000000..ad53752 --- /dev/null +++ b/SanSystem/UCSchachtanbindung.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 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/frmObjektEdit.cs b/SanSystem/frmObjektEdit.cs index 44253e0..d752667 100644 --- a/SanSystem/frmObjektEdit.cs +++ b/SanSystem/frmObjektEdit.cs @@ -40,7 +40,9 @@ namespace SanSystem else if(san is SchachtAnbindung) { tab.Text = "Schachtanbindung"; - + UCSchachtanbindung uCSchachtanbindung = new UCSchachtanbindung(san as SchachtAnbindung); + uCSchachtanbindung.Dock = DockStyle.Fill; + tab.Controls.Add(uCSchachtanbindung); tabControl1.TabPages.Add(tab); } } @@ -104,7 +106,9 @@ namespace SanSystem inspektionsobjekt.Sanierung.Add(schachtAnbindung); TabPage tab = new TabPage(); tab.Text = "Schachtanbindung"; - + UCSchachtanbindung uCSchachtanbindung = new UCSchachtanbindung(schachtAnbindung); + uCSchachtanbindung.Dock = DockStyle.Fill; + tab.Controls.Add(uCSchachtanbindung); tabControl1.TabPages.Add(tab); }