private System.Windows.Forms.Timer WindowShow;//定义一个计时器WindowShow
private void client_Load(object sender, EventArgs e)
{
try
{
this.Opacity = 0.1;//设置初始窗口透明度为0.1
WindowShow = new System.Windows.Forms.Timer();//初始化
WindowShow.Interval = 100;//间隔为0.1秒
WindowShow.Tick += WindowShowBySlide;//每经过0.1秒触发定时器,使窗口透明度加0.1
WindowShow.Start();//开始计时器
}
catch
{
throw;
}
}
private void WindowShowBySlide(object sender, EventArgs e)
{
if (this.Opacity != 1)
{
this.Opacity += 0.1;
}
else
{
WindowShow.Stop();
//WindowShow.Dispose();
}
}
Timer 计时器的初步使用(实现渐入效果)
最新推荐文章于 2021-02-12 12:45:12 发布