Animated winform idle panel

I am currently writing advanced execution control, 100% open source, and I have created some basic styles with gradients and solid colors.

One option I wanted to add is the animation in the bar, prety is very similar to Windows 7 and the green progress bar. So I need to add a moving "Glow" to% bar, however my attempt at that looks terrible.

My method is to draw an ellipse with the given size and move it to the x position until it reaches the end when the animation starts again.

First, does anyone have any links or code to help me achieve the current window 7 glow effect using GDI or some similar method?

I have a few other animations to be added to the panel as well, so 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();


    }

      

+3


source to share


1 answer


This is just an example of a glow repeating across the feather array. You can also use a transparent image (although this can have a performance impact).



        Pen[] gradient = { new Pen(Color.FromArgb(255, 200, 200, 255)), new Pen(Color.FromArgb(150, 200, 200, 255)), new Pen(Color.FromArgb(100, 200, 200, 255)) };
        int x = 20;
        int y = 20;
        int sizex = 200;
        int sizey = 10;
        int value = 25;


        //draw progress bar basic outline (position - 1 to compensate for the outline)
        e.Graphics.DrawRectangle(Pens.Black, new Rectangle(x-1, y-1, sizex, sizey));

        //draw the percentage done
        e.Graphics.FillRectangle(Brushes.AliceBlue, new Rectangle(x, y, (sizex/100)*value, sizey));

        //to add the glow effect just add lines around the area you want to glow.
        for (int i = 0; i < gradient.Length; i++)
        {
            e.Graphics.DrawRectangle(gradient[i], new Rectangle(x - (i + 1), y - (i + 1), (sizex / 100) * value + (2 * i), sizey + (2 * i)));
        }

      

0


source







All Articles