- 淡入淡出
- 变大变小
- 缓升缓降
实现的代码片段参考如下:
淡入淡出
[复制到剪贴板] |
public Form1()
{
InitializeComponent();
Opacity = 0;
timer1.Interval = 10;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (isShow)
{
if (Height < height)
{
Height += 1;
}
else
{
timer1.Stop();
}
}
else
{
if (ClientSize.Height > 0)
{
Height -= 1;
}
else
{
timer1.Stop();
Close();
}
}
}
变大变小
[复制到剪贴板] |
public Form2()
{
InitializeComponent();
height = Height;
Size = new Size(Width, 0);
timer1.Interval = 10;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (isShow)
{
if (Height < height)
{
Height += 1;
}
else
{
timer1.Stop();
}
}
else
{
if (ClientSize.Height > 0)
{
Height -= 1;
}
else
{
timer1.Stop();
Close();
}
}
}
缓升缓降
[复制到剪贴板] |
public Form3()
{
InitializeComponent();
timer1.Interval = 10;
}
private void Form3_Load(object sender, EventArgs e)
{
Location = new Point(screenRect.Width - Width, screenRect.Height);
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (isShow)
{
if (Location.Y > screenRect.Height-Height)
{
Location = new Point(Location.X, Location.Y - 1);
}
else
{
timer1.Stop();
}
}
else
{
if (Location.Y < screenRect.Height )
{
Location = new Point(Location.X, Location.Y + 1);
}
else
{
timer1.Stop();
Close();
}
}
}