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

DrawRibbonGroupNormalBorderSep() protected method

Internal rendering method.
protected DrawRibbonGroupNormalBorderSep ( bool showingInPopup, RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, IDisposable memento, bool pressed, bool tracking, bool dark ) : IDisposable
showingInPopup bool
context RenderContext
rect System.Drawing.Rectangle
state PaletteState
palette IPaletteRibbonBack
memento IDisposable
pressed bool
tracking bool
dark bool
return IDisposable
        protected virtual IDisposable DrawRibbonGroupNormalBorderSep(bool showingInPopup,
                                                                     RenderContext context,
                                                                     Rectangle rect,
                                                                     PaletteState state,
                                                                     IPaletteRibbonBack palette,
                                                                     IDisposable memento,
                                                                     bool pressed,
                                                                     bool tracking,
                                                                     bool dark)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);
                Color c3 = palette.GetRibbonBackColor3(state);
                Color c4 = palette.GetRibbonBackColor4(state);
                Color c5 = palette.GetRibbonBackColor5(state);

                bool generate = true;
                MementoRibbonGroupNormalBorderSep cache;

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

                    cache = new MementoRibbonGroupNormalBorderSep(rect, c1, c2, c3, c4, c5, tracking, dark);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonGroupNormalBorderSep)memento;
                    generate = !cache.UseCachedValues(rect, c1, c2, c3, c4, c5, tracking, dark);
                }

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

                    RectangleF rectF = new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2);
                    cache.totalBrush = new LinearGradientBrush(rectF, c2, c1, 90f);
                    cache.innerBrush = new LinearGradientBrush(rectF, c4, c3, 90f);
                    cache.trackSepBrush = new LinearGradientBrush(rectF, c5, c2, 90f);
                    cache.totalBrush.Blend = _ribbonGroup9Blend;
                    cache.innerBrush.Blend = _ribbonGroup9Blend;
                    cache.trackSepBrush.Blend = _ribbonGroup9Blend;
                    cache.innerPen = new Pen(cache.innerBrush);
                    cache.trackSepPen = new Pen(cache.trackSepBrush);
                    cache.trackBottomPen = new Pen(c5);

                    GraphicsPath trackingPath = new GraphicsPath();
                    trackingPath.AddEllipse(new Rectangle(rect.X, rect.Y + ( rect.Height / 2), rect.Width - 3, rect.Height));
                    cache.trackHighlightBrush = new PathGradientBrush(trackingPath);
                    cache.trackHighlightBrush.SurroundColors = new Color[] { Color.Transparent };
                    cache.trackHighlightBrush.CenterColor = (dark ? (rect.Width > 50 ? _whiten60 : _whiten45) : _whiten160);
                    cache.trackHighlightBrush.CenterPoint = new PointF(rect.X + (rect.Width - 3) / 2, rect.Height);
                    cache.trackFillBrush = new LinearGradientBrush(new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 1),
                                                                   (dark ? _whiten5 : _whiten10),
                                                                   (dark ? _whiten5 : _darken5), 90f);

                    cache.pressedFillBrush = new LinearGradientBrush(new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2),
                                                                    (dark ? Color.Empty : _whiten10),
                                                                    (dark ? _darken38 : _darken16), 90f);
                    cache.trackFillBrush.Blend = _linear50Blend;
                }

                if (!showingInPopup)
                {
                    context.Graphics.FillRectangle(cache.totalBrush, rect.Right - 3, rect.Top, 3, rect.Height);
                    context.Graphics.DrawLine(cache.innerPen, rect.Right - 2, rect.Top, rect.Right - 2, rect.Bottom - 1);
                }

                if (tracking || pressed)
                {

                    if (pressed)
                    {
                        // Lighent the top and darken the bottom of the fill area
                        context.Graphics.FillRectangle(cache.pressedFillBrush, rect.X, rect.Y, rect.Width - 2, rect.Height);
                    }
                    else if (tracking)
                    {
                        // Lighten the top and darken the bottom of the fill area
                        context.Graphics.FillRectangle(cache.trackFillBrush, rect.X, rect.Y, rect.Width - 1, rect.Height - 1);

                        // Draw the tracking highlight at bottom of area
                        context.Graphics.FillRectangle(cache.trackHighlightBrush, rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
                    }

                    if (!showingInPopup && !pressed && !dark)
                    {
                        // Lighten the right inner edge
                        context.Graphics.DrawLine(cache.trackSepPen, rect.Right - 3, rect.Top, rect.Right - 3, rect.Bottom - 1);
                    }

                    if (!showingInPopup && tracking)
                    {
                        // Lighten the bottom inner edge
                        context.Graphics.DrawLine(cache.trackBottomPen, rect.Right - 3, rect.Bottom - 1, rect.Left, rect.Bottom - 1);
                    }
                }
            }

            return memento;
        }
RenderStandard