using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace T6.红绿灯
{
public partial class frmRedGreen2 : Form
{
int red, yello, green, count = 0;
public frmRedGreen2()
{
InitializeComponent();
}
private void frmRedGreen2_Load(object sender, EventArgs e)
{
pbImage.Image=imageL.Images[0];
}
private void button1_Click(object sender, EventArgs e)
{
red=Convert.ToInt32(txtRed.Text.ToString());
yello = Convert.ToInt32(txtYello.Text.ToString());
green = Convert.ToInt32(txtGreen.Text.ToString());
}
private void btnStart_Click(object sender, EventArgs e)
{
Time.Enabled = true;
count = red;
}
private void Time_Tick(object sender, EventArgs e)
{
pbImage.Image = imageL.Images[1];
lblTime.Text = count.ToString();
count--;
if (count==0)
{
Time1.Enabled = true;
Time.Enabled = false;
count = yello;
}
}
private void Time1_Tick(object sender, EventArgs e)
{
pbImage.Image = imageL.Images[2];
lblTime.Text = count.ToString();
count--;
if (count == 0)
{
Time2.Enabled = true;
Time1.Enabled = false;
count = green;
}
}
private void Time2_Tick(object sender, EventArgs e)
{
pbImage.Image=imageL.Images[3];
lblTime.Text = count.ToString();
count--;
if (count == 0)
{
Time.Enabled = true;
Time2.Enabled = false;
count = red;
}
}
private void btbStop_Click(object sender, EventArgs e)
{
Time.Enabled = false;
Time1.Enabled = false;
Time2.Enabled = false;
}
}
}