PanelGraphView.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using ErgometerLibrary;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Forms;
  8. using System.Windows.Forms.DataVisualization.Charting;
  9. namespace ErgometerDoctorApplication
  10. {
  11. public class PanelGraphView : Panel
  12. {
  13. private List<ChartPanel> charts;
  14. private FlowLayoutPanel flowlayout;
  15. public PanelGraphView() : base()
  16. {
  17. createCharts();
  18. flowlayout = new FlowLayoutPanel();
  19. flowlayout.Dock = DockStyle.Fill;
  20. flowlayout.BackColor = System.Drawing.Color.DarkGray;
  21. flowlayout.Location = new System.Drawing.Point(0, 0);
  22. flowlayout.Name = "flowlayout";
  23. flowlayout.Padding = new Padding(15);
  24. flowlayout.AutoScroll = true;
  25. foreach (ChartPanel chart in charts)
  26. {
  27. flowlayout.Controls.Add(chart);
  28. }
  29. List<Meting> metingen = new List<Meting>();
  30. metingen.Add(new Meting(0, 0, 0, 0, 0, 0, 0, 0, 0));
  31. updateAllCharts(metingen);
  32. //
  33. // panelGraphView
  34. //
  35. this.Dock = System.Windows.Forms.DockStyle.Fill;
  36. this.Controls.Add(flowlayout);
  37. this.Location = new System.Drawing.Point(0, 0);
  38. this.Name = "panelGraphView";
  39. this.Size = new System.Drawing.Size(400, 600);
  40. this.TabIndex = 1;
  41. }
  42. public void createCharts()
  43. {
  44. charts = new List<ChartPanel>();
  45. charts.Add(new ChartPanel(ChartPanel.MetingType.HEARTBEAT, SeriesChartType.Line));
  46. charts.Add(new ChartPanel(ChartPanel.MetingType.RPM, SeriesChartType.Line));
  47. charts.Add(new ChartPanel(ChartPanel.MetingType.SPEED, SeriesChartType.Line));
  48. charts.Add(new ChartPanel(ChartPanel.MetingType.DISTANCE, SeriesChartType.Line));
  49. charts.Add(new ChartPanel(ChartPanel.MetingType.ENERGY, SeriesChartType.Line));
  50. charts.Add(new ChartPanel(ChartPanel.MetingType.POWER, SeriesChartType.Line));
  51. charts.Add(new ChartPanel(ChartPanel.MetingType.ACTUALPOWER, SeriesChartType.Line));
  52. }
  53. public void updateAllCharts(List<Meting> metingen)
  54. {
  55. foreach (ChartPanel chart in charts)
  56. {
  57. chart.updateChart(metingen);
  58. }
  59. }
  60. }
  61. }