![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
窗体加载
#region 窗体加载
private
void Form1_Load(
object sender, EventArgs e)
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
{
//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;
//设置窗体透明度
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
ShowForm1.Start();
//timer控件 ShowForm1开始
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
}
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
#endregion
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
打开form1
#region 打开form1
private
void ShowForm1_Tick(
object sender, EventArgs e)
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
{
if (
this.Opacity == 1)
//如果窗体透明度达到 1
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
{
this.ShowForm1.Stop();
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
}
else
//透明度小于 1
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
{
this.Opacity =
this.Opacity + 0.1;
//透明度递增
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
}
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
}
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
#endregion
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
隐藏from1
#region 隐藏from1
private
void HideForm1_Tick_1(
object sender, EventArgs e)
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
{
this.Opacity =
this.Opacity - 0.1;
//透明度不等于 0
if (
this.Opacity == 0)
//透明度等于 0
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
{
this.HideForm1.Stop();
this.Hide();
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
}
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
}
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
#endregion
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
关闭
#region 关闭
private
void button1_Click(
object sender, EventArgs e)
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
{
this.HideForm1.Start();
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
}
![InBlock.gif](p_w_picpaths/editer/InBlock.gif)
#endregion
转载于:https://blog.51cto.com/51cndo/102582