NowyButton.cs 916 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection.Emit;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Forms;
  8. namespace _07_3_NowyButton
  9. {
  10. public class NowyButton : Button
  11. {
  12. public event EventHandler Click_LU;
  13. public event EventHandler Click_LD;
  14. public event EventHandler Click_RU;
  15. public event EventHandler Click_RD;
  16. public NowyButton()
  17. {
  18. this.MouseClick += NowyButton_MouseClick;
  19. }
  20. private void NowyButton_MouseClick(object sender, MouseEventArgs e)
  21. {
  22. if (e.X < this.Width / 2 && e.Y < this.Height / 2)
  23. Click_LU?.Invoke(this, e);
  24. else if (e.X < this.Width / 2 && e.Y >= this.Height / 2)
  25. Click_LD?.Invoke(this, e);
  26. else if (e.X >= this.Width / 2 && e.Y < this.Height / 2)
  27. Click_RU?.Invoke(this, e);
  28. else
  29. Click_RD?.Invoke(this, e);
  30. }
  31. }
  32. }