SessionWindow.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 ClientApplicatie_Resize(object sender, EventArgs e)
  42. {
  43. Control control = (Control)sender;
  44. if (control.Size.Width < 980)
  45. {
  46. panelGraphView.Visible = false;
  47. panelClientChat.Width = 400;
  48. panelDataViewLeft.Dock = DockStyle.Fill;
  49. }
  50. if (control.Size.Width >= 980 && control.Size.Width < 1368)
  51. {
  52. panelGraphView.Visible = true;
  53. panelDataViewLeft.Width = 250;
  54. panelClientChat.Width = 400;
  55. panelDataViewLeft.Dock = DockStyle.Left;
  56. }
  57. if (control.Size.Width >= 1368)
  58. {
  59. panelGraphView.Visible = true;
  60. panelDataViewLeft.Width = 400;
  61. panelDataViewLeft.Dock = DockStyle.Left;
  62. }
  63. }
  64. public void SaveMeting(Meting m)
  65. {
  66. heartBeat.updateValue(m.HeartBeat);
  67. RPM.updateValue(m.RPM);
  68. speed.updateValue(m.Speed*100);
  69. distance.updateValue(m.Distance*100);
  70. power.updateValue(m.Power);
  71. energy.updateValue(m.Energy);
  72. actualpower.updateValue(m.ActualPower);
  73. time.updateValue(m.Seconds);
  74. if (count >= 10)
  75. {
  76. count = 0;
  77. panelGraphView.updateAllCharts(client.Metingen);
  78. }
  79. count++;
  80. }
  81. public void LoadGraph()
  82. {
  83. panelGraphView.updateAllCharts(client.Metingen);
  84. }
  85. }
  86. }