天天看点

简单的Winform启动画面

static void Main()

{

Application.Run(new Form1());

Application.Run(new Form2());

}

public delegate void lable_invoke1();

private void lable_start1()

{

this.label1.BeginInvoke(new lable_invoke1(lable_show1));

}

private void lable_show1()

{

this.label1.Visible = true;

Application.DoEvents();

this.progressBar1.Minimum = 0;

this.progressBar1.Maximum = 100;

try

{

this.label1.Text = System.Convert.ToString(int.Parse(this.label1.Text.ToString().Substring(0,this.label1.Text.ToString().IndexOf("%"))) + 1) + "%";

this.progressBar1.Value ++;

Application.DoEvents();

if(this.progressBar1.Value == 30)

{

Application.DoEvents();

this.label2.Text = "Waitting for system...";

if(System.IO.File.Exists("D://1.bmp"))

{

this.label3.Text = "Find 1.bmp Ok";

}

else

{

this.label3.Text = "Can not find 1.bmp , pls check it";

}

}

if(this.progressBar1.Value == 50)

{

Application.DoEvents();

this.label2.Text = "Essential components of detection system...";

}

if(this.progressBar1.Value == 70)

{

Application.DoEvents();

this.label2.Text = "Starting system...";

}

if(this.progressBar1.Value == 100)

{

this.timer1.Stop();

}

}

catch(Exception ex)

{

MessageBox.Show(ex.Message.ToString());

}

}

private void Form1_Load(object sender, System.EventArgs e)

{

this.label1.Visible = false;

this.timer1.Enabled = true;

this.progressBar1.Value = 0;

this.Opacity = 0;

}

private void timer1_Tick(object sender, System.EventArgs e)

{

System.Threading.Thread s1 = new System.Threading.Thread(new ThreadStart(lable_start1));

if (this.Opacity < 1)

{

this.Opacity = this.Opacity + 0.05;

}

else

{

s1.Start();

}

}

}  

画面

简单的Winform启动画面

继续阅读