ComponentFactory.Krypton.Toolkit.RenderStandard.DrawBackSolidInside C# (CSharp) Method

DrawBackSolidInside() private method

private DrawBackSolidInside ( RenderContext context, Rectangle gradientRect, Color backColor1, Color backColor2, GraphicsPath path ) : void
context RenderContext
gradientRect System.Drawing.Rectangle
backColor1 Color
backColor2 Color
path System.Drawing.Drawing2D.GraphicsPath
return void
        private void DrawBackSolidInside(RenderContext context,
                                         Rectangle gradientRect,
                                         Color backColor1,
                                         Color backColor2,
                                         GraphicsPath path)
        {
            // Clip to prevent drawing outside the path
            using(Clipping clip = new Clipping(context.Graphics, path))
            {
                // Get the rectangle that encloses the path
                RectangleF rectF = path.GetBounds();

                // Convert to a pixel aligned rectangle
                Rectangle rect;

                // Do we have any non-integeer numbers to convert
                if ((Math.Round(rectF.X) != rectF.X) ||
                    (Math.Round(rectF.Y) != rectF.Y) ||
                    (Math.Round(rectF.Width) != rectF.Width) ||
                    (Math.Round(rectF.Height) != rectF.Height))
                {
                    int x = (int)Math.Round(rectF.X);
                    int y = (int)Math.Round(rectF.Y);
                    int width = (int)Math.Round(rectF.Width + 1 + (rectF.X - x));
                    int height = (int)Math.Round(rectF.Height + 1 + (rectF.Y - y));
                    rect = new Rectangle(x, y, width, height);
                }
                else
                    rect = new Rectangle((int)rectF.X, (int)rectF.Y, (int)rectF.Width, (int)rectF.Height);

                using (Brush backBrush1 = CreateColorBrush(gradientRect, backColor1, backColor1, PaletteColorStyle.Solid, 0f, VisualOrientation.Top),
                             backBrush2 = CreateColorBrush(gradientRect, backColor2, backColor2, PaletteColorStyle.Solid, 0f, VisualOrientation.Top))
                {
                    // Draw the first color over the entire area
                    context.Graphics.FillRectangle(backBrush1, rect);

                    // Draw the second color on the inside of the area
                    rect.Inflate(-2, -2);
                    context.Graphics.FillRectangle(backBrush2, rect);

                    // Draw the first color inside the rest of the area
                    rect.Inflate(-1, -1);
                    context.Graphics.FillRectangle(backBrush1, rect);
                }
            }
        }
RenderStandard