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

DrawRibbonAppMenuInner() protected method

Internal rendering method.
protected DrawRibbonAppMenuInner ( RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, IDisposable memento ) : IDisposable
context RenderContext
rect System.Drawing.Rectangle
state PaletteState
palette IPaletteRibbonBack
memento IDisposable
return IDisposable
        protected virtual IDisposable DrawRibbonAppMenuInner(RenderContext context,
                                                             Rectangle rect,
                                                             PaletteState state,
                                                             IPaletteRibbonBack palette,
                                                             IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);

                bool generate = true;
                MementoRibbonAppButtonInner cache;

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

                    cache = new MementoRibbonAppButtonInner(rect, c1, c2);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonAppButtonInner)memento;
                    generate = !cache.UseCachedValues(rect, c1, c2);
                }

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

                    cache.outsideBrush = new SolidBrush(c1);
                    cache.insideBrush = new SolidBrush(c2);
                }

                // Draw the outside in one color and the inside with another
                context.Graphics.FillRectangle(cache.outsideBrush, rect);
                rect.Inflate(-1, -1);
                context.Graphics.FillRectangle(cache.insideBrush, rect);
            }

            return memento;
        }
RenderStandard