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

DrawBackGlassCenter() private static method

private static DrawBackGlassCenter ( RectangleF drawRect, Color color1, Color color2, Color glassColor1, Color glassColor2, float factorX, float factorY, VisualOrientation orientation, Graphics g, float glassPercent, IDisposable memento ) : IDisposable
drawRect System.Drawing.RectangleF
color1 Color
color2 Color
glassColor1 Color
glassColor2 Color
factorX float
factorY float
orientation VisualOrientation
g System.Drawing.Graphics
glassPercent float
memento IDisposable
return IDisposable
        private static IDisposable DrawBackGlassCenter(RectangleF drawRect,
                                                       Color color1,
                                                       Color color2,
                                                       Color glassColor1,
                                                       Color glassColor2,
                                                       float factorX,
                                                       float factorY,
                                                       VisualOrientation orientation,
                                                       Graphics g,
                                                       float glassPercent,
                                                       IDisposable memento)
        {
            // Cannot draw a path that contains a zero sized element
            if ((drawRect.Width > 0) && (drawRect.Height > 0))
            {
                MementoDouble cache;

                if ((memento == null) || !(memento is MementoDouble))
                {
                    if (memento != null)
                        memento.Dispose();

                    cache = new MementoDouble();
                    memento = cache;
                }
                else
                {
                    cache = (MementoDouble)memento;
                }

                // Draw the gradient effect background
                DrawBackGlassBasic(drawRect, color1, color2,
                                   glassColor1, glassColor2,
                                   factorX, factorY,
                                   orientation, g,
                                   glassPercent,
                                   ref cache.first);

                bool generate = true;
                MementoBackGlassCenter cacheThis;

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

                    cacheThis = new MementoBackGlassCenter(drawRect, color2);
                    cache.second = cacheThis;
                }
                else
                {
                    cacheThis = (MementoBackGlassCenter)cache.second;
                    generate = !cacheThis.UseCachedValues(drawRect, color2);
                }

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

                    cacheThis.path = new GraphicsPath();
                    cacheThis.path.AddEllipse(drawRect);
                    cacheThis.bottomBrush = new PathGradientBrush(cacheThis.path);
                    cacheThis.bottomBrush.CenterColor = color2;
                    cacheThis.bottomBrush.CenterPoint = new PointF(drawRect.X + (drawRect.Width / 2), drawRect.Y + (drawRect.Height / 2));
                    cacheThis.bottomBrush.SurroundColors = new Color[] { Color.Transparent };
                }

                g.FillRectangle(cacheThis.bottomBrush, drawRect);
            }

            return memento;
        }

Same methods

RenderGlassHelpers::DrawBackGlassCenter ( RenderContext context, Rectangle rect, Color backColor1, Color backColor2, VisualOrientation orientation, GraphicsPath path, IDisposable memento ) : IDisposable