引言:
迅雷7 发布以来,就对它的“动态图标按钮”特效垂涎很久了,现在终于有机会和心情来模拟这个效果。我坚信在编程的世界,没有做不到,只有想不到!
特效一览:
using System; using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } int IconState = 0;//标记图标状态。 private void pictureBox1_MouseEnter(object sender, EventArgs e) { timer1.Stop(); this.pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.动态1; //this.pictureBox1.Image = Image.FromFile("动态1.gif"); IconState = 1; timer1.Start(); } private void pictureBox1_MouseLeave(object sender, EventArgs e) { timer1.Stop(); this.pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.动态2; //this.pictureBox1.Image = Image.FromFile("动态2.gif"); IconState = 2; timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { timer1.Stop(); switch (IconState) { case 1://图标状态1,将显示变为静态2图标 this.pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.静态2; //this.pictureBox1.Image = Image.FromFile("静态2.gif"); break; case 2://图标状态2,将显示变为静态1图标 this.pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.静态1; //this.pictureBox1.Image = Image.FromFile("静态1.gif"); break; default: break; } IconState = 0; } } }界面显示效果如下:
源代码下载:
迅雷7动态图标按钮模拟.zip[By:Asion Tang] 2011年3月12日 14:24:48
最新评论