3
我正在写一个扩展的进度条控件,目前已经100%开放源代码,并且我已经创建了一些带有渐变和纯色的基本样式。动画栏中的进度条winform
我想添加的一个选项是动画到酒吧,prety很像Windows 7和Vista的绿色进度条。所以我需要向%栏添加一个移动的“发光”,但是我对此的尝试看起来很糟糕。
我的方法是绘制一个具有设置大小的椭圆,并移动它的x位置,直到动画开始再次到达终点。
首先有没有人有没有链接或代码,以帮助我使用GDI或类似的方法来实现当前的Windows 7发光效果?
我还有其他几个动画,它们也会被添加到GDI中。
private void renderAnimation(PaintEventArgs e)
{
if (this.AnimType == animoptions.Halo)
{
Rectangle rec = e.ClipRectangle;
Rectangle glow = new Rectangle();
//SolidBrush brush = new SolidBrush(Color.FromArgb(100, Color.White));
//int offset = (int)(rec.Width * ((double)Value/Maximum)) - 4;
int offset = (int)(rec.Width/Maximum) * Value;
if (this.animxoffset > offset)
{
this.animxoffset = 0;
}
glow.Height = rec.Height - 4;
if (this.animxoffset + glow.X > offset)
{
glow.Width = offset - (this.animxoffset + 50);
}
else
{
glow.Width = 50;
}
glow.X = this.animxoffset;
LinearGradientBrush brush = new LinearGradientBrush(glow, Color.FromArgb(0, Color.White), Color.FromArgb(100, Color.White), LinearGradientMode.Horizontal);
e.Graphics.FillEllipse(brush, this.animxoffset, 2, glow.Width, glow.Height);
brush.Dispose();
string temp = offset.ToString();
e.Graphics.DrawString(temp + " : " + glow.X.ToString(), DefaultFont, Brushes.Black, 2, 2);
animTimer = new System.Timers.Timer();
animTimer.Interval = 10;
animTimer.Elapsed += new System.Timers.ElapsedEventHandler(t_Elapsed);
animTimer.Start();
}
}
void t_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
this.animTimer.Stop();
this.animxoffset += 2;
Invalidate();
}