MainForm.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. namespace simple_game
  11. {
  12. public partial class MainForm : Form
  13. {
  14. public MainForm()
  15. {
  16. InitializeComponent();
  17. }
  18. /// <summary>
  19. /// Проверка выигрыша
  20. /// </summary>
  21. private void CheckWin()
  22. {
  23. if (!lblTopLeft.Visible && !lblTopRight.Visible && !lblBottomLeft.Visible && !lblBottomRight.Visible)
  24. {
  25. MessageBox.Show("Поздравляю! Вы сделали что-то(?)");
  26. Close();
  27. }
  28. }
  29. /// <summary>
  30. /// Клик левой верхней кнопки
  31. /// </summary>
  32. /// <param name="sender"></param>
  33. /// <param name="e"></param>
  34. private void btnTopLeft_Click(object sender, EventArgs e)
  35. {
  36. lblBottomRight.Visible = !lblBottomRight.Visible;
  37. CheckWin();
  38. }
  39. /// <summary>
  40. /// Клик правой верхней кнопки
  41. /// </summary>
  42. /// <param name="sender"></param>
  43. /// <param name="e"></param>
  44. private void btnTopRight_Click(object sender, EventArgs e)
  45. {
  46. lblBottomRight.Visible = !lblBottomRight.Visible;
  47. lblBottomLeft.Visible = !lblBottomLeft.Visible;
  48. CheckWin();
  49. }
  50. /// <summary>
  51. /// Клик нижней левой кнопки
  52. /// </summary>
  53. /// <param name="sender"></param>
  54. /// <param name="e"></param>
  55. private void btnBottomLeft_Click(object sender, EventArgs e)
  56. {
  57. lblTopRight.Visible = !lblTopRight.Visible;
  58. lblBottomRight.Visible = !lblBottomRight.Visible;
  59. CheckWin();
  60. }
  61. /// <summary>
  62. /// Клик правой нижней кнопки
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="e"></param>
  66. private void btnBottomRight_Click(object sender, EventArgs e)
  67. {
  68. lblTopLeft.Visible = !lblTopLeft.Visible;
  69. CheckWin();
  70. }
  71. }
  72. }