PanelClientSetData.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. namespace ErgometerDoctorApplication.Client
  9. {
  10. public class PanelClientSetData : Panel
  11. {
  12. private Panel panel6;
  13. private Label label3;
  14. private Panel panel5;
  15. private Label label4;
  16. private Panel panel3;
  17. private Label label2;
  18. private Panel panel2;
  19. private Label label1;
  20. private Button buttonTrapsnelheid;
  21. private TrackBar trackBar1;
  22. private Label label6;
  23. private Button buttonAfstand;
  24. private TextBox textBox2;
  25. private Label label5;
  26. private Button buttonTijd;
  27. private MaskedTextBox textBox1;
  28. private int Session;
  29. public PanelClientSetData(int session) : base()
  30. {
  31. Session = session;
  32. this.panel6 = new System.Windows.Forms.Panel();
  33. this.label3 = new System.Windows.Forms.Label();
  34. this.panel5 = new System.Windows.Forms.Panel();
  35. this.label4 = new System.Windows.Forms.Label();
  36. this.panel3 = new System.Windows.Forms.Panel();
  37. this.label2 = new System.Windows.Forms.Label();
  38. this.panel2 = new System.Windows.Forms.Panel();
  39. this.label1 = new System.Windows.Forms.Label();
  40. this.textBox1 = new System.Windows.Forms.MaskedTextBox();
  41. this.textBox2 = new System.Windows.Forms.TextBox();
  42. this.trackBar1 = new System.Windows.Forms.TrackBar();
  43. this.buttonTijd = new System.Windows.Forms.Button();
  44. this.buttonAfstand = new System.Windows.Forms.Button();
  45. this.label5 = new System.Windows.Forms.Label();
  46. this.label6 = new System.Windows.Forms.Label();
  47. this.buttonTrapsnelheid = new System.Windows.Forms.Button();
  48. this.panel6.SuspendLayout();
  49. this.panel5.SuspendLayout();
  50. this.panel3.SuspendLayout();
  51. this.panel2.SuspendLayout();
  52. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
  53. this.SuspendLayout();
  54. //
  55. // panel1
  56. //
  57. //
  58. // panel6
  59. //
  60. this.panel6.BackColor = System.Drawing.Color.White;
  61. this.panel6.Controls.Add(this.buttonTrapsnelheid);
  62. this.panel6.Controls.Add(this.trackBar1);
  63. this.panel6.Controls.Add(this.label3);
  64. this.panel6.Dock = System.Windows.Forms.DockStyle.Fill;
  65. this.panel6.Location = new System.Drawing.Point(0, 199);
  66. this.panel6.Name = "panel6";
  67. this.panel6.Size = new System.Drawing.Size(370, 112);
  68. this.panel6.TabIndex = 4;
  69. //
  70. // label3
  71. //
  72. this.label3.AutoSize = true;
  73. this.label3.Font = new System.Drawing.Font("Segoe UI Semibold", 10F, System.Drawing.FontStyle.Bold);
  74. this.label3.Location = new System.Drawing.Point(4, 5);
  75. this.label3.Name = "label3";
  76. this.label3.Size = new System.Drawing.Size(146, 19);
  77. this.label3.TabIndex = 0;
  78. this.label3.Text = "Trapsterkte aanpassen";
  79. //
  80. // panel5
  81. //
  82. this.panel5.BackColor = System.Drawing.Color.White;
  83. this.panel5.Controls.Add(this.label6);
  84. this.panel5.Controls.Add(this.buttonAfstand);
  85. this.panel5.Controls.Add(this.textBox2);
  86. this.panel5.Controls.Add(this.label4);
  87. this.panel5.Dock = System.Windows.Forms.DockStyle.Top;
  88. this.panel5.Location = new System.Drawing.Point(0, 124);
  89. this.panel5.Name = "panel5";
  90. this.panel5.Size = new System.Drawing.Size(370, 75);
  91. this.panel5.TabIndex = 3;
  92. //
  93. // label4
  94. //
  95. this.label4.AutoSize = true;
  96. this.label4.Font = new System.Drawing.Font("Segoe UI Semibold", 10F, System.Drawing.FontStyle.Bold);
  97. this.label4.Location = new System.Drawing.Point(4, 26);
  98. this.label4.Name = "label4";
  99. this.label4.Size = new System.Drawing.Size(114, 19);
  100. this.label4.TabIndex = 0;
  101. this.label4.Text = "Afstand instellen";
  102. //
  103. // panel3
  104. //
  105. this.panel3.BackColor = System.Drawing.Color.White;
  106. this.panel3.Controls.Add(this.label5);
  107. this.panel3.Controls.Add(this.buttonTijd);
  108. this.panel3.Controls.Add(this.textBox1);
  109. this.panel3.Controls.Add(this.label2);
  110. this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
  111. this.panel3.Font = new System.Drawing.Font("Tunga", 8.25F);
  112. this.panel3.Location = new System.Drawing.Point(0, 52);
  113. this.panel3.Name = "panel3";
  114. this.panel3.Size = new System.Drawing.Size(370, 72);
  115. this.panel3.TabIndex = 1;
  116. //
  117. // label2
  118. //
  119. this.label2.AutoSize = true;
  120. this.label2.Font = new System.Drawing.Font("Segoe UI Semibold", 10F, System.Drawing.FontStyle.Bold);
  121. this.label2.Location = new System.Drawing.Point(3, 23);
  122. this.label2.Name = "label2";
  123. this.label2.Size = new System.Drawing.Size(101, 19);
  124. this.label2.TabIndex = 0;
  125. this.label2.Text = "Tijd aanpassen";
  126. //
  127. // panel2
  128. //
  129. this.panel2.BackColor = System.Drawing.SystemColors.ControlDarkDark;
  130. this.panel2.Controls.Add(this.label1);
  131. this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
  132. this.panel2.Location = new System.Drawing.Point(0, 0);
  133. this.panel2.Name = "panel2";
  134. this.panel2.Size = new System.Drawing.Size(500, 52);
  135. this.panel2.TabIndex = 0;
  136. //
  137. // label1
  138. //
  139. this.label1.AutoSize = true;
  140. this.label1.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  141. this.label1.ForeColor = System.Drawing.Color.White;
  142. this.label1.Location = new System.Drawing.Point(3, 9);
  143. this.label1.Name = "label1";
  144. this.label1.Size = new System.Drawing.Size(247, 21);
  145. this.label1.TabIndex = 0;
  146. this.label1.Text = "Eigenschappen fiets aanpassen";
  147. //
  148. // textBox1
  149. //
  150. this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  151. this.textBox1.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  152. this.textBox1.Location = new System.Drawing.Point(123, 21);
  153. this.textBox1.Name = "textBox1";
  154. this.textBox1.Size = new System.Drawing.Size(77, 25);
  155. this.textBox1.TabIndex = 1;
  156. this.textBox1.Mask = "00:00";
  157. this.textBox1.KeyDown += TextBox1_KeyDown;
  158. //
  159. // textBox2
  160. //
  161. this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  162. this.textBox2.Font = new System.Drawing.Font("Segoe UI", 9.75F);
  163. this.textBox2.Location = new System.Drawing.Point(124, 24);
  164. this.textBox2.Name = "textBox2";
  165. this.textBox2.Size = new System.Drawing.Size(77, 25);
  166. this.textBox2.TabIndex = 1;
  167. this.textBox2.KeyDown += TextBox2_KeyDown;
  168. //
  169. // trackBar1
  170. //
  171. this.trackBar1.Location = new System.Drawing.Point(29, 42);
  172. this.trackBar1.Maximum = 400;
  173. this.trackBar1.Minimum = 25;
  174. this.trackBar1.Name = "trackBar1";
  175. this.trackBar1.Size = new System.Drawing.Size(221, 45);
  176. this.trackBar1.TabIndex = 1;
  177. this.trackBar1.Value = 25;
  178. //
  179. // button1
  180. //
  181. this.buttonTijd.BackColor = System.Drawing.Color.WhiteSmoke;
  182. this.buttonTijd.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
  183. this.buttonTijd.Font = new System.Drawing.Font("Segoe UI", 9.75F);
  184. this.buttonTijd.Location = new System.Drawing.Point(282, 19);
  185. this.buttonTijd.Name = "button1";
  186. this.buttonTijd.Size = new System.Drawing.Size(75, 25);
  187. this.buttonTijd.TabIndex = 2;
  188. this.buttonTijd.Text = "Set";
  189. this.buttonTijd.UseVisualStyleBackColor = false;
  190. this.buttonTijd.Click += new System.EventHandler(this.buttonTijd_Click);
  191. //
  192. // button2
  193. //
  194. this.buttonAfstand.BackColor = System.Drawing.Color.WhiteSmoke;
  195. this.buttonAfstand.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
  196. this.buttonAfstand.Font = new System.Drawing.Font("Segoe UI", 9.75F);
  197. this.buttonAfstand.Location = new System.Drawing.Point(283, 24);
  198. this.buttonAfstand.Name = "button2";
  199. this.buttonAfstand.Size = new System.Drawing.Size(75, 25);
  200. this.buttonAfstand.TabIndex = 2;
  201. this.buttonAfstand.Text = "Set";
  202. this.buttonAfstand.UseVisualStyleBackColor = false;
  203. this.buttonAfstand.Click += new System.EventHandler(this.buttonAfstand_Click);
  204. //
  205. // label5
  206. //
  207. this.label5.AutoSize = true;
  208. this.label5.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  209. this.label5.Location = new System.Drawing.Point(207, 26);
  210. this.label5.Name = "label5";
  211. this.label5.Size = new System.Drawing.Size(23, 13);
  212. this.label5.TabIndex = 3;
  213. this.label5.Text = "sec";
  214. //
  215. // label6
  216. //
  217. this.label6.AutoSize = true;
  218. this.label6.Location = new System.Drawing.Point(208, 30);
  219. this.label6.Name = "label6";
  220. this.label6.Size = new System.Drawing.Size(15, 13);
  221. this.label6.TabIndex = 3;
  222. this.label6.Text = "m";
  223. //
  224. // button3
  225. //
  226. this.buttonTrapsnelheid.BackColor = System.Drawing.Color.WhiteSmoke;
  227. this.buttonTrapsnelheid.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
  228. this.buttonTrapsnelheid.Location = new System.Drawing.Point(283, 42);
  229. this.buttonTrapsnelheid.Name = "button3";
  230. this.buttonTrapsnelheid.Size = new System.Drawing.Size(75, 25);
  231. this.buttonTrapsnelheid.TabIndex = 2;
  232. this.buttonTrapsnelheid.Text = "Set";
  233. this.buttonTrapsnelheid.UseVisualStyleBackColor = false;
  234. this.buttonTrapsnelheid.Click += new System.EventHandler(this.buttonTrapsnelheid_Click);
  235. Controls.Add(this.panel6);
  236. Controls.Add(this.panel5);
  237. Controls.Add(this.panel3);
  238. Controls.Add(this.panel2);
  239. Dock = System.Windows.Forms.DockStyle.Fill;
  240. Location = new System.Drawing.Point(0, 0);
  241. BackColor = System.Drawing.Color.White;
  242. Name = "panel1";
  243. Size = new System.Drawing.Size(370, 400);
  244. }
  245. private void TextBox2_KeyDown(object sender, KeyEventArgs e)
  246. {
  247. if(e.KeyCode == Keys.Enter)
  248. {
  249. buttonAfstand_Click(this, new EventArgs());
  250. }
  251. }
  252. private void TextBox1_KeyDown(object sender, KeyEventArgs e)
  253. {
  254. if (e.KeyCode == Keys.Enter)
  255. {
  256. buttonTijd_Click(this, new EventArgs());
  257. }
  258. }
  259. private void buttonTrapsnelheid_Click(object sender, EventArgs e)
  260. {
  261. MainClient.SendNetCommand(new NetCommand(NetCommand.ValueType.POWER, trackBar1.Value, Session));
  262. }
  263. private void buttonAfstand_Click(object sender, EventArgs e)
  264. {
  265. MainClient.SendNetCommand(new NetCommand(NetCommand.ValueType.DISTANCE, int.Parse(textBox2.Text), Session));
  266. textBox2.Text = "";
  267. }
  268. private void buttonTijd_Click(object sender, EventArgs e)
  269. {
  270. int seconds = (int.Parse(textBox1.Text.Split(':')[0]) * 60) + int.Parse(textBox1.Text.Split(':')[1]);
  271. MainClient.SendNetCommand(new NetCommand(NetCommand.ValueType.TIME, seconds, Session));
  272. textBox1.Text = "";
  273. }
  274. }
  275. }