PanelGatherInfo.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7. namespace ErgometerApplication
  8. {
  9. public class PanelGatherInfo :Panel
  10. {
  11. private System.Windows.Forms.Label lblGeslacht;
  12. private System.Windows.Forms.Label lblLeeftijd;
  13. private System.Windows.Forms.Label lblLengte;
  14. private System.Windows.Forms.Label lblGewicht;
  15. public System.Windows.Forms.Label lblFeedback;
  16. public System.Windows.Forms.TextBox textBoxLeeftijd;
  17. public System.Windows.Forms.TextBox textBoxLengte;
  18. public System.Windows.Forms.TextBox textBoxGewicht;
  19. public System.Windows.Forms.ComboBox comboBoxGeslacht;
  20. public System.Windows.Forms.Button buttonStart;
  21. private System.Windows.Forms.Label lblInfoTitel;
  22. private System.Windows.Forms.PictureBox pictureBoxBike;
  23. private ClientApplicatie app;
  24. public PanelGatherInfo(ClientApplicatie app):base()
  25. {
  26. this.app = app;
  27. this.pictureBoxBike = new System.Windows.Forms.PictureBox();
  28. this.buttonStart = new System.Windows.Forms.Button();
  29. this.textBoxLeeftijd = new System.Windows.Forms.TextBox();
  30. this.textBoxLengte = new System.Windows.Forms.TextBox();
  31. this.textBoxGewicht = new TextBox();
  32. this.comboBoxGeslacht = new ComboBox();
  33. this.lblInfoTitel = new System.Windows.Forms.Label();
  34. this.lblGeslacht = new System.Windows.Forms.Label();
  35. this.lblGewicht = new System.Windows.Forms.Label();
  36. this.lblLeeftijd = new System.Windows.Forms.Label();
  37. this.lblLengte = new Label();
  38. this.lblFeedback = new System.Windows.Forms.Label();
  39. ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBike)).BeginInit();
  40. //
  41. // panelLogin
  42. //
  43. this.Controls.Add(this.pictureBoxBike);
  44. this.Controls.Add(this.buttonStart);
  45. this.Controls.Add(this.comboBoxGeslacht);
  46. this.Controls.Add(this.textBoxGewicht);
  47. this.Controls.Add(this.textBoxLengte);
  48. this.Controls.Add(this.textBoxLeeftijd);
  49. this.Controls.Add(this.lblInfoTitel);
  50. this.Controls.Add(this.lblGeslacht);
  51. this.Controls.Add(this.lblGewicht);
  52. this.Controls.Add(this.lblLeeftijd);
  53. this.Controls.Add(this.lblFeedback);
  54. this.Controls.Add(this.lblLengte);
  55. this.Dock = System.Windows.Forms.DockStyle.Fill;
  56. this.Location = new System.Drawing.Point(0, 0);
  57. this.Name = "panelLogin";
  58. this.Size = new System.Drawing.Size(800, 600);
  59. this.TabIndex = 0;
  60. //
  61. // pictureBoxBike
  62. //
  63. this.pictureBoxBike.Anchor = System.Windows.Forms.AnchorStyles.None;
  64. this.pictureBoxBike.Image = global::ErgometerApplication.Properties.Resources.flatbike;
  65. this.pictureBoxBike.Location = new System.Drawing.Point(137, 131);
  66. this.pictureBoxBike.Name = "pictureBoxBike";
  67. this.pictureBoxBike.Size = new System.Drawing.Size(250, 250);
  68. this.pictureBoxBike.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
  69. this.pictureBoxBike.TabIndex = 4;
  70. this.pictureBoxBike.TabStop = false;
  71. //
  72. // buttonLogin
  73. //
  74. this.buttonStart.Anchor = System.Windows.Forms.AnchorStyles.None;
  75. this.buttonStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
  76. this.buttonStart.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  77. this.buttonStart.Location = new System.Drawing.Point(468, 420);
  78. this.buttonStart.Name = "buttonStart";
  79. this.buttonStart.Size = new System.Drawing.Size(168, 31);
  80. this.buttonStart.TabIndex = 3;
  81. this.buttonStart.Text = "Start Test";
  82. this.buttonStart.UseVisualStyleBackColor = true;
  83. this.buttonStart.Click += new System.EventHandler(this.buttonStart_Click);
  84. //
  85. // textBoxPassword
  86. //
  87. this.textBoxLeeftijd.Anchor = System.Windows.Forms.AnchorStyles.None;
  88. this.textBoxLeeftijd.Location = new System.Drawing.Point(467, 270);
  89. this.textBoxLeeftijd.MaxLength = 16;
  90. this.textBoxLeeftijd.Name = "textBoxLeeftijd";
  91. this.textBoxLeeftijd.Size = new System.Drawing.Size(167, 20);
  92. this.textBoxLeeftijd.TabIndex = 2;
  93. this.textBoxLeeftijd.KeyDown += TextBox_KeyDown;
  94. //
  95. // textBoxPassword
  96. //
  97. this.textBoxGewicht.Anchor = System.Windows.Forms.AnchorStyles.None;
  98. this.textBoxGewicht.Location = new System.Drawing.Point(467, 390);
  99. this.textBoxGewicht.MaxLength = 16;
  100. this.textBoxGewicht.Name = "textBoxGewicht";
  101. this.textBoxGewicht.Size = new System.Drawing.Size(167, 20);
  102. this.textBoxGewicht.TabIndex = 2;
  103. this.textBoxGewicht.KeyDown += TextBox_KeyDown;
  104. //
  105. // textBoxUsername
  106. //
  107. this.textBoxLengte.Anchor = System.Windows.Forms.AnchorStyles.None;
  108. this.textBoxLengte.Location = new System.Drawing.Point(468, 330);
  109. this.textBoxLengte.MaxLength = 16;
  110. this.textBoxLengte.Name = "textBoxLengte";
  111. this.textBoxLengte.Size = new System.Drawing.Size(167, 20);
  112. this.textBoxLengte.TabIndex = 2;
  113. this.textBoxLengte.KeyDown += TextBox_KeyDown;
  114. //
  115. // comboBox
  116. //
  117. this.comboBoxGeslacht.Anchor = System.Windows.Forms.AnchorStyles.None;
  118. this.comboBoxGeslacht.Location = new System.Drawing.Point(468, 210);
  119. this.comboBoxGeslacht.MaxLength = 16;
  120. this.comboBoxGeslacht.Name = "textBoxLengte";
  121. this.comboBoxGeslacht.Size = new System.Drawing.Size(167, 20);
  122. this.comboBoxGeslacht.TabIndex = 2;
  123. this.comboBoxGeslacht.Items.AddRange(new object[] { "Man", "Vrouw" });
  124. this.comboBoxGeslacht.SelectedIndex = 0;
  125. //
  126. // lblLoginTitle
  127. //
  128. this.lblInfoTitel.Anchor = System.Windows.Forms.AnchorStyles.None;
  129. this.lblInfoTitel.AutoSize = true;
  130. this.lblInfoTitel.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  131. this.lblInfoTitel.Location = new System.Drawing.Point(461, 141);
  132. this.lblInfoTitel.Name = "lblLoginTitle";
  133. this.lblInfoTitel.Size = new System.Drawing.Size(87, 32);
  134. this.lblInfoTitel.TabIndex = 1;
  135. this.lblInfoTitel.Text = "Vul je gegevens in";
  136. //
  137. // lblVerification
  138. //
  139. this.lblFeedback.Anchor = System.Windows.Forms.AnchorStyles.None;
  140. this.lblFeedback.AutoSize = true;
  141. this.lblFeedback.Font = new System.Drawing.Font("Segoe UI Light", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  142. this.lblFeedback.Location = new System.Drawing.Point(140, 415);
  143. this.lblFeedback.Name = "lvlVerification";
  144. this.lblFeedback.Size = new System.Drawing.Size(200, 21);
  145. this.lblFeedback.ForeColor = System.Drawing.Color.Red;
  146. this.lblFeedback.TabIndex = 1;
  147. this.lblFeedback.Text = "";
  148. //
  149. // lblUsername
  150. //
  151. this.lblGeslacht.Anchor = System.Windows.Forms.AnchorStyles.None;
  152. this.lblGeslacht.AutoSize = true;
  153. this.lblGeslacht.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  154. this.lblGeslacht.Location = new System.Drawing.Point(464, 180);
  155. this.lblGeslacht.Name = "lblUsername";
  156. this.lblGeslacht.Size = new System.Drawing.Size(128, 21);
  157. this.lblGeslacht.TabIndex = 1;
  158. this.lblGeslacht.Text = "Geslacht";
  159. //
  160. // lblUsername
  161. //
  162. this.lblLeeftijd.Anchor = System.Windows.Forms.AnchorStyles.None;
  163. this.lblLeeftijd.AutoSize = true;
  164. this.lblLeeftijd.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  165. this.lblLeeftijd.Location = new System.Drawing.Point(464, 240);
  166. this.lblLeeftijd.Name = "lblUsername";
  167. this.lblLeeftijd.Size = new System.Drawing.Size(128, 21);
  168. this.lblLeeftijd.TabIndex = 1;
  169. this.lblLeeftijd.Text = "Leeftijd";
  170. //
  171. // lblUsername
  172. //
  173. this.lblLengte.Anchor = System.Windows.Forms.AnchorStyles.None;
  174. this.lblLengte.AutoSize = true;
  175. this.lblLengte.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  176. this.lblLengte.Location = new System.Drawing.Point(464, 300);
  177. this.lblLengte.Name = "lblLengte";
  178. this.lblLengte.Size = new System.Drawing.Size(128, 21);
  179. this.lblLengte.TabIndex = 1;
  180. this.lblLengte.Text = "Lengte (cm)";
  181. //
  182. // lblPassword
  183. //
  184. this.lblGewicht.Anchor = System.Windows.Forms.AnchorStyles.None;
  185. this.lblGewicht.AutoSize = true;
  186. this.lblGewicht.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold);
  187. this.lblGewicht.Location = new System.Drawing.Point(464, 360);
  188. this.lblGewicht.Name = "lblPassword";
  189. this.lblGewicht.Size = new System.Drawing.Size(103, 21);
  190. this.lblGewicht.TabIndex = 0;
  191. this.lblGewicht.Text = "Gewicht (kg)";
  192. ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBike)).EndInit();
  193. }
  194. private void TextBox_KeyDown(object sender, KeyEventArgs e)
  195. {
  196. if (e.KeyCode == Keys.Enter)
  197. {
  198. buttonStart_Click(this, new EventArgs());
  199. }
  200. }
  201. public void buttonStart_Click(object sender, EventArgs e)
  202. {
  203. char geslacht = comboBoxGeslacht.SelectedText == "Vrouw" ? 'V' : 'M';
  204. int leeftijd = 0;
  205. bool leeftijdOk = int.TryParse(textBoxLeeftijd.Text, out leeftijd);
  206. if(!leeftijdOk)
  207. {
  208. lblFeedback.Text = "Leeftijd is niet juist";
  209. textBoxLeeftijd.ForeColor = System.Drawing.Color.Red;
  210. return;
  211. }
  212. int gewicht = 0;
  213. bool gewichtOk = int.TryParse(textBoxGewicht.Text, out gewicht);
  214. if (!gewichtOk)
  215. {
  216. lblFeedback.Text = "Gewicht is niet juist";
  217. textBoxGewicht.ForeColor = System.Drawing.Color.Red;
  218. return;
  219. }
  220. textBoxGewicht.BackColor = System.Drawing.Color.Black;
  221. int lengte = 0;
  222. bool lengteOk = int.TryParse(textBoxLengte.Text, out lengte);
  223. if (!lengteOk)
  224. {
  225. lblFeedback.Text = "Lengte is niet juist";
  226. textBoxLengte.ForeColor = System.Drawing.Color.Red;
  227. return;
  228. }
  229. lblFeedback.Text = "";
  230. textBoxLengte.BackColor = System.Drawing.Color.Black;
  231. app.CreateNewTest(geslacht, leeftijd, gewicht, lengte);
  232. }
  233. }
  234. }