读书人

用C#做出像金山毒霸2012SP3.5的关闭窗

发布时间: 2012-05-05 17:21:10 作者: rapoo

用C#做出像金山毒霸2012SP3.5的关闭窗口的效果
我写了一段代码,不过不是很好,没它的漂亮,大家出出主意。
我的代码如下:
[code=C#][/code]
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事件中,但我把代码放过去效果没有出现前窗体就被关闭了。



[解决办法]
if (true)为什么这里为true
{


if (Opacity + 0.1 >= 1.0)
{
Opacity -= 0.1;

}
else这里无法问
{
Opacity = 0.0;
timer1.Stop();

}

[解决办法]

探讨
if (true)为什么这里为true
{
if (Opacity + 0.1 >= 1.0)
{
Opacity -= 0.1;

}
else这里无法问
{
Opacity = 0.0;
timer1.Stop();

}

[解决办法]
那个效果好,渐变透明,上下自中消失,我也想弄个

[解决办法]
为什么不用wpf。。。。
[解决办法]
探讨

为什么不用wpf。。。。

[解决办法]
探讨

引用:

为什么不用wpf。。。。

WPF 麻烦...

读书人网 >C#

热点推荐