Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class frmTrafficLight : Form
- {
- TrafficLight trafficLightLeft = new TrafficLight(75, Color.Red);
- TrafficLight trafficLightRight = new TrafficLight(55, Color.Green);
- public frmTrafficLight()
- {
- InitializeComponent();
- }
- private void pbLeft_Paint(object sender, PaintEventArgs e)
- {
- trafficLightLeft.Draw(e.Graphics);
- }
- private void btnChangeColorLeft_Click(object sender, EventArgs e)
- {
- trafficLightLeft.ChangeColor();
- Refresh();
- }
- private void btnBiggerLeft_Click(object sender, EventArgs e)
- {
- // On click the drawing becomes bigger with 5
- if (trafficLightLeft.Size < 75)
- {
- trafficLightLeft.Size += 5;
- Refresh();
- }
- }
- private void btnSmallerLeft_Click(object sender, EventArgs e)
- {
- // On click the drawing becomes smaller with 5
- if (trafficLightLeft.Size > 5)
- {
- trafficLightLeft.Size -= 5;
- Refresh();
- }
- }
- private void pbRight_Paint(object sender, PaintEventArgs e)
- {
- trafficLightRight.Draw(e.Graphics);
- }
- private void btnChangeColorRight_Click(object sender, EventArgs e)
- {
- trafficLightRight.ChangeColor();
- Refresh();
- }
- private void btnBiggerRight_Click(object sender, EventArgs e)
- {
- if (trafficLightRight.Size < 75)
- {
- trafficLightRight.Size += 5;
- Refresh();
- }
- }
- private void btnSmallerRight_Click(object sender, EventArgs e)
- {
- if (trafficLightRight.Size > 5)
- {
- trafficLightRight.Size -= 5;
- Refresh();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement