From 21ef130573220f8ba52717747c0466a1a050903a Mon Sep 17 00:00:00 2001 From: "de@itstall.de" <de@itstall.de> Date: Sun, 2 Feb 2020 23:48:23 +0100 Subject: [PATCH] Finished settings dialog closes:#7 closes:#4 closes:#3 --- Wetterstation/Form1.Designer.cs | 267 ++++++++++++---------- Wetterstation/Form1.cs | 149 +++--------- Wetterstation/Program.cs | 5 +- Wetterstation/Settings.Designer.cs | 354 ++++++++++++++++------------- Wetterstation/Settings.cs | 122 ++++------ Wetterstation/SettingsModel.cs | 12 +- Wetterstation/SqliteDataAccess.cs | 88 ++----- Wetterstation/frontend.db | Bin 557056 -> 557056 bytes 8 files changed, 443 insertions(+), 554 deletions(-) diff --git a/Wetterstation/Form1.Designer.cs b/Wetterstation/Form1.Designer.cs index fb941e2..7e0171c 100644 --- a/Wetterstation/Form1.Designer.cs +++ b/Wetterstation/Form1.Designer.cs @@ -36,10 +36,10 @@ namespace Wetterstation /// </summary> private void InitializeComponent() { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea3 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series(); - System.Windows.Forms.DataVisualization.Charting.Title title3 = new System.Windows.Forms.DataVisualization.Charting.Title(); + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Title title1 = new System.Windows.Forms.DataVisualization.Charting.Title(); this.lbTextInnentemp = new System.Windows.Forms.Label(); this.lbTextAussentemp = new System.Windows.Forms.Label(); this.lbTextWindSpeed = new System.Windows.Forms.Label(); @@ -97,9 +97,10 @@ namespace Wetterstation this.lbTextInnentemp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(99)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbTextInnentemp.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbTextInnentemp.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.lbTextInnentemp.Location = new System.Drawing.Point(160, 21); + this.lbTextInnentemp.Location = new System.Drawing.Point(213, 26); + this.lbTextInnentemp.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbTextInnentemp.Name = "lbTextInnentemp"; - this.lbTextInnentemp.Size = new System.Drawing.Size(163, 24); + this.lbTextInnentemp.Size = new System.Drawing.Size(203, 29); this.lbTextInnentemp.TabIndex = 0; this.lbTextInnentemp.Text = "Innentemperatur"; // @@ -109,9 +110,10 @@ namespace Wetterstation this.lbTextAussentemp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbTextAussentemp.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbTextAussentemp.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.lbTextAussentemp.Location = new System.Drawing.Point(152, 124); + this.lbTextAussentemp.Location = new System.Drawing.Point(203, 153); + this.lbTextAussentemp.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbTextAussentemp.Name = "lbTextAussentemp"; - this.lbTextAussentemp.Size = new System.Drawing.Size(180, 24); + this.lbTextAussentemp.Size = new System.Drawing.Size(224, 29); this.lbTextAussentemp.TabIndex = 1; this.lbTextAussentemp.Text = "Aussentemperatur"; // @@ -121,12 +123,12 @@ namespace Wetterstation this.lbTextWindSpeed.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbTextWindSpeed.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbTextWindSpeed.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.lbTextWindSpeed.Location = new System.Drawing.Point(582, 25); + this.lbTextWindSpeed.Location = new System.Drawing.Point(776, 31); + this.lbTextWindSpeed.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbTextWindSpeed.Name = "lbTextWindSpeed"; - this.lbTextWindSpeed.Size = new System.Drawing.Size(165, 18); + this.lbTextWindSpeed.Size = new System.Drawing.Size(208, 24); this.lbTextWindSpeed.TabIndex = 2; this.lbTextWindSpeed.Text = "Windgeschwindigkeit"; - this.lbTextWindSpeed.Click += new System.EventHandler(this.Windgeschwindigkeit_Click); // // lbTextLuftfeuchtInnen // @@ -134,12 +136,12 @@ namespace Wetterstation this.lbTextLuftfeuchtInnen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(99)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbTextLuftfeuchtInnen.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbTextLuftfeuchtInnen.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.lbTextLuftfeuchtInnen.Location = new System.Drawing.Point(402, 21); + this.lbTextLuftfeuchtInnen.Location = new System.Drawing.Point(536, 26); + this.lbTextLuftfeuchtInnen.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbTextLuftfeuchtInnen.Name = "lbTextLuftfeuchtInnen"; - this.lbTextLuftfeuchtInnen.Size = new System.Drawing.Size(149, 24); + this.lbTextLuftfeuchtInnen.Size = new System.Drawing.Size(189, 29); this.lbTextLuftfeuchtInnen.TabIndex = 3; this.lbTextLuftfeuchtInnen.Text = "Luftfeuchtigkeit"; - this.lbTextLuftfeuchtInnen.Click += new System.EventHandler(this.LbTextLuftfeucht_Click); // // Windrichtung // @@ -147,9 +149,10 @@ namespace Wetterstation this.Windrichtung.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.Windrichtung.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Windrichtung.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.Windrichtung.Location = new System.Drawing.Point(850, 21); + this.Windrichtung.Location = new System.Drawing.Point(1133, 26); + this.Windrichtung.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.Windrichtung.Name = "Windrichtung"; - this.Windrichtung.Size = new System.Drawing.Size(134, 24); + this.Windrichtung.Size = new System.Drawing.Size(165, 29); this.Windrichtung.TabIndex = 4; this.Windrichtung.Text = "Windrichtung"; // @@ -159,12 +162,12 @@ namespace Wetterstation this.pictureBox1.BackColor = System.Drawing.Color.Transparent; this.pictureBox1.BackgroundImage = global::Wetterstation.Properties.Resources.Kompassrose; this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.pictureBox1.Location = new System.Drawing.Point(871, 48); + this.pictureBox1.Location = new System.Drawing.Point(1161, 59); + this.pictureBox1.Margin = new System.Windows.Forms.Padding(4); this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(89, 90); + this.pictureBox1.Size = new System.Drawing.Size(119, 111); this.pictureBox1.TabIndex = 10; this.pictureBox1.TabStop = false; - this.pictureBox1.Click += new System.EventHandler(this.PictureBox1_Click); // // lbInnenTemp // @@ -172,12 +175,12 @@ namespace Wetterstation this.lbInnenTemp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbInnenTemp.Font = new System.Drawing.Font("Arial", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbInnenTemp.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.lbInnenTemp.Location = new System.Drawing.Point(133, 44); + this.lbInnenTemp.Location = new System.Drawing.Point(177, 54); + this.lbInnenTemp.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbInnenTemp.Name = "lbInnenTemp"; - this.lbInnenTemp.Size = new System.Drawing.Size(248, 75); + this.lbInnenTemp.Size = new System.Drawing.Size(306, 93); this.lbInnenTemp.TabIndex = 13; this.lbInnenTemp.Text = "23,3 C°"; - this.lbInnenTemp.BackColorChanged += new System.EventHandler(this.HierInnen_BackColorChanged); // // lbAussenTemp // @@ -186,12 +189,12 @@ namespace Wetterstation this.lbAussenTemp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbAussenTemp.Font = new System.Drawing.Font("Arial", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbAussenTemp.ForeColor = System.Drawing.Color.White; - this.lbAussenTemp.Location = new System.Drawing.Point(132, 151); + this.lbAussenTemp.Location = new System.Drawing.Point(176, 186); + this.lbAussenTemp.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbAussenTemp.Name = "lbAussenTemp"; - this.lbAussenTemp.Size = new System.Drawing.Size(248, 75); + this.lbAussenTemp.Size = new System.Drawing.Size(306, 93); this.lbAussenTemp.TabIndex = 15; this.lbAussenTemp.Text = "25,7 C°"; - this.lbAussenTemp.Click += new System.EventHandler(this.HierAussen_Click); // // lbWindSpeed // @@ -199,9 +202,10 @@ namespace Wetterstation this.lbWindSpeed.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbWindSpeed.Font = new System.Drawing.Font("Arial", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbWindSpeed.ForeColor = System.Drawing.SystemColors.ButtonFace; - this.lbWindSpeed.Location = new System.Drawing.Point(610, 45); + this.lbWindSpeed.Location = new System.Drawing.Point(813, 55); + this.lbWindSpeed.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbWindSpeed.Name = "lbWindSpeed"; - this.lbWindSpeed.Size = new System.Drawing.Size(113, 29); + this.lbWindSpeed.Size = new System.Drawing.Size(142, 35); this.lbWindSpeed.TabIndex = 16; this.lbWindSpeed.Text = "12 m/sec"; // @@ -211,12 +215,12 @@ namespace Wetterstation this.lbLuftFeuchtInnen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbLuftFeuchtInnen.Font = new System.Drawing.Font("Arial", 36F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbLuftFeuchtInnen.ForeColor = System.Drawing.SystemColors.ButtonFace; - this.lbLuftFeuchtInnen.Location = new System.Drawing.Point(410, 51); + this.lbLuftFeuchtInnen.Location = new System.Drawing.Point(547, 63); + this.lbLuftFeuchtInnen.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbLuftFeuchtInnen.Name = "lbLuftFeuchtInnen"; - this.lbLuftFeuchtInnen.Size = new System.Drawing.Size(133, 56); + this.lbLuftFeuchtInnen.Size = new System.Drawing.Size(164, 70); this.lbLuftFeuchtInnen.TabIndex = 17; this.lbLuftFeuchtInnen.Text = "36 %"; - this.lbLuftFeuchtInnen.Click += new System.EventHandler(this.LbLuftFeuchtInnen_Click); // // lbWindricht // @@ -224,9 +228,10 @@ namespace Wetterstation this.lbWindricht.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbWindricht.Font = new System.Drawing.Font("Arial", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbWindricht.ForeColor = System.Drawing.SystemColors.ButtonFace; - this.lbWindricht.Location = new System.Drawing.Point(889, 162); + this.lbWindricht.Location = new System.Drawing.Point(1185, 199); + this.lbWindricht.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbWindricht.Name = "lbWindricht"; - this.lbWindricht.Size = new System.Drawing.Size(50, 24); + this.lbWindricht.Size = new System.Drawing.Size(67, 32); this.lbWindricht.TabIndex = 18; this.lbWindricht.Text = "Süd"; // @@ -236,12 +241,12 @@ namespace Wetterstation this.lbUhr.BackColor = System.Drawing.Color.Transparent; this.lbUhr.Font = new System.Drawing.Font("Arial", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbUhr.ForeColor = System.Drawing.SystemColors.ButtonFace; - this.lbUhr.Location = new System.Drawing.Point(817, 656); + this.lbUhr.Location = new System.Drawing.Point(1089, 807); + this.lbUhr.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbUhr.Name = "lbUhr"; - this.lbUhr.Size = new System.Drawing.Size(105, 29); + this.lbUhr.Size = new System.Drawing.Size(137, 35); this.lbUhr.TabIndex = 19; this.lbUhr.Text = "22:56:12"; - this.lbUhr.Click += new System.EventHandler(this.HierUhr_Click); // // lbDatum // @@ -249,12 +254,12 @@ namespace Wetterstation this.lbDatum.BackColor = System.Drawing.Color.Transparent; this.lbDatum.Font = new System.Drawing.Font("Arial", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbDatum.ForeColor = System.Drawing.SystemColors.ButtonFace; - this.lbDatum.Location = new System.Drawing.Point(804, 696); + this.lbDatum.Location = new System.Drawing.Point(1072, 857); + this.lbDatum.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbDatum.Name = "lbDatum"; - this.lbDatum.Size = new System.Drawing.Size(118, 24); + this.lbDatum.Size = new System.Drawing.Size(151, 32); this.lbDatum.TabIndex = 20; this.lbDatum.Text = "24.12.1872"; - this.lbDatum.Click += new System.EventHandler(this.HierDatum_Click); // // lbTextTendenz // @@ -262,9 +267,10 @@ namespace Wetterstation this.lbTextTendenz.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(99)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbTextTendenz.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbTextTendenz.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.lbTextTendenz.Location = new System.Drawing.Point(36, 26); + this.lbTextTendenz.Location = new System.Drawing.Point(48, 32); + this.lbTextTendenz.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbTextTendenz.Name = "lbTextTendenz"; - this.lbTextTendenz.Size = new System.Drawing.Size(68, 16); + this.lbTextTendenz.Size = new System.Drawing.Size(80, 20); this.lbTextTendenz.TabIndex = 25; this.lbTextTendenz.Text = "Tendenz"; // @@ -274,9 +280,10 @@ namespace Wetterstation this.lbWT1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbWT1.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbWT1.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.lbWT1.Location = new System.Drawing.Point(127, 238); + this.lbWT1.Location = new System.Drawing.Point(169, 293); + this.lbWT1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbWT1.Name = "lbWT1"; - this.lbWT1.Size = new System.Drawing.Size(48, 47); + this.lbWT1.Size = new System.Drawing.Size(64, 58); this.lbWT1.TabIndex = 27; this.lbWT1.Text = "MO"; this.lbWT1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -284,20 +291,21 @@ namespace Wetterstation // picTg2 // this.picTg2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); - this.picTg2.Location = new System.Drawing.Point(177, 271); + this.picTg2.Location = new System.Drawing.Point(236, 334); + this.picTg2.Margin = new System.Windows.Forms.Padding(4); this.picTg2.Name = "picTg2"; - this.picTg2.Size = new System.Drawing.Size(53, 44); + this.picTg2.Size = new System.Drawing.Size(71, 54); this.picTg2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.picTg2.TabIndex = 29; this.picTg2.TabStop = false; - this.picTg2.Click += new System.EventHandler(this.PicTg2_Click); // // picTg3 // this.picTg3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); - this.picTg3.Location = new System.Drawing.Point(230, 271); + this.picTg3.Location = new System.Drawing.Point(307, 334); + this.picTg3.Margin = new System.Windows.Forms.Padding(4); this.picTg3.Name = "picTg3"; - this.picTg3.Size = new System.Drawing.Size(53, 44); + this.picTg3.Size = new System.Drawing.Size(71, 54); this.picTg3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.picTg3.TabIndex = 30; this.picTg3.TabStop = false; @@ -305,9 +313,10 @@ namespace Wetterstation // picTg4 // this.picTg4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); - this.picTg4.Location = new System.Drawing.Point(282, 271); + this.picTg4.Location = new System.Drawing.Point(376, 334); + this.picTg4.Margin = new System.Windows.Forms.Padding(4); this.picTg4.Name = "picTg4"; - this.picTg4.Size = new System.Drawing.Size(53, 44); + this.picTg4.Size = new System.Drawing.Size(71, 54); this.picTg4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.picTg4.TabIndex = 31; this.picTg4.TabStop = false; @@ -315,9 +324,10 @@ namespace Wetterstation // picTg5 // this.picTg5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); - this.picTg5.Location = new System.Drawing.Point(331, 271); + this.picTg5.Location = new System.Drawing.Point(441, 334); + this.picTg5.Margin = new System.Windows.Forms.Padding(4); this.picTg5.Name = "picTg5"; - this.picTg5.Size = new System.Drawing.Size(53, 44); + this.picTg5.Size = new System.Drawing.Size(71, 54); this.picTg5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.picTg5.TabIndex = 32; this.picTg5.TabStop = false; @@ -328,9 +338,10 @@ namespace Wetterstation this.lbWt2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbWt2.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbWt2.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.lbWt2.Location = new System.Drawing.Point(179, 238); + this.lbWt2.Location = new System.Drawing.Point(239, 293); + this.lbWt2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbWt2.Name = "lbWt2"; - this.lbWt2.Size = new System.Drawing.Size(48, 47); + this.lbWt2.Size = new System.Drawing.Size(64, 58); this.lbWt2.TabIndex = 33; this.lbWt2.Text = "DI"; this.lbWt2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -341,9 +352,10 @@ namespace Wetterstation this.lbWt3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbWt3.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbWt3.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.lbWt3.Location = new System.Drawing.Point(234, 238); + this.lbWt3.Location = new System.Drawing.Point(312, 293); + this.lbWt3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbWt3.Name = "lbWt3"; - this.lbWt3.Size = new System.Drawing.Size(48, 47); + this.lbWt3.Size = new System.Drawing.Size(64, 58); this.lbWt3.TabIndex = 34; this.lbWt3.Text = "Mi"; this.lbWt3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -354,9 +366,10 @@ namespace Wetterstation this.lbWt4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbWt4.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbWt4.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.lbWt4.Location = new System.Drawing.Point(282, 238); + this.lbWt4.Location = new System.Drawing.Point(376, 293); + this.lbWt4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbWt4.Name = "lbWt4"; - this.lbWt4.Size = new System.Drawing.Size(48, 47); + this.lbWt4.Size = new System.Drawing.Size(64, 58); this.lbWt4.TabIndex = 35; this.lbWt4.Text = "DO"; this.lbWt4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -367,9 +380,10 @@ namespace Wetterstation this.lbWt5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbWt5.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbWt5.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.lbWt5.Location = new System.Drawing.Point(333, 238); + this.lbWt5.Location = new System.Drawing.Point(444, 293); + this.lbWt5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbWt5.Name = "lbWt5"; - this.lbWt5.Size = new System.Drawing.Size(48, 47); + this.lbWt5.Size = new System.Drawing.Size(64, 58); this.lbWt5.TabIndex = 36; this.lbWt5.Text = "FR"; this.lbWt5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -380,12 +394,12 @@ namespace Wetterstation this.lbLuftfeuchtAussen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbLuftfeuchtAussen.Font = new System.Drawing.Font("Arial", 36F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbLuftfeuchtAussen.ForeColor = System.Drawing.SystemColors.ButtonFace; - this.lbLuftfeuchtAussen.Location = new System.Drawing.Point(412, 159); + this.lbLuftfeuchtAussen.Location = new System.Drawing.Point(549, 196); + this.lbLuftfeuchtAussen.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbLuftfeuchtAussen.Name = "lbLuftfeuchtAussen"; - this.lbLuftfeuchtAussen.Size = new System.Drawing.Size(133, 56); + this.lbLuftfeuchtAussen.Size = new System.Drawing.Size(164, 70); this.lbLuftfeuchtAussen.TabIndex = 37; this.lbLuftfeuchtAussen.Text = "36 %"; - this.lbLuftfeuchtAussen.Click += new System.EventHandler(this.LbLuftfeuchtAussen_Click); // // lbTextLuftfeuchtAussen // @@ -393,9 +407,10 @@ namespace Wetterstation this.lbTextLuftfeuchtAussen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(99)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbTextLuftfeuchtAussen.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbTextLuftfeuchtAussen.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.lbTextLuftfeuchtAussen.Location = new System.Drawing.Point(402, 124); + this.lbTextLuftfeuchtAussen.Location = new System.Drawing.Point(536, 153); + this.lbTextLuftfeuchtAussen.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbTextLuftfeuchtAussen.Name = "lbTextLuftfeuchtAussen"; - this.lbTextLuftfeuchtAussen.Size = new System.Drawing.Size(149, 24); + this.lbTextLuftfeuchtAussen.Size = new System.Drawing.Size(189, 29); this.lbTextLuftfeuchtAussen.TabIndex = 38; this.lbTextLuftfeuchtAussen.Text = "Luftfeuchtigkeit"; // @@ -405,9 +420,10 @@ namespace Wetterstation this.lbTextLuftdruck.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbTextLuftdruck.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbTextLuftdruck.ForeColor = System.Drawing.SystemColors.ButtonHighlight; - this.lbTextLuftdruck.Location = new System.Drawing.Point(623, 86); + this.lbTextLuftdruck.Location = new System.Drawing.Point(831, 106); + this.lbTextLuftdruck.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbTextLuftdruck.Name = "lbTextLuftdruck"; - this.lbTextLuftdruck.Size = new System.Drawing.Size(85, 20); + this.lbTextLuftdruck.Size = new System.Drawing.Size(101, 25); this.lbTextLuftdruck.TabIndex = 39; this.lbTextLuftdruck.Text = "Luftdruck"; // @@ -417,39 +433,42 @@ namespace Wetterstation this.lbLuftdruck.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbLuftdruck.Font = new System.Drawing.Font("Arial", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbLuftdruck.ForeColor = System.Drawing.SystemColors.ButtonFace; - this.lbLuftdruck.Location = new System.Drawing.Point(615, 107); + this.lbLuftdruck.Location = new System.Drawing.Point(820, 132); + this.lbLuftdruck.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbLuftdruck.Name = "lbLuftdruck"; - this.lbLuftdruck.Size = new System.Drawing.Size(103, 29); + this.lbLuftdruck.Size = new System.Drawing.Size(129, 35); this.lbLuftdruck.TabIndex = 40; this.lbLuftdruck.Text = "999 hPa"; // // chart1 // this.chart1.Anchor = System.Windows.Forms.AnchorStyles.None; - chartArea3.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea3); - legend3.Name = "Legend1"; - this.chart1.Legends.Add(legend3); - this.chart1.Location = new System.Drawing.Point(28, 546); + chartArea1.Name = "ChartArea1"; + this.chart1.ChartAreas.Add(chartArea1); + legend1.Name = "Legend1"; + this.chart1.Legends.Add(legend1); + this.chart1.Location = new System.Drawing.Point(37, 672); + this.chart1.Margin = new System.Windows.Forms.Padding(4); this.chart1.Name = "chart1"; this.chart1.Palette = System.Windows.Forms.DataVisualization.Charting.ChartColorPalette.Excel; - series3.ChartArea = "ChartArea1"; - series3.Legend = "Legend1"; - series3.Name = "Series1"; - this.chart1.Series.Add(series3); - this.chart1.Size = new System.Drawing.Size(743, 107); + series1.ChartArea = "ChartArea1"; + series1.Legend = "Legend1"; + series1.Name = "Series1"; + this.chart1.Series.Add(series1); + this.chart1.Size = new System.Drawing.Size(991, 132); this.chart1.TabIndex = 41; this.chart1.Text = "chTendenz"; - title3.Name = "Title1"; - this.chart1.Titles.Add(title3); + title1.Name = "Title1"; + this.chart1.Titles.Add(title1); // // lbHintergrund // this.lbHintergrund.Anchor = System.Windows.Forms.AnchorStyles.None; this.lbHintergrund.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(99)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); - this.lbHintergrund.Location = new System.Drawing.Point(12, 18); + this.lbHintergrund.Location = new System.Drawing.Point(16, 22); + this.lbHintergrund.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbHintergrund.Name = "lbHintergrund"; - this.lbHintergrund.Size = new System.Drawing.Size(984, 301); + this.lbHintergrund.Size = new System.Drawing.Size(1312, 370); this.lbHintergrund.TabIndex = 42; // // lbCity @@ -457,9 +476,10 @@ namespace Wetterstation this.lbCity.BackColor = System.Drawing.Color.Transparent; this.lbCity.Font = new System.Drawing.Font("Arial Black", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbCity.ForeColor = System.Drawing.Color.White; - this.lbCity.Location = new System.Drawing.Point(0, 656); + this.lbCity.Location = new System.Drawing.Point(0, 807); + this.lbCity.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbCity.Name = "lbCity"; - this.lbCity.Size = new System.Drawing.Size(1007, 50); + this.lbCity.Size = new System.Drawing.Size(1343, 62); this.lbCity.TabIndex = 43; this.lbCity.Text = "Marienhausen"; this.lbCity.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -467,9 +487,10 @@ namespace Wetterstation // picTg1 // this.picTg1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); - this.picTg1.Location = new System.Drawing.Point(124, 271); + this.picTg1.Location = new System.Drawing.Point(165, 334); + this.picTg1.Margin = new System.Windows.Forms.Padding(4); this.picTg1.Name = "picTg1"; - this.picTg1.Size = new System.Drawing.Size(53, 44); + this.picTg1.Size = new System.Drawing.Size(71, 54); this.picTg1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.picTg1.TabIndex = 44; this.picTg1.TabStop = false; @@ -479,9 +500,10 @@ namespace Wetterstation this.btSystemKnopf.BackColor = System.Drawing.Color.Transparent; this.btSystemKnopf.BackgroundImage = global::Wetterstation.Properties.Resources.Zahnrad12; this.btSystemKnopf.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.btSystemKnopf.Location = new System.Drawing.Point(966, 687); + this.btSystemKnopf.Location = new System.Drawing.Point(1288, 846); + this.btSystemKnopf.Margin = new System.Windows.Forms.Padding(4); this.btSystemKnopf.Name = "btSystemKnopf"; - this.btSystemKnopf.Size = new System.Drawing.Size(30, 30); + this.btSystemKnopf.Size = new System.Drawing.Size(40, 37); this.btSystemKnopf.TabIndex = 46; this.btSystemKnopf.TextAlign = System.Drawing.ContentAlignment.TopLeft; this.btSystemKnopf.UseVisualStyleBackColor = false; @@ -490,100 +512,110 @@ namespace Wetterstation // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(75, 493); + this.label1.Location = new System.Drawing.Point(100, 607); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(29, 13); + this.label1.Size = new System.Drawing.Size(37, 17); this.label1.TabIndex = 47; this.label1.Text = "max."; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(75, 515); + this.label2.Location = new System.Drawing.Point(100, 634); + this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(26, 13); + this.label2.Size = new System.Drawing.Size(34, 17); this.label2.TabIndex = 48; this.label2.Text = "min."; // // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(122, 474); + this.label4.Location = new System.Drawing.Point(163, 583); + this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(34, 13); + this.label4.Size = new System.Drawing.Size(43, 17); this.label4.TabIndex = 49; this.label4.Text = "Innen"; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(215, 474); + this.label3.Location = new System.Drawing.Point(287, 583); + this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(42, 13); + this.label3.Size = new System.Drawing.Size(55, 17); this.label3.TabIndex = 50; this.label3.Text = "Aussen"; // // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(121, 493); + this.label5.Location = new System.Drawing.Point(161, 607); + this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(72, 13); + this.label5.Size = new System.Drawing.Size(55, 17); this.label5.TabIndex = 51; - this.label5.Text = "12,4 C° 17:45"; + this.label5.Text = "12,4 C°"; // // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(211, 493); + this.label6.Location = new System.Drawing.Point(281, 607); + this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(72, 13); + this.label6.Size = new System.Drawing.Size(47, 17); this.label6.TabIndex = 52; - this.label6.Text = "2,4 C° 22:67h"; + this.label6.Text = "2,4 C°"; // // label7 // this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(211, 515); + this.label7.Location = new System.Drawing.Point(281, 634); + this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(72, 13); + this.label7.Size = new System.Drawing.Size(47, 17); this.label7.TabIndex = 54; - this.label7.Text = "2,4 C° 22:67h"; + this.label7.Text = "2,4 C°"; // // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(121, 515); + this.label8.Location = new System.Drawing.Point(161, 634); + this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(72, 13); + this.label8.Size = new System.Drawing.Size(55, 17); this.label8.TabIndex = 53; - this.label8.Text = "12,4 C° 17:45"; + this.label8.Text = "12,4 C°"; // // label9 // this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(243, 225); + this.label9.Location = new System.Drawing.Point(324, 277); + this.label9.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(72, 13); + this.label9.Size = new System.Drawing.Size(47, 17); this.label9.TabIndex = 56; - this.label9.Text = "2,4 C° 22:67h"; + this.label9.Text = "2,4 C°"; // // label10 // this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(153, 225); + this.label10.Location = new System.Drawing.Point(204, 277); + this.label10.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(72, 13); + this.label10.Size = new System.Drawing.Size(55, 17); this.label10.TabIndex = 55; - this.label10.Text = "12,4 C° 17:45"; + this.label10.Text = "12,4 C°"; // // Hintergrund // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackgroundImage = global::Wetterstation.Properties.Resources.Bild_Dennis_Formatiert; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.ClientSize = new System.Drawing.Size(1008, 729); + this.ClientSize = new System.Drawing.Size(1344, 897); this.Controls.Add(this.label9); this.Controls.Add(this.label10); this.Controls.Add(this.label7); @@ -627,8 +659,9 @@ namespace Wetterstation this.Controls.Add(this.lbHintergrund); this.Controls.Add(this.lbCity); this.DoubleBuffered = true; + this.Margin = new System.Windows.Forms.Padding(4); this.Name = "Hintergrund"; - this.Text = "Wetterstation C++ Kurs Alfatraining Dozent Karol Lassota"; + this.Text = "Wetterstation"; this.Load += new System.EventHandler(this.Hintergrund_Load); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picTg2)).EndInit(); diff --git a/Wetterstation/Form1.cs b/Wetterstation/Form1.cs index 94bcd1b..b448cc6 100644 --- a/Wetterstation/Form1.cs +++ b/Wetterstation/Form1.cs @@ -1,11 +1,6 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Drawing; -using System.Linq; using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; using uPLibrary.Networking.M2Mqtt; using uPLibrary.Networking.M2Mqtt.Messages; @@ -16,59 +11,16 @@ namespace Wetterstation public partial class Hintergrund : Form { private MqttClient myClient; - + SettingsModel WeatherstationSettings = new SettingsModel(); public Hintergrund() { InitializeComponent(); + WeatherstationSettings = SqliteDataAccess.LoadWeatherstationSettings(); + lbCity.Text = WeatherstationSettings.city; mqttStart(); } - private void InnenTemp_TextChanged(object sender, EventArgs e) - { - - } - - private void AussenTemp_TextChanged(object sender, EventArgs e) - { - - } - - private void WindSpeed_TextChanged(object sender, EventArgs e) - { - - } - - private void LuftFeucht_TextChanged(object sender, EventArgs e) - { - - } - - private void WindRicht_TextChanged(object sender, EventArgs e) - { - - } - - private void Uhrzeit_Click(object sender, EventArgs e) - { - - } - - private void HierAussen_Click(object sender, EventArgs e) - { - - } - - private void Windgeschwindigkeit_Click(object sender, EventArgs e) - { - - } - - private void HierDatum_Click(object sender, EventArgs e) - { - - } - private void LED_Click(object sender, EventArgs e) { @@ -110,46 +62,6 @@ namespace Wetterstation formGraphics.Dispose(); } - private void HierUhr_Click(object sender, EventArgs e) - { - - } - - private void HierInnen_Click(object sender, EventArgs e) - { - - } - - private void HierInnen_BackColorChanged(object sender, EventArgs e) - { - - } - - private void LbTextLuftfeucht_Click(object sender, EventArgs e) - { - - } - - private void PicTg2_Click(object sender, EventArgs e) - { - - } - - private void PictureBox1_Click(object sender, EventArgs e) - { - - } - - private void Hintergrund_Load(object sender, EventArgs e) - { - - } - - private void LbLuftfeuchtAussen_Click(object sender, EventArgs e) - { - - } - //MQTT connect public void mqttStart() { @@ -172,25 +84,11 @@ namespace Wetterstation this.myClient.Publish(topic_publish, Encoding.UTF8.GetBytes("Request_frontend")); } - public void updateForm(String message) - { - try - { - dynamic weatherData = JsonConvert.DeserializeObject(message.ToString()); - //hierAussen.Invoke(new Action(() => { hierAussen.Text = weatherData.current.temp + " °C"; })); - lbAussenTemp.Invoke(new Action(() => { lbAussenTemp.Text = weatherData.sensors[1].temperature + " °C"; })); - - //lbLuftFeuchtInnen.Invoke(new Action(() => { lbLuftFeuchtInnen.Text = weatherData.sensors[0].humidity + " %"; })); - //lblpressure.Invoke(new Action(() => { lblpressure.Text = weatherData.result.current.pressure; })); - //lblrain3h.Invoke(new Action(() => { lblrain3h.Text = weatherData.result.current.rain3h; })); - //lblsnow3h.Invoke(new Action(() => { lblsnow3h.Text = weatherData.result.current.snow3h; })); - //lbltemp.Invoke(new Action(() => { lbltemp.Text = weatherData.result.current.temp; })); - } - catch (Exception ignored) { } - } - public void msgPublish(String topic, String message) { + Console.Write("Sending via MQTT: "); + Console.Write("Topic: " + topic); + Console.WriteLine("Message: " + message); this.myClient.Publish(topic, Encoding.UTF8.GetBytes(message)); } @@ -200,19 +98,42 @@ namespace Wetterstation var message = System.Text.Encoding.Default.GetString(e.Message); System.Console.WriteLine("Message received: " + message); - this.updateForm(message); + this.updateFormWeather(message); + } + + private void BtSystemKnopf_Click(object sender, EventArgs e) + { + Form settings = new Settings(); + // abhängig von Form1 + settings.ShowDialog(); + updateFormComplete(); + this.updateSettings2Mqtt(); + } + + public void updateFormWeather(String message) + { + try + { + dynamic weatherData = JsonConvert.DeserializeObject(message.ToString()); + lbAussenTemp.Invoke(new Action(() => { lbAussenTemp.Text = weatherData.sensors[1].temperature + " °C"; })); + } + catch (Exception ignored) { } } - private void LbLuftFeuchtInnen_Click(object sender, EventArgs e) + public void updateFormComplete() { + WeatherstationSettings = SqliteDataAccess.LoadWeatherstationSettings(); + lbCity.Text = WeatherstationSettings.city; + } + public void updateSettings2Mqtt() + { + Console.WriteLine(JsonConvert.SerializeObject(WeatherstationSettings).ToString()); + this.msgPublish(WeatherstationSettings.mqtt_topic_backend + WeatherstationSettings.frontendId + "/settings", JsonConvert.SerializeObject(WeatherstationSettings).ToString()); } - private void BtSystemKnopf_Click(object sender, EventArgs e) + private void Hintergrund_Load(object sender, EventArgs e) { - Form frm = new Settings(); - // abhängig von Form1 - frm.Show(this); } } diff --git a/Wetterstation/Program.cs b/Wetterstation/Program.cs index 0254cde..2d932e2 100644 --- a/Wetterstation/Program.cs +++ b/Wetterstation/Program.cs @@ -18,9 +18,8 @@ namespace Wetterstation static void Main() { Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Hintergrund()); - Application.Run(new Settings()); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Hintergrund()); } } } diff --git a/Wetterstation/Settings.Designer.cs b/Wetterstation/Settings.Designer.cs index 46fce46..3a731bc 100644 --- a/Wetterstation/Settings.Designer.cs +++ b/Wetterstation/Settings.Designer.cs @@ -28,9 +28,7 @@ /// </summary> private void InitializeComponent() { - this.lbSettingsHost = new System.Windows.Forms.Label(); this.tbHost = new System.Windows.Forms.TextBox(); - this.lbSettingsPort = new System.Windows.Forms.Label(); this.tbPort = new System.Windows.Forms.TextBox(); this.lbUser = new System.Windows.Forms.Label(); this.tbUser = new System.Windows.Forms.TextBox(); @@ -39,65 +37,42 @@ this.lbFrontend = new System.Windows.Forms.Label(); this.tbTopicFrontend = new System.Windows.Forms.TextBox(); this.lbBackend = new System.Windows.Forms.Label(); - this.tbTobicBackend = new System.Windows.Forms.TextBox(); + this.tbTopicBackend = new System.Windows.Forms.TextBox(); this.lbQos = new System.Windows.Forms.Label(); this.tbQos = new System.Windows.Forms.TextBox(); this.lbTimeout = new System.Windows.Forms.Label(); this.tbTimeout = new System.Windows.Forms.TextBox(); this.lbPlz = new System.Windows.Forms.Label(); - this.tbPlz = new System.Windows.Forms.TextBox(); - this.lblFrontendId = new System.Windows.Forms.Label(); + this.tbCity = new System.Windows.Forms.TextBox(); this.btnSave = new System.Windows.Forms.Button(); + this.lbFrontendId = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.txtPlz = new System.Windows.Forms.Label(); + this.tbLngCode = new System.Windows.Forms.TextBox(); + this.lbLngCode = new System.Windows.Forms.Label(); this.SuspendLayout(); // - // lbSettingsHost - // - this.lbSettingsHost.Anchor = System.Windows.Forms.AnchorStyles.None; - this.lbSettingsHost.AutoSize = true; - this.lbSettingsHost.BackColor = System.Drawing.Color.Transparent; - this.lbSettingsHost.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbSettingsHost.ForeColor = System.Drawing.Color.DarkSlateGray; - this.lbSettingsHost.Location = new System.Drawing.Point(28, 50); - this.lbSettingsHost.Name = "lbSettingsHost"; - this.lbSettingsHost.Size = new System.Drawing.Size(54, 24); - this.lbSettingsHost.TabIndex = 0; - this.lbSettingsHost.Text = "Host"; - // // tbHost // - this.tbHost.Anchor = System.Windows.Forms.AnchorStyles.None; this.tbHost.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tbHost.Location = new System.Drawing.Point(13, 96); - this.tbHost.Margin = new System.Windows.Forms.Padding(4); - this.tbHost.MinimumSize = new System.Drawing.Size(399, 30); + this.tbHost.Location = new System.Drawing.Point(14, 76); + this.tbHost.Margin = new System.Windows.Forms.Padding(5); + this.tbHost.MinimumSize = new System.Drawing.Size(531, 30); this.tbHost.Name = "tbHost"; - this.tbHost.Size = new System.Drawing.Size(399, 35); - this.tbHost.TabIndex = 4; - this.tbHost.TextChanged += new System.EventHandler(this.TbSettingsHost_TextChanged); - // - // lbSettingsPort - // - this.lbSettingsPort.Anchor = System.Windows.Forms.AnchorStyles.None; - this.lbSettingsPort.AutoSize = true; - this.lbSettingsPort.BackColor = System.Drawing.Color.Transparent; - this.lbSettingsPort.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbSettingsPort.ForeColor = System.Drawing.Color.DarkSlateGray; - this.lbSettingsPort.Location = new System.Drawing.Point(28, 100); - this.lbSettingsPort.Name = "lbSettingsPort"; - this.lbSettingsPort.Size = new System.Drawing.Size(74, 16); - this.lbSettingsPort.TabIndex = 5; - this.lbSettingsPort.Text = "Port (1883)"; + this.tbHost.Size = new System.Drawing.Size(531, 35); + this.tbHost.TabIndex = 1; // // tbPort // - this.tbPort.Anchor = System.Windows.Forms.AnchorStyles.None; this.tbPort.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tbPort.Location = new System.Drawing.Point(13, 172); - this.tbPort.Margin = new System.Windows.Forms.Padding(4); - this.tbPort.MinimumSize = new System.Drawing.Size(399, 30); + this.tbPort.Location = new System.Drawing.Point(14, 145); + this.tbPort.Margin = new System.Windows.Forms.Padding(5); + this.tbPort.MinimumSize = new System.Drawing.Size(531, 30); this.tbPort.Name = "tbPort"; - this.tbPort.Size = new System.Drawing.Size(399, 35); - this.tbPort.TabIndex = 6; + this.tbPort.Size = new System.Drawing.Size(531, 35); + this.tbPort.TabIndex = 2; // // lbUser // @@ -105,34 +80,33 @@ this.lbUser.BackColor = System.Drawing.Color.Transparent; this.lbUser.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbUser.ForeColor = System.Drawing.Color.White; - this.lbUser.Location = new System.Drawing.Point(31, 229); - this.lbUser.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbUser.Location = new System.Drawing.Point(14, 185); + this.lbUser.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.lbUser.Name = "lbUser"; - this.lbUser.Size = new System.Drawing.Size(54, 24); + this.lbUser.Size = new System.Drawing.Size(119, 24); this.lbUser.TabIndex = 7; - this.lbUser.Text = "User"; + this.lbUser.Text = "MQTT User"; // // tbUser // - this.tbUser.Anchor = System.Windows.Forms.AnchorStyles.None; this.tbUser.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tbUser.Location = new System.Drawing.Point(15, 252); - this.tbUser.Margin = new System.Windows.Forms.Padding(4); - this.tbUser.MinimumSize = new System.Drawing.Size(399, 30); + this.tbUser.Location = new System.Drawing.Point(14, 214); + this.tbUser.Margin = new System.Windows.Forms.Padding(5); + this.tbUser.MinimumSize = new System.Drawing.Size(531, 30); this.tbUser.Name = "tbUser"; - this.tbUser.Size = new System.Drawing.Size(399, 35); - this.tbUser.TabIndex = 8; + this.tbUser.Size = new System.Drawing.Size(531, 35); + this.tbUser.TabIndex = 3; // // tbPasswort // - this.tbPasswort.Anchor = System.Windows.Forms.AnchorStyles.None; this.tbPasswort.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tbPasswort.Location = new System.Drawing.Point(15, 333); - this.tbPasswort.Margin = new System.Windows.Forms.Padding(4); - this.tbPasswort.MinimumSize = new System.Drawing.Size(399, 30); + this.tbPasswort.Location = new System.Drawing.Point(14, 283); + this.tbPasswort.Margin = new System.Windows.Forms.Padding(5); + this.tbPasswort.MinimumSize = new System.Drawing.Size(531, 30); this.tbPasswort.Name = "tbPasswort"; - this.tbPasswort.Size = new System.Drawing.Size(399, 35); - this.tbPasswort.TabIndex = 9; + this.tbPasswort.Size = new System.Drawing.Size(531, 35); + this.tbPasswort.TabIndex = 4; + this.tbPasswort.UseSystemPasswordChar = true; // // lbPasswort // @@ -140,12 +114,12 @@ this.lbPasswort.BackColor = System.Drawing.Color.Transparent; this.lbPasswort.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbPasswort.ForeColor = System.Drawing.Color.White; - this.lbPasswort.Location = new System.Drawing.Point(31, 307); - this.lbPasswort.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbPasswort.Location = new System.Drawing.Point(14, 254); + this.lbPasswort.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.lbPasswort.Name = "lbPasswort"; - this.lbPasswort.Size = new System.Drawing.Size(109, 24); + this.lbPasswort.Size = new System.Drawing.Size(174, 24); this.lbPasswort.TabIndex = 10; - this.lbPasswort.Text = "Passswort"; + this.lbPasswort.Text = "MQTT Passswort"; // // lbFrontend // @@ -153,24 +127,22 @@ this.lbFrontend.BackColor = System.Drawing.Color.Transparent; this.lbFrontend.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbFrontend.ForeColor = System.Drawing.Color.White; - this.lbFrontend.Location = new System.Drawing.Point(31, 390); - this.lbFrontend.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbFrontend.Location = new System.Drawing.Point(14, 323); + this.lbFrontend.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.lbFrontend.Name = "lbFrontend"; - this.lbFrontend.Size = new System.Drawing.Size(154, 24); + this.lbFrontend.Size = new System.Drawing.Size(219, 24); this.lbFrontend.TabIndex = 11; - this.lbFrontend.Text = "Topic Frontend"; + this.lbFrontend.Text = "MQTT Topic Frontend"; // // tbTopicFrontend // - this.tbTopicFrontend.Anchor = System.Windows.Forms.AnchorStyles.None; this.tbTopicFrontend.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tbTopicFrontend.Location = new System.Drawing.Point(13, 414); - this.tbTopicFrontend.Margin = new System.Windows.Forms.Padding(4); - this.tbTopicFrontend.MinimumSize = new System.Drawing.Size(399, 30); + this.tbTopicFrontend.Location = new System.Drawing.Point(14, 352); + this.tbTopicFrontend.Margin = new System.Windows.Forms.Padding(5); + this.tbTopicFrontend.MinimumSize = new System.Drawing.Size(531, 30); this.tbTopicFrontend.Name = "tbTopicFrontend"; - this.tbTopicFrontend.Size = new System.Drawing.Size(399, 35); - this.tbTopicFrontend.TabIndex = 12; - this.tbTopicFrontend.TextChanged += new System.EventHandler(this.TextBox1_TextChanged); + this.tbTopicFrontend.Size = new System.Drawing.Size(531, 35); + this.tbTopicFrontend.TabIndex = 5; // // lbBackend // @@ -178,23 +150,22 @@ this.lbBackend.BackColor = System.Drawing.Color.Transparent; this.lbBackend.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbBackend.ForeColor = System.Drawing.Color.White; - this.lbBackend.Location = new System.Drawing.Point(31, 480); - this.lbBackend.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbBackend.Location = new System.Drawing.Point(14, 392); + this.lbBackend.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.lbBackend.Name = "lbBackend"; - this.lbBackend.Size = new System.Drawing.Size(150, 24); + this.lbBackend.Size = new System.Drawing.Size(215, 24); this.lbBackend.TabIndex = 13; - this.lbBackend.Text = "Topic Backend"; + this.lbBackend.Text = "MQTT Topic Backend"; // - // tbTobicBackend + // tbTopicBackend // - this.tbTobicBackend.Anchor = System.Windows.Forms.AnchorStyles.None; - this.tbTobicBackend.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tbTobicBackend.Location = new System.Drawing.Point(13, 503); - this.tbTobicBackend.Margin = new System.Windows.Forms.Padding(4); - this.tbTobicBackend.MinimumSize = new System.Drawing.Size(399, 30); - this.tbTobicBackend.Name = "tbTobicBackend"; - this.tbTobicBackend.Size = new System.Drawing.Size(399, 35); - this.tbTobicBackend.TabIndex = 14; + this.tbTopicBackend.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tbTopicBackend.Location = new System.Drawing.Point(14, 421); + this.tbTopicBackend.Margin = new System.Windows.Forms.Padding(5); + this.tbTopicBackend.MinimumSize = new System.Drawing.Size(531, 30); + this.tbTopicBackend.Name = "tbTopicBackend"; + this.tbTopicBackend.Size = new System.Drawing.Size(531, 35); + this.tbTopicBackend.TabIndex = 6; // // lbQos // @@ -202,24 +173,22 @@ this.lbQos.BackColor = System.Drawing.Color.Transparent; this.lbQos.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbQos.ForeColor = System.Drawing.Color.White; - this.lbQos.Location = new System.Drawing.Point(29, 574); - this.lbQos.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbQos.Location = new System.Drawing.Point(14, 461); + this.lbQos.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.lbQos.Name = "lbQos"; - this.lbQos.Size = new System.Drawing.Size(98, 24); + this.lbQos.Size = new System.Drawing.Size(114, 24); this.lbQos.TabIndex = 15; - this.lbQos.Text = "Mqtt Qos"; + this.lbQos.Text = "MQTT Qos"; // // tbQos // - this.tbQos.Anchor = System.Windows.Forms.AnchorStyles.None; this.tbQos.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tbQos.Location = new System.Drawing.Point(12, 597); - this.tbQos.Margin = new System.Windows.Forms.Padding(4); - this.tbQos.MinimumSize = new System.Drawing.Size(399, 30); + this.tbQos.Location = new System.Drawing.Point(14, 490); + this.tbQos.Margin = new System.Windows.Forms.Padding(5); + this.tbQos.MinimumSize = new System.Drawing.Size(531, 30); this.tbQos.Name = "tbQos"; - this.tbQos.Size = new System.Drawing.Size(399, 35); - this.tbQos.TabIndex = 16; - this.tbQos.TextChanged += new System.EventHandler(this.TextBox2_TextChanged); + this.tbQos.Size = new System.Drawing.Size(531, 35); + this.tbQos.TabIndex = 7; // // lbTimeout // @@ -227,23 +196,22 @@ this.lbTimeout.BackColor = System.Drawing.Color.Transparent; this.lbTimeout.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbTimeout.ForeColor = System.Drawing.Color.White; - this.lbTimeout.Location = new System.Drawing.Point(28, 668); - this.lbTimeout.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbTimeout.Location = new System.Drawing.Point(14, 530); + this.lbTimeout.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.lbTimeout.Name = "lbTimeout"; - this.lbTimeout.Size = new System.Drawing.Size(87, 24); + this.lbTimeout.Size = new System.Drawing.Size(152, 24); this.lbTimeout.TabIndex = 17; - this.lbTimeout.Text = "Timeout"; + this.lbTimeout.Text = "MQTT Timeout"; // // tbTimeout // - this.tbTimeout.Anchor = System.Windows.Forms.AnchorStyles.None; this.tbTimeout.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tbTimeout.Location = new System.Drawing.Point(15, 691); - this.tbTimeout.Margin = new System.Windows.Forms.Padding(4); - this.tbTimeout.MinimumSize = new System.Drawing.Size(399, 30); + this.tbTimeout.Location = new System.Drawing.Point(14, 559); + this.tbTimeout.Margin = new System.Windows.Forms.Padding(5); + this.tbTimeout.MinimumSize = new System.Drawing.Size(531, 30); this.tbTimeout.Name = "tbTimeout"; - this.tbTimeout.Size = new System.Drawing.Size(399, 35); - this.tbTimeout.TabIndex = 18; + this.tbTimeout.Size = new System.Drawing.Size(531, 35); + this.tbTimeout.TabIndex = 8; // // lbPlz // @@ -251,63 +219,138 @@ this.lbPlz.BackColor = System.Drawing.Color.Transparent; this.lbPlz.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbPlz.ForeColor = System.Drawing.Color.White; - this.lbPlz.Location = new System.Drawing.Point(36, 754); - this.lbPlz.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbPlz.Location = new System.Drawing.Point(14, 668); + this.lbPlz.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.lbPlz.Name = "lbPlz"; - this.lbPlz.Size = new System.Drawing.Size(64, 24); + this.lbPlz.Size = new System.Drawing.Size(41, 24); this.lbPlz.TabIndex = 19; - this.lbPlz.Text = "CityId"; - this.lbPlz.Click += new System.EventHandler(this.Label1_Click); - // - // tbPlz - // - this.tbPlz.Anchor = System.Windows.Forms.AnchorStyles.None; - this.tbPlz.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tbPlz.Location = new System.Drawing.Point(21, 781); - this.tbPlz.Margin = new System.Windows.Forms.Padding(4); - this.tbPlz.MinimumSize = new System.Drawing.Size(399, 30); - this.tbPlz.Name = "tbPlz"; - this.tbPlz.Size = new System.Drawing.Size(399, 35); - this.tbPlz.TabIndex = 20; - // - // lblFrontendId - // - this.lblFrontendId.Anchor = System.Windows.Forms.AnchorStyles.None; - this.lblFrontendId.AutoSize = true; - this.lblFrontendId.BackColor = System.Drawing.Color.Transparent; - this.lblFrontendId.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblFrontendId.ForeColor = System.Drawing.Color.Black; - this.lblFrontendId.Location = new System.Drawing.Point(29, 24); - this.lblFrontendId.Name = "lblFrontendId"; - this.lblFrontendId.Size = new System.Drawing.Size(73, 15); - this.lblFrontendId.TabIndex = 21; - this.lblFrontendId.Text = "Frontend Id:"; + this.lbPlz.Text = "Ort"; + // + // tbCity + // + this.tbCity.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + this.tbCity.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource; + this.tbCity.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tbCity.Location = new System.Drawing.Point(14, 697); + this.tbCity.Margin = new System.Windows.Forms.Padding(5); + this.tbCity.MinimumSize = new System.Drawing.Size(531, 30); + this.tbCity.Name = "tbCity"; + this.tbCity.Size = new System.Drawing.Size(531, 35); + this.tbCity.TabIndex = 10; + this.tbCity.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbCity_KeyDown); // // btnSave // - this.btnSave.Location = new System.Drawing.Point(503, 746); + this.btnSave.Location = new System.Drawing.Point(143, 783); + this.btnSave.Margin = new System.Windows.Forms.Padding(4); this.btnSave.Name = "btnSave"; - this.btnSave.Size = new System.Drawing.Size(191, 70); - this.btnSave.TabIndex = 22; + this.btnSave.Size = new System.Drawing.Size(255, 86); + this.btnSave.TabIndex = 11; this.btnSave.Text = "Save Settings"; this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.Button1_Click); // + // lbFrontendId + // + this.lbFrontendId.AutoSize = true; + this.lbFrontendId.Location = new System.Drawing.Point(12, 9); + this.lbFrontendId.Name = "lbFrontendId"; + this.lbFrontendId.Size = new System.Drawing.Size(46, 17); + this.lbFrontendId.TabIndex = 24; + this.lbFrontendId.Text = "label1"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.BackColor = System.Drawing.Color.Transparent; + this.label1.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.ForeColor = System.Drawing.Color.White; + this.label1.Location = new System.Drawing.Point(14, 116); + this.label1.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(115, 24); + this.label1.TabIndex = 25; + this.label1.Text = "MQTT Port"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.BackColor = System.Drawing.Color.Transparent; + this.label2.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.ForeColor = System.Drawing.Color.White; + this.label2.Location = new System.Drawing.Point(14, 47); + this.label2.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(119, 24); + this.label2.TabIndex = 26; + this.label2.Text = "MQTT Host"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.BackColor = System.Drawing.Color.Transparent; + this.label3.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.ForeColor = System.Drawing.Color.White; + this.label3.Location = new System.Drawing.Point(14, 737); + this.label3.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(126, 24); + this.label3.TabIndex = 27; + this.label3.Text = "Postleitzahl:"; + // + // txtPlz + // + this.txtPlz.AutoSize = true; + this.txtPlz.Location = new System.Drawing.Point(149, 741); + this.txtPlz.Name = "txtPlz"; + this.txtPlz.Size = new System.Drawing.Size(46, 17); + this.txtPlz.TabIndex = 28; + this.txtPlz.Text = "label4"; + // + // tbLngCode + // + this.tbLngCode.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tbLngCode.Location = new System.Drawing.Point(14, 628); + this.tbLngCode.Margin = new System.Windows.Forms.Padding(5); + this.tbLngCode.MinimumSize = new System.Drawing.Size(531, 30); + this.tbLngCode.Name = "tbLngCode"; + this.tbLngCode.Size = new System.Drawing.Size(531, 35); + this.tbLngCode.TabIndex = 9; + // + // lbLngCode + // + this.lbLngCode.AutoSize = true; + this.lbLngCode.BackColor = System.Drawing.Color.Transparent; + this.lbLngCode.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbLngCode.ForeColor = System.Drawing.Color.White; + this.lbLngCode.Location = new System.Drawing.Point(14, 599); + this.lbLngCode.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); + this.lbLngCode.Name = "lbLngCode"; + this.lbLngCode.Size = new System.Drawing.Size(161, 24); + this.lbLngCode.TabIndex = 29; + this.lbLngCode.Text = "Landeskennung"; + // // Settings // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ScrollBar; - this.ClientSize = new System.Drawing.Size(757, 858); + this.ClientSize = new System.Drawing.Size(567, 889); + this.Controls.Add(this.tbLngCode); + this.Controls.Add(this.lbLngCode); + this.Controls.Add(this.txtPlz); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.lbFrontendId); this.Controls.Add(this.btnSave); - this.Controls.Add(this.lblFrontendId); - this.Controls.Add(this.tbPlz); + this.Controls.Add(this.tbCity); this.Controls.Add(this.lbPlz); this.Controls.Add(this.tbTimeout); this.Controls.Add(this.lbTimeout); this.Controls.Add(this.tbQos); this.Controls.Add(this.lbQos); - this.Controls.Add(this.tbTobicBackend); + this.Controls.Add(this.tbTopicBackend); this.Controls.Add(this.lbBackend); this.Controls.Add(this.tbTopicFrontend); this.Controls.Add(this.lbFrontend); @@ -316,11 +359,9 @@ this.Controls.Add(this.tbUser); this.Controls.Add(this.lbUser); this.Controls.Add(this.tbPort); - this.Controls.Add(this.lbSettingsPort); this.Controls.Add(this.tbHost); - this.Controls.Add(this.lbSettingsHost); this.Location = new System.Drawing.Point(500, 0); - this.Margin = new System.Windows.Forms.Padding(2); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "Settings"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Settings"; @@ -331,10 +372,7 @@ } #endregion - - private System.Windows.Forms.Label lbSettingsHost; private System.Windows.Forms.TextBox tbHost; - private System.Windows.Forms.Label lbSettingsPort; private System.Windows.Forms.TextBox tbPort; private System.Windows.Forms.Label lbUser; private System.Windows.Forms.TextBox tbUser; @@ -343,14 +381,20 @@ private System.Windows.Forms.Label lbFrontend; private System.Windows.Forms.TextBox tbTopicFrontend; private System.Windows.Forms.Label lbBackend; - private System.Windows.Forms.TextBox tbTobicBackend; + private System.Windows.Forms.TextBox tbTopicBackend; private System.Windows.Forms.Label lbQos; private System.Windows.Forms.TextBox tbQos; private System.Windows.Forms.Label lbTimeout; private System.Windows.Forms.TextBox tbTimeout; private System.Windows.Forms.Label lbPlz; - private System.Windows.Forms.TextBox tbPlz; - private System.Windows.Forms.Label lblFrontendId; + private System.Windows.Forms.TextBox tbCity; private System.Windows.Forms.Button btnSave; + private System.Windows.Forms.Label lbFrontendId; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label txtPlz; + private System.Windows.Forms.TextBox tbLngCode; + private System.Windows.Forms.Label lbLngCode; } } \ No newline at end of file diff --git a/Wetterstation/Settings.cs b/Wetterstation/Settings.cs index d2125ec..172232e 100644 --- a/Wetterstation/Settings.cs +++ b/Wetterstation/Settings.cs @@ -1,60 +1,40 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; using System.Management; using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; using System.Security.Cryptography; +using System.Configuration; +using System.Data.SQLite; +using System.Linq; namespace Wetterstation { public partial class Settings : Form { - //List<SettingsModel> WeatherstationSettings = new List<SettingsModel>(); SettingsModel WeatherstationSettings = new SettingsModel(); public Settings() { InitializeComponent(); - lblFrontendId.Text = "Frontend Id: " + generateId(); + lbFrontendId.Text = "Frontend Id: " + generateId(); - //SqliteDataAccess.CreateAndOpenDb(); Console.WriteLine("Daten werden aus DB ausgelesen ..."); WeatherstationSettings = SqliteDataAccess.LoadWeatherstationSettings(); - //Console.WriteLine("Ausgabe der Daten:" + WeatherstationSettings.mqtt_host); - - //WeatherstationSettings = LoadWeatherstationSettings(); - //Console.WriteLine("Ausgabe der Daten:" + WeatherstationSettings.; } private void LoadWeatherstationSettings() { - //WeatherstationSettings = SqliteDataAccess.LoadWeatherstationSettings(); - //SqliteDataAccess.CreateAndOpenDb(); - //WeatherstationSettings = SqliteDataAccess.GetUserByName(); tbHost.Text = WeatherstationSettings.mqtt_host; tbUser.Text = WeatherstationSettings.mqtt_user; tbPasswort.Text = WeatherstationSettings.mqtt_pass; tbTopicFrontend.Text = WeatherstationSettings.mqtt_topic_frontend; - tbTobicBackend.Text = WeatherstationSettings.mqtt_topic_backend; + tbTopicBackend.Text = WeatherstationSettings.mqtt_topic_backend; tbQos.Text = WeatherstationSettings.mqtt_qos.ToString(); tbTimeout.Text = WeatherstationSettings.mqtt_timeout; tbPort.Text = WeatherstationSettings.mqtt_port.ToString(); - tbPlz.Text = WeatherstationSettings.plz.ToString(); - } - - private void TextBox2_TextChanged(object sender, EventArgs e) - { - - } - - private void Label1_Click(object sender, EventArgs e) - { - + tbCity.Text = WeatherstationSettings.city; + txtPlz.Text = WeatherstationSettings.plz; + tbLngCode.Text = WeatherstationSettings.lngCode; } private String generateId() @@ -65,14 +45,6 @@ namespace Wetterstation ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor"); foreach (ManagementObject queryObj in searcher.Get()) { - Console.WriteLine("-----------------------------------"); - Console.WriteLine("Win32_Processor instance"); - Console.WriteLine("-----------------------------------"); - Console.WriteLine("Architecture: {0}", queryObj["Architecture"]); - Console.WriteLine("Caption: {0}", queryObj["Caption"]); - Console.WriteLine("Family: {0}", queryObj["Family"]); - Console.WriteLine("ProcessorId: {0}", queryObj["ProcessorId"]); - Console.WriteLine("Username: {0}", Environment.UserName); result = queryObj["ProcessorId"] + Environment.UserName; } } @@ -84,18 +56,16 @@ namespace Wetterstation return GetMd5Hash(md5Hash, result); } } + private string GetMd5Hash(MD5 md5Hash, string input) { - // Convert the input string to a byte array and compute the hash. byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input)); - // Create a new Stringbuilder to collect the bytes - // and create a string. + // Create a new Stringbuilder to collect the bytes and create a string. StringBuilder sBuilder = new StringBuilder(); - // Loop through each byte of the hashed data - // and format each one as a hexadecimal string. + // Loop through each byte of the hashed data and format each one as a hexadecimal string. for (int i = 0; i < data.Length; i++) { sBuilder.Append(data[i].ToString("x2")); @@ -109,11 +79,24 @@ namespace Wetterstation { Console.WriteLine("Bin in Settings_Load !!!!!!!"); LoadWeatherstationSettings(); + acPlz(); } - private void TbSettingsHost_TextChanged(object sender, EventArgs e) + public void acPlz() { - + using (SQLiteConnection con = new SQLiteConnection(ConfigurationManager.ConnectionStrings["Default"].ConnectionString)) + { + SQLiteCommand com = new SQLiteCommand("SELECT ort || ', ' || plz AS plzort, ort, plz FROM plz_ort", con); + con.Open(); + SQLiteDataReader dr = com.ExecuteReader(); + AutoCompleteStringCollection myCollection = new AutoCompleteStringCollection(); + while (dr.Read()) + { + myCollection.Add(dr.GetString(0)); + } + tbCity.AutoCompleteCustomSource = myCollection; + con.Close(); + } } //SettingsForm in SettingsModell ablegen @@ -122,16 +105,17 @@ namespace Wetterstation SettingsModel mqttSettings = new SettingsModel(); mqttSettings.mqtt_host = tbHost.Text; - mqttSettings.mqtt_user = tbPasswort.Text; - mqttSettings.mqtt_pass = tbTopicFrontend.Text; - mqttSettings.mqtt_topic_frontend = tbTobicBackend.Text; - mqttSettings.mqtt_topic_backend = tbQos.Text; + mqttSettings.mqtt_user = tbUser.Text; + mqttSettings.mqtt_pass = tbPasswort.Text; + mqttSettings.mqtt_topic_frontend = tbTopicFrontend.Text; + mqttSettings.mqtt_topic_backend = tbTopicBackend.Text; mqttSettings.mqtt_qos = Int32.Parse(tbQos.Text); mqttSettings.mqtt_timeout = tbTimeout.Text; mqttSettings.mqtt_port = Int32.Parse(tbPort.Text); mqttSettings.frontendId = generateId(); //wird automatisch berechnet und gesetzt und soll nicht geändert werden - mqttSettings.plz = Int16.Parse(tbPlz.Text); - mqttSettings.city = tbPlz.Text; + mqttSettings.plz = txtPlz.Text; + mqttSettings.city = tbCity.Text; + mqttSettings.lngCode = tbLngCode.Text; Console.WriteLine("Speichere Settings "); SqliteDataAccess.SaveWeatherstationSettings(mqttSettings); @@ -139,41 +123,13 @@ namespace Wetterstation this.Close(); } - private void TextBox1_TextChanged(object sender, EventArgs e) + private void tbCity_KeyDown(object sender, KeyEventArgs e) { - - } - - private void TbSettingsClient_TextChanged(object sender, EventArgs e) - { - - } - - private void LbSettingsClient_Click(object sender, EventArgs e) - { - - } - - private void TbSettingsHost_TextChanged(object sender, EventArgs e) - { - - } - - private void LbSettingsHost_Click(object sender, EventArgs e) - { - - } - - private void LbSettingsUser_Click(object sender, EventArgs e) - { - - } - - private void BtSichern_Click(object sender, EventArgs e) - { - this.Close(); - + if (e.KeyData == Keys.Enter) + { + String strTemp = tbCity.Text; + txtPlz.Text = strTemp.Split(' ').Last(); + } } } } - diff --git a/Wetterstation/SettingsModel.cs b/Wetterstation/SettingsModel.cs index ce3ba2a..4ab9657 100644 --- a/Wetterstation/SettingsModel.cs +++ b/Wetterstation/SettingsModel.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Wetterstation +namespace Wetterstation { public class SettingsModel { @@ -26,8 +20,10 @@ namespace Wetterstation public string frontendId { get; set; } - public int plz { get; set; } + public string plz { get; set; } public string city { get; set; } + + public string lngCode { get; set; } } } diff --git a/Wetterstation/SqliteDataAccess.cs b/Wetterstation/SqliteDataAccess.cs index 90888dc..f94a975 100644 --- a/Wetterstation/SqliteDataAccess.cs +++ b/Wetterstation/SqliteDataAccess.cs @@ -1,109 +1,49 @@ using Dapper; -using System; -using System.Collections.Generic; using System.Configuration; using System.Data; using System.Data.SQLite; -using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Data.SqlClient; namespace Wetterstation { - - public static class SqliteDataAccess { - public static SQLiteConnection _dbConnection; - //public static void CreateAndOpenDb() - //{ - // //var dbFilePath = "./TestDb.sqlite"; - // var dbFilePath = "./frontend.db"; - // if (!File.Exists(dbFilePath)) - // { - - // SQLiteConnection.CreateFile(dbFilePath); - // } - // _dbConnection = new SQLiteConnection(string.Format( - // "Data Source={0};Version=3;", dbFilePath)); - // _dbConnection.Open(); - //} - - public static SettingsModel LoadWeatherstationSettings() { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { var output = cnn.Query<SettingsModel>("SELECT * FROM settings LIMIT 1;"); - //Console.WriteLine("Der Horst ist:" + output.ToString); return output.FirstOrDefault(); } } public static void SaveWeatherstationSettings(SettingsModel mqttSettings) { - //Console.WriteLine("Port aus DB ..." + mqttSettings.dbMqttHost); using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { - cnn.Execute("UPDATE settings SET mqtt_host = @mqtt_host, mqtt_user = @mqtt_user, mqtt_pass = @mqtt_pass, mqtt_topic_frontend = @mqtt_topic_frontend, mqtt_topic_backend = @mqtt_topic_backend, mqtt_qos = @mqtt_qos, mqtt_timeout = @mqtt_timeout, mqtt_port = @mqtt_port, plz = @plz;", mqttSettings); + cnn.Execute("UPDATE settings " + + "SET mqtt_host = @mqtt_host, " + + "mqtt_user = @mqtt_user, " + + "mqtt_pass = @mqtt_pass, " + + "mqtt_topic_frontend = @mqtt_topic_frontend, " + + "mqtt_topic_backend = @mqtt_topic_backend, " + + "mqtt_qos = @mqtt_qos, " + + "mqtt_timeout = @mqtt_timeout, " + + "mqtt_port = @mqtt_port, " + + "frontendId = @frontendId, " + + "lngCode = @lngCode, " + + "plz = @plz, " + + "city = @city;", + mqttSettings); } } - //holt den ConnectionString aus der App.config (siehe ProjektmappenExplorer) private static string LoadConnectionString(string id = "Default") { return ConfigurationManager.ConnectionStrings[id].ConnectionString; } - - //public static SettingsModel GetUserByName() - //{ - // var userCollection = _dbConnection.Query<SettingsModel>("SELECT * FROM settings LIMIT 1;"); - // //new { Port = port }); - - // return userCollection.FirstOrDefault(); - //} - - //public static void SaveWeatherstationSettings(SettingsModel mqttSettings) - //{ - // _dbConnection.ExecuteNonQuery(@"UPDATE settings SET mqtt_host = @mqtt_host, mqtt_user = @mqtt_user, mqtt_pass = @mqtt_pass, mqtt_topic_frontend = @mqtt_topic_frontend, mqtt_topic_backend = @mqtt_topic_backend, mqtt_qos = @mqtt_qos, mqtt_timeout = @mqtt_timeout, mqtt_port = @mqtt_port, plz = @plz, city = @city ; "); - - //} - - - // - - - } } - - - - // public static SettingsModel LoadWeatherstationSettings() - // { - // using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) - // { - // var output = cnn.Query<SettingsModel>("select * from settings where mqtt_port=1883"); - // //Console.WriteLine("Der Horst ist:" + output.ToString); - // return output.FirstOrDefault(); - // } - // } - - // public static void SaveWeatherstationSettings(SettingsModel mqttSettings) - // { - // Console.WriteLine("Port aus DB ..." + mqttSettings.dbMqttHost); - // using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) - // { - // cnn.Execute("UPDATE settings SET mqtt_host = @mqtt_host, mqtt_user = @mqtt_user, mqtt_pass = @mqtt_pass, mqtt_topic_frontend = @mqtt_topic_frontend, mqtt_topic_backend = @mqtt_topic_backend, mqtt_qos = @mqtt_qos, mqtt_timeout = @mqtt_timeout, mqtt_port = @mqtt_port, plz = @plz, city = @city ;"); - // } - // } - - - -//} - diff --git a/Wetterstation/frontend.db b/Wetterstation/frontend.db index aa6fadd48d50b6d247f33224bbdcfd85cbd79cf8..c80ebb9c6818e01761d660126550e2db0fb072a6 100644 GIT binary patch delta 272 zcmZo@P-<vUnjkHx%fP_U0mSV<%m~Ed6LpM5bs6+DGI@bKX5L*4{Na30d3W(F+Af&D z@rG-20=F|GCj*nSxVAP^3+Lnv?!VGyiABj7iA6eGoCP^m3P4_y1{=G$tSnQD;^e!$ zugoyyp{kQJODaLiL0m2!g`B)}=lqmZm`L*zzV;`4j6lo;#LPg<0>rF9%m&2l+n?}p zs0K1l+AdhYA;UjiEuSNYFNcvwTV37Onp2Vq==kXi@;TC2dKvh8L24TL1sNC$8F^s} N_<;bVB7wyK2mp>)N~{0? delta 450 zcmZo@P-<vUnjkHx#K6GN0mSV<%m~B+6LpM5l^FCiGI@bKX5PyT{Na30c`tLvZ5K@7 zc*C_hf!mppv3>GI9?^OQ4PGt<93a0uH$JhTATtFhUzS*uoRL_hgI{$)P8HZJ;#BA4 zrPn*>r=${LcxGN&PH9DaMt*S#@u~~*i%JwS^GfhIS`BJ&N)p(Q!0=NL*Vblg&M!$! z%4y<fVHcN`1@a~z;e9nZl}E1mDPQ|jK1LvB0%B$$W&vVWAZ7z%_U%vkI8*`|HMa{E paLDjaSIg(fnZ7%pgKzqRe2z4hNeujxKr%J_69agrPs-=W0|2&3Z=e7G -- GitLab