SessionWindow.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using ErgometerLibrary;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace ErgometerDoctorApplication
  12. {
  13. public partial class SessionWindow : Form
  14. {
  15. private bool ActiveSession { get; }
  16. private string ClientName { get; set; }
  17. public int Session { get; }
  18. private ClientThread client;
  19. private int count;
  20. public delegate void UpdateMetingen(Meting m);
  21. public UpdateMetingen updateMetingen;
  22. public delegate void UpdateGraph();
  23. public UpdateGraph updateGraph;
  24. public SessionWindow(string ClientName, bool old, int session, ClientThread parentthread)
  25. {
  26. this.ActiveSession = !old;
  27. this.ClientName = ClientName;
  28. this.client = parentthread;
  29. Session = session;
  30. count = 0;
  31. updateMetingen = new UpdateMetingen(this.SaveMeting);
  32. updateGraph = new UpdateGraph(this.LoadGraph);
  33. InitializeComponent();
  34. if(! ActiveSession)
  35. {
  36. panelClientChat.richTextBox1.Enabled = false;
  37. panelClientChat.button1.Enabled = false;
  38. panelDataViewLeft.Visible = false;
  39. }
  40. }
  41. public void updateStepsText(string text)
  42. {
  43. steps.setText(text);
  44. }
  45. public void ClientApplicatie_Resize(object sender, EventArgs e)
  46. {
  47. Control control = (Control)sender;
  48. if (control.Size.Width < 980)
  49. {
  50. panelGraphView.Visible = false;
  51. panelClientChat.Width = 400;
  52. panelDataViewLeft.Dock = DockStyle.Fill;
  53. }
  54. if (control.Size.Width >= 980 && control.Size.Width < 1368)
  55. {
  56. panelGraphView.Visible = true;
  57. panelDataViewLeft.Width = 250;
  58. panelClientChat.Width = 400;
  59. panelDataViewLeft.Dock = DockStyle.Left;
  60. }
  61. if (control.Size.Width >= 1368)
  62. {
  63. panelGraphView.Visible = true;
  64. panelDataViewLeft.Width = 400;
  65. panelDataViewLeft.Dock = DockStyle.Left;
  66. }
  67. }
  68. public void SaveMeting(Meting m)
  69. {
  70. heartBeat.updateValue(m.HeartBeat);
  71. RPM.updateValue(m.RPM);
  72. speed.updateValue(m.Speed*100);
  73. distance.updateValue(m.Distance*100);
  74. power.updateValue(m.Power);
  75. energy.updateValue(m.Energy);
  76. actualpower.updateValue(m.ActualPower);
  77. time.updateValue(m.Seconds);
  78. if (count >= 10)
  79. {
  80. count = 0;
  81. panelGraphView.updateAllCharts(client.Metingen);
  82. }
  83. count++;
  84. }
  85. public void LoadGraph()
  86. {
  87. panelGraphView.updateAllCharts(client.Metingen);
  88. }
  89. }
  90. }