ComponentFactory.Krypton.Toolkit.RenderGlassHelpers.DrawBackGlassThreeEdge C# (CSharp) Method

DrawBackGlassThreeEdge() public static method

Draw a background in glass effect with three edges lighter.
public static DrawBackGlassThreeEdge ( RenderContext context, Rectangle rect, Color backColor1, Color backColor2, VisualOrientation orientation, GraphicsPath path, IDisposable memento ) : IDisposable
context RenderContext Rendering context.
rect System.Drawing.Rectangle Rectangle to draw.
backColor1 Color First color.
backColor2 Color Second color.
orientation VisualOrientation Drawing orientation.
path System.Drawing.Drawing2D.GraphicsPath Clipping path.
memento IDisposable Cache used for drawing.
return IDisposable
        public static IDisposable DrawBackGlassThreeEdge(RenderContext context,
                                                         Rectangle rect,
                                                         Color backColor1,
                                                         Color backColor2,
                                                         VisualOrientation orientation,
                                                         GraphicsPath path,
                                                         IDisposable memento)
        {
            using (Clipping clip = new Clipping(context.Graphics, path))
            {
                bool generate = true;
                MementoBackGlassThreeEdge cache;

                // Access a cache instance and decide if cache resources need generating
                if ((memento == null) || !(memento is MementoBackGlassThreeEdge))
                {
                    if (memento != null)
                        memento.Dispose();

                    cache = new MementoBackGlassThreeEdge(rect, backColor1, backColor2, orientation);
                    memento = cache;
                }
                else
                {
                    cache = (MementoBackGlassThreeEdge)memento;
                    generate = !cache.UseCachedValues(rect, backColor1, backColor2, orientation);
                }

                // Do we need to generate the contents of the cache?
                if (generate)
                {
                    // Dispose of existing values
                    cache.Dispose();

                    // Generate color values
                    cache.colorA1L = CommonHelper.MergeColors(backColor1, 0.7f, Color.White, 0.3f);
                    cache.colorA2L = CommonHelper.MergeColors(backColor2, 0.7f, Color.White, 0.3f);
                    cache.colorA2LL = CommonHelper.MergeColors(cache.colorA2L, 0.8f, Color.White, 0.2f);
                    cache.colorB2LL = CommonHelper.MergeColors(backColor2, 0.8f, Color.White, 0.2f);
                    cache.rectB = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 1, rect.Height - 2);
                }

                // Draw entire area in a lighter version
                cache.first = DrawBackGlassLinear(rect, rect,
                                                  cache.colorA1L, _glassColorLight,
                                                  cache.colorA2L, cache.colorA2LL,
                                                  orientation,
                                                  context.Graphics,
                                                  _fullGlassLength,
                                                  cache.first);

                // Draw the inside area in the full color
                cache.second = DrawBackGlassLinear(cache.rectB, cache.rectB,
                                                   backColor1, _glassColorLight,
                                                   backColor2, cache.colorB2LL,
                                                   orientation,
                                                   context.Graphics,
                                                   _fullGlassLength,
                                                   cache.second);

                return cache;
            }
        }