public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.button1.Visible = false;
this.progressBar1.Minimum = 0;
this.progressBar1.Maximum = 200;
this.timer1.Interval = 100;// 1 second
this.label1.Text = "";
}
private void button1_Click_1(object sender, EventArgs e)
{
this.Close();
}
private void Form1_Shown(object sender, EventArgs e)
{
this.timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
// increase progressbar
if (this.progressBar1.Value < this.progressBar1.Maximum)
{
this.progressBar1.Value += 1;
}
// 5 seconds elapsed (25 ticks on a progre:
if (this.progressBar1.Value == 50)
{
this.label1.Text = "5 seconds";
}
else if (this.progressBar1.Value == 150)
{
this.label1.Text = "15 seconds";
}
else if (this.progressBar1.Value == this.progressBar1.Maximum)
{
this.timer1.Stop();
this.label1.Text = "timer stopped";
this.button1.Visible = true;
}
}
}
|