ImageGlass.ImageBox.DrawGlowShadow C# (CSharp) Method

DrawGlowShadow() protected method

Draws a glow shadow.
protected DrawGlowShadow ( Graphics g, Rectangle viewPort ) : void
g System.Drawing.Graphics The graphics.
viewPort System.Drawing.Rectangle The view port.
return void
        protected virtual void DrawGlowShadow(Graphics g, Rectangle viewPort)
        {
            // Glow code adapted from http://www.codeproject.com/Articles/372743/gGlowBox-Create-a-glow-effect-around-a-focused-con

            g.SetClip(viewPort, CombineMode.Exclude); // make sure the inside glow doesn't appear

            using (GraphicsPath path = new GraphicsPath())
            {
                int glowSize;
                int feather;

                path.AddRectangle(viewPort);
                glowSize = DropShadowSize * 3;
                feather = 50;

                for (int i = 1; i <= glowSize; i += 2)
                {
                    int alpha;

                    alpha = feather - ((feather / glowSize) * i);

                    using (Pen pen = new Pen(Color.FromArgb(alpha, ImageBorderColor), i)
                                     {
                                         LineJoin = LineJoin.Round
                                     })
                    {
                        g.DrawPath(pen, path);
                    }
                }
            }
        }
ImageBox