From 88323fcd29af1756a4c34f1da64febd4075897f2 Mon Sep 17 00:00:00 2001 From: HuskyTeufel Date: Fri, 9 Apr 2021 11:58:05 +0200 Subject: [PATCH] =?UTF-8?q?Stra=C3=9Fenliste=20code=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit radiobuttons hinzugefügt, noch kein Funktion --- SanSystem/SanSystem.csproj | 5 ++- SanSystem/StrassenContent.cs | 15 +++++++++ SanSystem/frmStrassenList.Designer.cs | 48 +++++++++++++++++++++------ SanSystem/frmStrassenList.cs | 18 ++++------ 4 files changed, 64 insertions(+), 22 deletions(-) create mode 100644 SanSystem/StrassenContent.cs diff --git a/SanSystem/SanSystem.csproj b/SanSystem/SanSystem.csproj index 65359a9..946ad01 100644 --- a/SanSystem/SanSystem.csproj +++ b/SanSystem/SanSystem.csproj @@ -218,7 +218,9 @@ frmSelectNewSan.cs - + + Form + frmStrassenList.cs @@ -233,6 +235,7 @@ + UserControl diff --git a/SanSystem/StrassenContent.cs b/SanSystem/StrassenContent.cs new file mode 100644 index 0000000..6b58362 --- /dev/null +++ b/SanSystem/StrassenContent.cs @@ -0,0 +1,15 @@ +namespace SanSystem +{ + class StrassenContent + { + public string Strassename; + public int AnzahlObjekte; + public int AnzahlFertig; + + public override string ToString() + { + return string.Format("{0} ({1} / {2})", Strassename, AnzahlFertig, AnzahlObjekte); + } + } + +} diff --git a/SanSystem/frmStrassenList.Designer.cs b/SanSystem/frmStrassenList.Designer.cs index ea1e4ff..8cfa24e 100644 --- a/SanSystem/frmStrassenList.Designer.cs +++ b/SanSystem/frmStrassenList.Designer.cs @@ -30,6 +30,8 @@ { this.lst_strassen = new System.Windows.Forms.ListBox(); this.btn_add = new System.Windows.Forms.Button(); + this.rdbtn_street = new System.Windows.Forms.RadioButton(); + this.rdbtn_ort = new System.Windows.Forms.RadioButton(); this.SuspendLayout(); // // lst_strassen @@ -39,11 +41,11 @@ | System.Windows.Forms.AnchorStyles.Right))); this.lst_strassen.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lst_strassen.FormattingEnabled = true; - this.lst_strassen.ItemHeight = 25; - this.lst_strassen.Location = new System.Drawing.Point(16, 122); - this.lst_strassen.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.lst_strassen.ItemHeight = 20; + this.lst_strassen.Location = new System.Drawing.Point(12, 130); + this.lst_strassen.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.lst_strassen.Name = "lst_strassen"; - this.lst_strassen.Size = new System.Drawing.Size(252, 529); + this.lst_strassen.Size = new System.Drawing.Size(190, 424); this.lst_strassen.TabIndex = 0; this.lst_strassen.DoubleClick += new System.EventHandler(this.lst_strassen_DoubleClick); // @@ -52,28 +54,52 @@ this.btn_add.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btn_add.Image = global::SanSystem.Properties.Resources.Add1; this.btn_add.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.btn_add.Location = new System.Drawing.Point(16, 15); - this.btn_add.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btn_add.Location = new System.Drawing.Point(12, 12); this.btn_add.Name = "btn_add"; - this.btn_add.Size = new System.Drawing.Size(251, 101); + this.btn_add.Size = new System.Drawing.Size(188, 82); this.btn_add.TabIndex = 1; this.btn_add.Text = "Neues \r\nObjekt hinzufügen"; this.btn_add.UseVisualStyleBackColor = true; this.btn_add.Click += new System.EventHandler(this.btn_add_Click); // + // rdbtn_street + // + this.rdbtn_street.AutoSize = true; + this.rdbtn_street.Location = new System.Drawing.Point(19, 107); + this.rdbtn_street.Name = "rdbtn_street"; + this.rdbtn_street.Size = new System.Drawing.Size(80, 17); + this.rdbtn_street.TabIndex = 2; + this.rdbtn_street.TabStop = true; + this.rdbtn_street.Text = "Straßenliste"; + this.rdbtn_street.UseVisualStyleBackColor = true; + // + // rdbtn_ort + // + this.rdbtn_ort.AutoSize = true; + this.rdbtn_ort.Location = new System.Drawing.Point(110, 107); + this.rdbtn_ort.Name = "rdbtn_ort"; + this.rdbtn_ort.Size = new System.Drawing.Size(63, 17); + this.rdbtn_ort.TabIndex = 3; + this.rdbtn_ort.TabStop = true; + this.rdbtn_ort.Text = "Ortsteile"; + this.rdbtn_ort.UseVisualStyleBackColor = true; + // // frmStrassenList // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(283, 672); + this.ClientSize = new System.Drawing.Size(212, 565); this.ControlBox = false; + this.Controls.Add(this.rdbtn_ort); + this.Controls.Add(this.rdbtn_street); this.Controls.Add(this.btn_add); this.Controls.Add(this.lst_strassen); - this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.Name = "frmStrassenList"; this.Text = "Strassen"; this.Load += new System.EventHandler(this.frmStrassenList_Load); this.ResumeLayout(false); + this.PerformLayout(); } @@ -81,5 +107,7 @@ private System.Windows.Forms.ListBox lst_strassen; private System.Windows.Forms.Button btn_add; + private System.Windows.Forms.RadioButton rdbtn_street; + private System.Windows.Forms.RadioButton rdbtn_ort; } } \ No newline at end of file diff --git a/SanSystem/frmStrassenList.cs b/SanSystem/frmStrassenList.cs index fe71965..1a19d80 100644 --- a/SanSystem/frmStrassenList.cs +++ b/SanSystem/frmStrassenList.cs @@ -13,17 +13,6 @@ using System.Windows.Forms; namespace SanSystem { - class StrassenContent - { - public string Strassename; - public int AnzahlObjekte; - public int AnzahlFertig; - - public override string ToString() - { - return string.Format("{0} ({1} / {2})", Strassename, AnzahlFertig, AnzahlObjekte); - } - } /// /// /// @@ -38,10 +27,17 @@ namespace SanSystem InitializeComponent(); } + bool mehrereOrteAktiv() + { + return Datenbank.Instance.loadedProjekt.Objekte.Select(x => x.OrtName).Distinct().Count() > 1; + } + private void buildStreetList() { lst_strassen.DataSource = null; if (Datenbank.Instance.loadedProjekt == null) return; + rdbtn_ort.Enabled = mehrereOrteAktiv(); + if (!mehrereOrteAktiv()) rdbtn_street.Checked = true; List strassen = Datenbank.Instance.loadedProjekt.Objekte.Select(x => x.StrasseName).Distinct().ToList(); List streets = new List(); List strassenContents = new List();