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

DrawRibbonGroupNormalTitle() protected method

Internal rendering method.
protected DrawRibbonGroupNormalTitle ( 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 DrawRibbonGroupNormalTitle(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;
                MementoRibbonGroupNormalTitle cache;

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

                    cache = new MementoRibbonGroupNormalTitle(rect, c1, c2);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonGroupNormalTitle)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();

                    GraphicsPath titlePath = new GraphicsPath();

                    // Create the rounded bottom edge to fit inside a group border
                    titlePath.AddLine(rect.Left, rect.Top, rect.Right - 1, rect.Top);
                    titlePath.AddLine(rect.Right - 1, rect.Top, rect.Right - 1, rect.Bottom - 3);
                    titlePath.AddLine(rect.Right - 1, rect.Bottom - 3, rect.Right - 3, rect.Bottom - 1);
                    titlePath.AddLine(rect.Right - 3, rect.Bottom - 1, rect.Left + 2, rect.Bottom - 1);
                    titlePath.AddLine(rect.Left + 2, rect.Bottom - 1, rect.Left, rect.Bottom - 3);
                    titlePath.AddLine(rect.Left, rect.Bottom - 3, rect.Left, rect.Top);

                    RectangleF rectF = new RectangleF(rect.Left - 0.5f, rect.Top - 0.5f, rect.Width + 1, rect.Height + 1);
                    cache.titleBrush = new LinearGradientBrush(rectF, c1, c2, 90f);
                    cache.titlePath = titlePath;
                }

                // Fill path area with a gradient brush
                context.Graphics.FillPath(cache.titleBrush, cache.titlePath);
            }

            return memento;
        }
RenderStandard