Guest User

Untitled

a guest
Apr 18th, 2014
61
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace Rocnikovka
  12. {
  13. public partial class Form2 : Form
  14. {
  15. Random rand = new Random();
  16. Databaze databaze;
  17. Otazka ot;
  18. public bool fail;
  19. private long start;
  20.  
  21.  
  22. public Form2()
  23. {
  24. InitializeComponent();
  25. databaze = new Databaze();
  26. start = DateTime.Now.Ticks;
  27.  
  28.  
  29. }
  30.  
  31. private void Form2_Load(object sender, EventArgs e)
  32. {
  33. load();
  34. }
  35.  
  36. private void aButton_Click(object sender, EventArgs e)
  37. {
  38. if (aButton.Text == ot.od)
  39. {
  40. richTextBox1.BackColor = Color.Green;
  41. loadNext();
  42. }
  43. else
  44. {
  45. aButton.BackColor = Color.Red;
  46. failEnd();
  47. }
  48.  
  49. }
  50.  
  51. private void bButton_Click(object sender, EventArgs e)
  52. {
  53. if (bButton.Text == ot.od)
  54. {
  55. richTextBox1.BackColor = Color.Green;
  56. loadNext();
  57. }
  58. else
  59. {
  60. bButton.BackColor = Color.Red;
  61. failEnd();
  62. }
  63.  
  64. }
  65.  
  66. private void cButton_Click(object sender, EventArgs e)
  67. {
  68. if (cButton.Text == ot.od)
  69. {
  70. richTextBox1.BackColor = Color.Green;
  71. loadNext();
  72. }
  73. else
  74. {
  75. cButton.BackColor = Color.Red;
  76. failEnd();
  77. }
  78.  
  79. }
  80.  
  81. private void dButton_Click(object sender, EventArgs e)
  82. {
  83. if (dButton.Text == ot.od)
  84. {
  85. richTextBox1.BackColor = Color.Green;
  86. loadNext();
  87. }
  88. else
  89. {
  90. dButton.BackColor = Color.Red;
  91. failEnd();
  92. }
  93.  
  94. }
  95. public void load()
  96. {
  97. do
  98. {
  99. int i = rand.Next(0, databaze.otazky.Count);
  100. ot = databaze.otazky[i];
  101. }
  102. while (ot.byla);
  103.  
  104. richTextBox1.Select();
  105. richTextBox1.Text = ot.ot;
  106. aButton.Text = ot.a;
  107. bButton.Text = ot.b;
  108. cButton.Text = ot.c;
  109. dButton.Text = ot.d;
  110. fail = false;
  111.  
  112.  
  113.  
  114.  
  115. }
  116.  
  117. private void loadNext()
  118. {
  119.  
  120. richTextBox1.Select();
  121. ot.byla = true;
  122. load();
  123. progressBar1.Value = progressBar1.Value + 5;
  124.  
  125.  
  126.  
  127. }
  128. public void failEnd()
  129. {
  130. countDown.Stop();
  131. fail = true;
  132. if (fail == true)
  133. {
  134.  
  135. MessageBox.Show("Smůla, prohrál jsi - hra se restartuje");
  136. Application.Restart();
  137.  
  138. }
  139.  
  140. }
  141.  
  142. private void countDown_Tick(object sender, EventArgs e)
  143. {
  144. TimeSpan oTime = new TimeSpan(DateTime.Now.Ticks - start);
  145. count.Text = oTime.Seconds.ToString();
  146. if (oTime.Seconds == 20)
  147. {
  148. count.ForeColor = Color.Pink;
  149. }
  150. if (oTime.Seconds == 25)
  151. {
  152. count.ForeColor = Color.Purple;
  153. }
  154. if (oTime.Seconds == 30)
  155. {
  156. count.ForeColor = Color.Red;
  157. countDown.Stop();
  158. MessageBox.Show("Smůla, čas vypršel - hra se restartuje");
  159. Application.Restart();
  160. }
  161. }
  162. }
  163. }
RAW Paste Data