using System;
using System.Drawing;
using System.Windows.Forms;
namespace Test_03_渐变效果_
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Opacity = 0; //设置透明度为0
this.BackgroundImage = Image.FromFile(Application.StartupPath + @"/2.jpg"); //加载图片
this.BackgroundImageLayout = ImageLayout.Stretch; //拉伸
//this.FormBorderStyle = FormBorderStyle.None; //去边框
this.WindowState = FormWindowState.Maximized; //最大化
this.timer1.Enabled = true; //启用时间控件
}
private void timer1_Tick(object sender, EventArgs e)
{
this.Opacity += 0.02; //透明度变化
if (this.Opacity == 1)
{
this.timer1.Enabled = false; //关闭时间控件
}
}
}
}