diff --git a/Wetterstation/Form1.Designer.cs b/Wetterstation/Form1.Designer.cs index bf7a953d5a78f2925ed43cda5fcd18c781c235b0..5bf1f6c760d3732af17f0e9ffff63892fc1aec70 100644 --- a/Wetterstation/Form1.Designer.cs +++ b/Wetterstation/Form1.Designer.cs @@ -36,10 +36,6 @@ 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(); this.lbTextInnentemp = new System.Windows.Forms.Label(); this.lbTextAussentemp = new System.Windows.Forms.Label(); this.lbTextWindSpeed = new System.Windows.Forms.Label(); @@ -67,7 +63,6 @@ namespace Wetterstation this.lbTextLuftfeuchtAussen = new System.Windows.Forms.Label(); this.lbTextLuftdruck = new System.Windows.Forms.Label(); this.lbLuftdruck = new System.Windows.Forms.Label(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.lbHintergrund = new System.Windows.Forms.Label(); this.lbCity = new System.Windows.Forms.Label(); this.lbForecastImage1 = new System.Windows.Forms.PictureBox(); @@ -85,12 +80,12 @@ namespace Wetterstation this.lbForecastTemp3 = new System.Windows.Forms.Label(); this.lbForecastTemp4 = new System.Windows.Forms.Label(); this.lbForecastTemp5 = new System.Windows.Forms.Label(); + this.cartesianChart1 = new LiveCharts.WinForms.CartesianChart(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.lbForecastImage2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.lbForecastImage3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.lbForecastImage4)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.lbForecastImage5)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.lbForecastImage1)).BeginInit(); this.SuspendLayout(); // @@ -443,27 +438,6 @@ namespace Wetterstation this.lbLuftdruck.TabIndex = 40; this.lbLuftdruck.Text = "NA 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(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(991, 132); - this.chart1.TabIndex = 41; - this.chart1.Text = "chTendenz"; - title3.Name = "Title1"; - this.chart1.Titles.Add(title3); - // // lbHintergrund // this.lbHintergrund.Anchor = System.Windows.Forms.AnchorStyles.None; @@ -677,6 +651,14 @@ namespace Wetterstation this.lbForecastTemp5.TabIndex = 59; this.lbForecastTemp5.Text = "NA °C"; // + // cartesianChart1 + // + this.cartesianChart1.Location = new System.Drawing.Point(19, 480); + this.cartesianChart1.Name = "cartesianChart1"; + this.cartesianChart1.Size = new System.Drawing.Size(1309, 310); + this.cartesianChart1.TabIndex = 60; + this.cartesianChart1.Text = "cartesianChart1"; + // // Hintergrund // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); @@ -684,6 +666,7 @@ namespace Wetterstation this.BackgroundImage = global::Wetterstation.Properties.Resources.Bild_Dennis_Formatiert; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.ClientSize = new System.Drawing.Size(1344, 897); + this.Controls.Add(this.cartesianChart1); this.Controls.Add(this.lbForecastTemp5); this.Controls.Add(this.lbForecastTemp4); this.Controls.Add(this.lbForecastTemp3); @@ -705,7 +688,6 @@ namespace Wetterstation this.Controls.Add(this.lbForecastDay4); this.Controls.Add(this.lbForecastDay5); this.Controls.Add(this.lbAussenTemp); - this.Controls.Add(this.chart1); this.Controls.Add(this.lbLuftdruck); this.Controls.Add(this.lbTextLuftdruck); this.Controls.Add(this.lbTextLuftfeuchtAussen); @@ -740,7 +722,6 @@ namespace Wetterstation ((System.ComponentModel.ISupportInitialize)(this.lbForecastImage3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.lbForecastImage4)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.lbForecastImage5)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.lbForecastImage1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -776,7 +757,6 @@ namespace Wetterstation private Label lbTextLuftfeuchtAussen; private Label lbTextLuftdruck; private Label lbLuftdruck; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; private Label lbHintergrund; private Label lbCity; private PictureBox lbForecastImage1; @@ -794,6 +774,7 @@ namespace Wetterstation private Label lbForecastTemp3; private Label lbForecastTemp4; private Label lbForecastTemp5; + private LiveCharts.WinForms.CartesianChart cartesianChart1; } } diff --git a/Wetterstation/Form1.cs b/Wetterstation/Form1.cs index cfedd8994cf4dfd7aa559f626d236ee920319cca..defed7c5c2eeae97f5488589d94135184935b127 100644 --- a/Wetterstation/Form1.cs +++ b/Wetterstation/Form1.cs @@ -6,6 +6,9 @@ using uPLibrary.Networking.M2Mqtt; using uPLibrary.Networking.M2Mqtt.Messages; using Newtonsoft.Json; using System.Globalization; +using LiveCharts; +using LiveCharts.WinForms; +using LiveCharts.Wpf; namespace Wetterstation { @@ -27,7 +30,46 @@ namespace Wetterstation t.Start(); mqttStart(); + updateChart(); } + + private void updateChart() + { + cartesianChart1.Series = new SeriesCollection + { + new LineSeries + { + Title = "Temperature", + Values = new ChartValues<double> {4, 6, 5, 2, 7}, + PointGeometry = null + }, + new LineSeries + { + Title = "Humidity", + Values = new ChartValues<double> {6, 7, 3, 4, 6}, + PointGeometry = null + }, + new LineSeries + { + Title = "Pressure", + Values = new ChartValues<double> {5, 2, 8, 3}, + PointGeometry = null + } + }; + + cartesianChart1.LegendLocation = LegendLocation.Right; + + //modifying the series collection will animate and update the chart + //cartesianChart1.Series.Add(new LineSeries + //{ + // Values = new ChartValues<double> { 5, 3, 2, 4, 5 }, + // LineSmoothness = 0, //straight lines, 1 really smooth lines + //}); + + //modifying any series values will also animate and update the chart + cartesianChart1.Series[2].Values.Add(5d); + } + private void t_DateTime(object sender, EventArgs e) { lbUhr.Text = DateTime.Now.ToLongTimeString(); diff --git a/Wetterstation/Wetterstation.csproj b/Wetterstation/Wetterstation.csproj index 547551ba8670c990680663c86ff3458ff5b10e67..da25cf11d33ce7997ff4263c126f9f872a796161 100644 --- a/Wetterstation/Wetterstation.csproj +++ b/Wetterstation/Wetterstation.csproj @@ -41,12 +41,20 @@ <Reference Include="LiveCharts, Version=0.9.7.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL"> <HintPath>..\packages\LiveCharts.0.9.7\lib\net45\LiveCharts.dll</HintPath> </Reference> + <Reference Include="LiveCharts.WinForms, Version=0.9.7.1, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL"> + <HintPath>..\packages\LiveCharts.WinForms.0.9.7.1\lib\net45\LiveCharts.WinForms.dll</HintPath> + </Reference> + <Reference Include="LiveCharts.Wpf, Version=0.9.7.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL"> + <HintPath>..\packages\LiveCharts.Wpf.0.9.7\lib\net45\LiveCharts.Wpf.dll</HintPath> + </Reference> <Reference Include="M2Mqtt.Net, Version=4.3.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\packages\M2Mqtt.4.3.0.0\lib\net45\M2Mqtt.Net.dll</HintPath> </Reference> <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> + <Reference Include="PresentationCore" /> + <Reference Include="PresentationFramework" /> <Reference Include="System" /> <Reference Include="System.Configuration" /> <Reference Include="System.Core" /> @@ -55,6 +63,7 @@ </Reference> <Reference Include="System.Management" /> <Reference Include="System.Windows.Forms.DataVisualization" /> + <Reference Include="System.Xaml" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> @@ -64,6 +73,8 @@ <Reference Include="System.Net.Http" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> + <Reference Include="WindowsBase" /> + <Reference Include="WindowsFormsIntegration" /> </ItemGroup> <ItemGroup> <Compile Include="SqliteDataAccess.cs" /> diff --git a/Wetterstation/packages.config b/Wetterstation/packages.config index 3573adec575a63fa6f0bfaf093fdea46d1bc7455..95aa657cd3d653567d21eb41edb97d6641440f74 100644 --- a/Wetterstation/packages.config +++ b/Wetterstation/packages.config @@ -2,6 +2,8 @@ <packages> <package id="Dapper" version="2.0.30" targetFramework="net472" /> <package id="LiveCharts" version="0.9.7" targetFramework="net472" /> + <package id="LiveCharts.WinForms" version="0.9.7.1" targetFramework="net472" /> + <package id="LiveCharts.Wpf" version="0.9.7" targetFramework="net472" /> <package id="M2Mqtt" version="4.3.0.0" targetFramework="net472" /> <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" /> <package id="System.Data.SQLite.Core" version="1.0.112.0" targetFramework="net472" />