diff --git a/ErgometerApplication/ErgometerApplication/ChartPanel.cs b/ErgometerApplication/ErgometerApplication/ChartPanel.cs new file mode 100644 index 0000000..fde0ab9 --- /dev/null +++ b/ErgometerApplication/ErgometerApplication/ChartPanel.cs @@ -0,0 +1,102 @@ +using ErgometerLibrary; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Windows.Forms.DataVisualization.Charting; +namespace ErgometerApplication +{ + public class ChartPanel:Panel + { + private Chart chart; + private MetingType type; + private ChartArea chartArea; + private Series series; + + public ChartPanel(MetingType type) : base() + { + this.type = type; + + this.chart = new Chart(); + this.chartArea = new ChartArea(); + this.chart.Titles.Add(new Title(type.ToString())); + + this.Location = new System.Drawing.Point(0, 0); + + this.Size = new System.Drawing.Size(250, 200); + this.Controls.Add(chart); + + this.series = createSerie(); + this.chartArea.Name = "chartArea"; + + this.chart.Size = new System.Drawing.Size(250, 200); + + this.chart.Dock = DockStyle.Fill; + this.chart.Series.Add(series); + this.chart.Text = "chart"; + + + this.chart.ChartAreas.Add(chartArea); + + } + + public void updateChart(List metingen) + { + chart.Series[0] = createSerie(); + for (int i = 0; i < metingen.Count; i++) + { + chart.Series[0].Points.Add(getMetingType(metingen[i])); + } + chart.Update(); + } + + public Series createSerie() + { + Series serie = new Series(); + serie.Name = "series"; + serie.ChartType = SeriesChartType.Line; + serie.ChartArea = "chartArea"; + serie.BorderWidth = 3; + return serie; + } + + public int getMetingType(Meting meting) + { + switch(type) + { + case MetingType.HEARTBEAT: + return meting.HeartBeat; + case MetingType.RPM: + return meting.RPM; + case MetingType.SPEED: + return (int)meting.Speed; + case MetingType.DISTANCE: + return (int)meting.Distance; + case MetingType.POWER: + return meting.Power; + case MetingType.ENERGY: + return meting.Energy; + case MetingType.SECONDS: + return meting.Seconds; + case MetingType.ACTUALPOWER: + return meting.ActualPower; + default: + return 0; + } + } + + public enum MetingType + { + HEARTBEAT, + RPM, + SPEED, + DISTANCE, + POWER, + ENERGY, + SECONDS, + ACTUALPOWER + } + } +} diff --git a/ErgometerApplication/ErgometerApplication/ClientApplicatie.Designer.cs b/ErgometerApplication/ErgometerApplication/ClientApplicatie.Designer.cs index 6d02edb..017117c 100644 --- a/ErgometerApplication/ErgometerApplication/ClientApplicatie.Designer.cs +++ b/ErgometerApplication/ErgometerApplication/ClientApplicatie.Designer.cs @@ -62,8 +62,9 @@ namespace ErgometerApplication // // panelClientContainer // - this.panelClientContainer.Controls.Add(this.panelDataViewLeft); this.panelClientContainer.Controls.Add(this.panelGraphView); + this.panelClientContainer.Controls.Add(this.panelDataViewLeft); + this.panelClientContainer.Controls.Add(this.panelClientChat); this.panelClientContainer.Dock = System.Windows.Forms.DockStyle.Fill; this.panelClientContainer.Location = new System.Drawing.Point(0, 0); @@ -87,15 +88,6 @@ namespace ErgometerApplication this.panelDataViewLeft.Controls.Add(energy); this.panelDataViewLeft.Controls.Add(actualpower); - // - // panelGraphView - // - this.panelGraphView.BackColor = System.Drawing.SystemColors.ButtonFace; - this.panelGraphView.Dock = System.Windows.Forms.DockStyle.Fill; - this.panelGraphView.Location = new System.Drawing.Point(0, 0); - this.panelGraphView.Name = "panelGraphView"; - this.panelGraphView.Size = new System.Drawing.Size(400, 600); - this.panelGraphView.TabIndex = 1; // // panelClientChat // diff --git a/ErgometerApplication/ErgometerApplication/ErgometerApplication.csproj b/ErgometerApplication/ErgometerApplication/ErgometerApplication.csproj index d4d176e..94c73b0 100644 --- a/ErgometerApplication/ErgometerApplication/ErgometerApplication.csproj +++ b/ErgometerApplication/ErgometerApplication/ErgometerApplication.csproj @@ -43,6 +43,8 @@ + + @@ -54,6 +56,9 @@ + + Component + Component diff --git a/ErgometerApplication/ErgometerApplication/PanelClientDataView.cs b/ErgometerApplication/ErgometerApplication/PanelClientDataView.cs index 9661486..fe3d405 100644 --- a/ErgometerApplication/ErgometerApplication/PanelClientDataView.cs +++ b/ErgometerApplication/ErgometerApplication/PanelClientDataView.cs @@ -1,4 +1,5 @@ -using System; +using ErgometerLibrary; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,17 +10,71 @@ namespace ErgometerApplication { public class PanelGraphView:Panel { + + private List charts; + private FlowLayoutPanel flowlayout; + public PanelGraphView() : base() { + createCharts(); + + flowlayout = new FlowLayoutPanel(); + + flowlayout.Dock = DockStyle.Fill; + flowlayout.BackColor = System.Drawing.Color.DarkGray; + flowlayout.Location = new System.Drawing.Point(0, 0); + flowlayout.Name = "flowlayout"; + flowlayout.Padding = new Padding(15); + flowlayout.AutoScroll = true; + foreach(ChartPanel chart in charts) + { + flowlayout.Controls.Add(chart); + } + + List metingen = new List(); + metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32)); + metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32)); + metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32)); + metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32)); + metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32)); + metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32)); + metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32)); + metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32)); + metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32)); + metingen.Add(new Meting(23, 25, 12, 46, 13, 25, 13, 1, 32)); + + updateAllCharts(metingen); // // panelGraphView // - this.BackColor = System.Drawing.SystemColors.ButtonFace; this.Dock = System.Windows.Forms.DockStyle.Fill; - this.Location = new System.Drawing.Point(400, 0); + this.Controls.Add(flowlayout); + + this.Location = new System.Drawing.Point(0, 0); this.Name = "panelGraphView"; this.Size = new System.Drawing.Size(400, 600); this.TabIndex = 1; } + + public void createCharts() + { + charts = new List(); + charts.Add(new ChartPanel(ChartPanel.MetingType.HEARTBEAT)); + charts.Add(new ChartPanel(ChartPanel.MetingType.RPM)); + charts.Add(new ChartPanel(ChartPanel.MetingType.SPEED)); + charts.Add(new ChartPanel(ChartPanel.MetingType.DISTANCE)); + charts.Add(new ChartPanel(ChartPanel.MetingType.ENERGY)); + charts.Add(new ChartPanel(ChartPanel.MetingType.SECONDS)); + charts.Add(new ChartPanel(ChartPanel.MetingType.POWER)); + charts.Add(new ChartPanel(ChartPanel.MetingType.ACTUALPOWER)); + } + + public void updateAllCharts(List metingen) + { + foreach(ChartPanel chart in charts) + { + chart.updateChart(metingen); + } + } } }