private void Form1_Load(object sender, EventArgs e)
{
//timer控件ShowForm1
this.ShowForm1.Enabled = true; //控件是否激活
this.ShowForm1.Interval = 100; //Elapsed 事件的频率
//timer控件HideForm1
this.HideForm1.Enabled = false;
this.HideForm1.Interval = 100;
this.Opacity = 0.5; //设置窗体透明度
ShowForm1.Start(); //timer控件 ShowForm1开始
}
#endregion
打开form1#region 打开form1
private void ShowForm1_Tick(object sender, EventArgs e)
{
if (this.Opacity == 1) //如果窗体透明度达到 1
{
this.ShowForm1.Stop();
}
else //透明度小于 1
{
this.Opacity = this.Opacity + 0.1; //透明度递增
}
}
#endregion
隐藏from1#region 隐藏from1
private void HideForm1_Tick_1(object sender, EventArgs e)
{
this.Opacity = this.Opacity - 0.1; //透明度不等于 0
if (this.Opacity == 0) //透明度等于 0
{
this.HideForm1.Stop();
this.Hide();
}
}
#endregion
关闭#region 关闭
private void button1_Click(object sender, EventArgs e)
{
this.HideForm1.Start();
}
#endregion