Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. public partial class frmTrafficLight : Form
  2. {
  3. TrafficLight trafficLightLeft = new TrafficLight(75, Color.Red);
  4. TrafficLight trafficLightRight = new TrafficLight(55, Color.Green);
  5.  
  6. public frmTrafficLight()
  7. {
  8. InitializeComponent();
  9. }
  10.  
  11. private void pbLeft_Paint(object sender, PaintEventArgs e)
  12. {
  13. trafficLightLeft.Draw(e.Graphics);
  14. }
  15.  
  16. private void btnChangeColorLeft_Click(object sender, EventArgs e)
  17. {
  18. trafficLightLeft.ChangeColor();
  19. Refresh();
  20. }
  21.  
  22. private void btnBiggerLeft_Click(object sender, EventArgs e)
  23. {
  24. // On click the drawing becomes bigger with 5
  25. if (trafficLightLeft.Size < 75)
  26. {
  27. trafficLightLeft.Size += 5;
  28. Refresh();
  29. }
  30. }
  31.  
  32. private void btnSmallerLeft_Click(object sender, EventArgs e)
  33. {
  34. // On click the drawing becomes smaller with 5
  35. if (trafficLightLeft.Size > 5)
  36. {
  37. trafficLightLeft.Size -= 5;
  38. Refresh();
  39. }
  40. }
  41.  
  42. private void pbRight_Paint(object sender, PaintEventArgs e)
  43. {
  44. trafficLightRight.Draw(e.Graphics);
  45. }
  46.  
  47. private void btnChangeColorRight_Click(object sender, EventArgs e)
  48. {
  49. trafficLightRight.ChangeColor();
  50. Refresh();
  51. }
  52.  
  53. private void btnBiggerRight_Click(object sender, EventArgs e)
  54. {
  55. if (trafficLightRight.Size < 75)
  56. {
  57. trafficLightRight.Size += 5;
  58. Refresh();
  59. }
  60. }
  61.  
  62. private void btnSmallerRight_Click(object sender, EventArgs e)
  63. {
  64. if (trafficLightRight.Size > 5)
  65. {
  66. trafficLightRight.Size -= 5;
  67. Refresh();
  68. }
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement