我写了一段代码,不过不是很好,没它的漂亮,大家出出主意。
我的代码如下:
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;namespace 透明渐变效果
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void timer1_Tick(object sender, EventArgs e)//透明渐变效果
{
if (true)
{
if (Opacity + 0.1 >= 1.0)
{
Opacity -= 0.1;
}
else
{
Opacity = 0.0;
timer1.Stop(); } }
else
{ if(Opacity - 0.1<= 0.0)
{
Opacity = 0.0;
timer1.Stop();
}
else
{
Opacity -= 0.1;
} }
} private void toolStripProgressBar1_Click(object sender, EventArgs e)
{
} private void timer2_Tick(object sender, EventArgs e)//窗口渐变效果
{
int d = 45; if (true)
{
if (Height + d >= 450)
{
Height -= d;
}
else
{
Height = 0;
timer2.Stop(); }
}
else
{ if(Height - d <= 0)
{
Height = 0;
timer1.Stop(); }
else
{
Height -= d;
}
}
} private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
} private void Form1_Load(object sender, EventArgs e)
{
} private void button1_Click(object sender, EventArgs e)
{
Height = 450;
timer2.Start();//窗口渐变效果
Opacity = 1.0;
timer1.Start();//透明度效果
}
}
}
timer1和timer2的Interval的值都设为200,点击按钮1就可以看到效果
我看的金山毒霸是窗体收缩的速度好像是越来越快的,应该收缩速度也是要渐变的,第二个是在关闭窗体的formclosing事件中,但我把代码放过去效果没有出现前窗体就被关闭了。
我的代码如下:
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;namespace 透明渐变效果
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void timer1_Tick(object sender, EventArgs e)//透明渐变效果
{
if (true)
{
if (Opacity + 0.1 >= 1.0)
{
Opacity -= 0.1;
}
else
{
Opacity = 0.0;
timer1.Stop(); } }
else
{ if(Opacity - 0.1<= 0.0)
{
Opacity = 0.0;
timer1.Stop();
}
else
{
Opacity -= 0.1;
} }
} private void toolStripProgressBar1_Click(object sender, EventArgs e)
{
} private void timer2_Tick(object sender, EventArgs e)//窗口渐变效果
{
int d = 45; if (true)
{
if (Height + d >= 450)
{
Height -= d;
}
else
{
Height = 0;
timer2.Stop(); }
}
else
{ if(Height - d <= 0)
{
Height = 0;
timer1.Stop(); }
else
{
Height -= d;
}
}
} private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
} private void Form1_Load(object sender, EventArgs e)
{
} private void button1_Click(object sender, EventArgs e)
{
Height = 450;
timer2.Start();//窗口渐变效果
Opacity = 1.0;
timer1.Start();//透明度效果
}
}
}
timer1和timer2的Interval的值都设为200,点击按钮1就可以看到效果
我看的金山毒霸是窗体收缩的速度好像是越来越快的,应该收缩速度也是要渐变的,第二个是在关闭窗体的formclosing事件中,但我把代码放过去效果没有出现前窗体就被关闭了。
解决方案 »
- 怎样将 前台js获取到的 byte[]数据图片显示出来
- vs.net环境里怎么打开一个visio fox开发的窗体
- C# 调用 C++.net写的DLL的问题
- DevExpressv9.2源码编译说明
- 企业库的data事务和linq to sql的事务无法通用....这个遇到过吗?
- 怪得让我瞠舌的问题
- 二氧化鬼进~~你给的代码有点问题~~
- c# 中的string [] 怎么传递到c++ dll 函数中对应的 p** 参数?
- listbox两级联动根据listbox中的信息查找数据库的问题
- 2005vs连接2000sql(服务器)的问题
- DataGridView控件设计问题
- 很强大的木马,应该怎么防
{
if (Opacity + 0.1 >= 1.0)
{
Opacity -= 0.1;
}
else这里无法问
{
Opacity = 0.0;
timer1.Stop(); }
你竟然说WPF麻烦…………winform做出来的动画效果很生硬的,他们本身就是用的WPF,比如迅雷
据了解迅雷并未使用WPF,而是有一套自己开发的UI系统,谢谢....UpdateLayeredWindow...函数
{
base.OnClosing(e);
while (true)
{
if (this.Height <= 2)
break;
if (this.Opacity > 0)
this.Opacity -= 0.003;
this.Top += 5;
this.Height -= 10;
}
this.Dispose();
this.Close();
Application.Exit();
}