FormMain.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Diagnostics;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Reflection;
  9. using System.Runtime.InteropServices;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. using System.Windows.Input;
  14. using WindowsInput;
  15. using System.Windows;
  16. namespace MouseClicker
  17. {
  18. public partial class FormMain : Form
  19. {
  20. public int AorBorEnd = 3;
  21. public FormMain()
  22. {
  23. InitializeComponent();
  24. FlipImageAndWait(4);
  25. }
  26. void FlipImageAndWait(int AorBorEnd)
  27. {
  28. Image originalImage = pictureBox3.Image;
  29. if (AorBorEnd == 1)
  30. {
  31. originalImage.RotateFlip(RotateFlipType.Rotate270FlipNone);
  32. pictureBox3.Image = originalImage;
  33. pictureBox3.Refresh();
  34. button2.Enabled = false;
  35. //button1.Enabled = false;
  36. //timer1.Enabled = true;
  37. }
  38. if (AorBorEnd == 2)
  39. {
  40. originalImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
  41. pictureBox3.Image = originalImage;
  42. pictureBox3.Refresh();
  43. //button2.Enabled = false;
  44. button1.Enabled = false;
  45. //timer2.Enabled = true;
  46. }
  47. if (AorBorEnd == 3)
  48. {
  49. originalImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
  50. pictureBox3.Image = originalImage;
  51. pictureBox3.Refresh();
  52. }
  53. if (AorBorEnd == 4)
  54. {
  55. originalImage.RotateFlip(RotateFlipType.Rotate270FlipNone);
  56. pictureBox3.Image = originalImage;
  57. pictureBox3.Refresh();
  58. }
  59. }
  60. private void timer1_Tick(object sender, EventArgs e)
  61. {
  62. timer1.Enabled = false;
  63. button2.Enabled = true;
  64. button1.Enabled = true;
  65. button2.FillColor = Color.SeaGreen;
  66. button1.FillColor = Color.SeaGreen;
  67. FlipImageAndWait(3);
  68. }
  69. private void timer2_Tick(object sender, EventArgs e)
  70. {
  71. timer2.Enabled = false;
  72. button2.Enabled = true;
  73. button1.Enabled = true;
  74. button2.FillColor = Color.SeaGreen;
  75. button1.FillColor = Color.SeaGreen;
  76. FlipImageAndWait(4);
  77. }
  78. private void button1_Click(object sender, EventArgs e)
  79. {
  80. if (AorBorEnd == 3)
  81. {
  82. AorBorEnd = 1;
  83. FlipImageAndWait(1);
  84. button1.FillColor = Color.Coral;
  85. }
  86. }
  87. private void button2_Click(object sender, EventArgs e)
  88. {
  89. if (AorBorEnd == 3)
  90. {
  91. AorBorEnd = 2;
  92. FlipImageAndWait(2);
  93. button2.FillColor = Color.Coral;
  94. }
  95. }
  96. protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
  97. {
  98. // Проверка нажатия клавиши Esc
  99. if (keyData == Keys.Escape)
  100. {
  101. if (keyData == Keys.Escape && AorBorEnd == 1)
  102. {
  103. timer1.Enabled = true;
  104. }
  105. if (keyData == Keys.Escape && AorBorEnd == 2)
  106. {
  107. timer2.Enabled = true;
  108. }
  109. AorBorEnd = 3;
  110. return true; // Обработка события завершена
  111. }
  112. return base.ProcessCmdKey(ref msg, keyData);
  113. }
  114. }
  115. }