C#一個漸變並且消失的窗體

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.timer1.Enabled = true;//獲取當前運行時間
this.Opacity = 1;//獲取當前窗體的透明度級別;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (this.Opacity >0.9)
{
this.Opacity = this.Opacity -0.01;//窗體以0.01的速度漸變
}
else if (this.Opacity < 0)
{
this.timer1.Enabled = false;//時間爲false
}
else
{
Close();///漸變消失
}

}
}
}


 


.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章