PanelGatherInfo.cs 12 KB

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