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

DrawRibbonGroupAreaBorder3And4() protected method

Internal rendering method.
protected DrawRibbonGroupAreaBorder3And4 ( RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, IDisposable memento, bool gradientTop ) : IDisposable
context RenderContext
rect System.Drawing.Rectangle
state PaletteState
palette IPaletteRibbonBack
memento IDisposable
gradientTop bool
return IDisposable
        protected virtual IDisposable DrawRibbonGroupAreaBorder3And4(RenderContext context,
                                                                     Rectangle rect,
                                                                     PaletteState state,
                                                                     IPaletteRibbonBack palette,
                                                                     IDisposable memento,
                                                                     bool gradientTop)
        {
            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;
                MementoRibbonGroupAreaBorder3 cache;

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

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

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

                    Rectangle innerRect = rect;
                    innerRect.Height -= 3;
                    int halfHeight = innerRect.Height / 2;
                    cache.borderRect = innerRect;
                    cache.borderPoints = new Point[] { new Point(innerRect.X, rect.Y), new Point(innerRect.X, innerRect.Bottom), new Point(innerRect.Right, innerRect.Bottom), new Point(innerRect.Right, innerRect.Top) };
                    cache.backRect1 = new Rectangle(innerRect.X, innerRect.Y, rect.Width, halfHeight);
                    cache.backRect2 = new Rectangle(innerRect.X, innerRect.Y + halfHeight, innerRect.Width, innerRect.Height - halfHeight);
                    cache.backBrush1 = new LinearGradientBrush(new RectangleF(cache.backRect1.X - 1, cache.backRect1.Y - 1, cache.backRect1.Width + 2, cache.backRect1.Height + 1), c3, c4, 90f);
                    cache.backBrush2 = new LinearGradientBrush(new RectangleF(cache.backRect2.X - 1, cache.backRect2.Y - 1, cache.backRect2.Width + 2, cache.backRect2.Height + 1), c4, c5, 90f);
                    cache.backBrush3 = new SolidBrush(c5);
                    cache.gradientBorderBrush = new LinearGradientBrush(new RectangleF(cache.backRect1.X - 1, cache.backRect1.Y - 1, cache.backRect1.Width + 2, 3), c1, c2, 0f);
                    cache.gradientBorderBrush.Blend = _ribbonGroupArea3;
                    cache.gradientBorderPen = (gradientTop ? new Pen(cache.gradientBorderBrush) :  new Pen(c1));
                    cache.solidBorderPen = new Pen(c2);
                    cache.shadowPen1 = new Pen(CommonHelper.MergeColors(c5, 0.4f, c1, 0.6f));
                    cache.shadowPen2 = new Pen(CommonHelper.MergeColors(c5, 0.25f, c1, 0.75f));
                    cache.shadowPen3 = new Pen(CommonHelper.MergeColors(c5, 0.1f, c1, 0.9f));
                }

                // Draw solid background for entire area
                context.Graphics.FillRectangle(cache.backBrush3, rect);

                // Fill area inside the border with a gradient effect
                context.Graphics.FillRectangle(cache.backBrush1, cache.backRect1);
                context.Graphics.FillRectangle(cache.backBrush2, cache.backRect2);

                // Draw the solid border around the edge
                context.Graphics.DrawLine(cache.gradientBorderPen, cache.borderRect.X, cache.borderRect.Y, cache.borderRect.Right, cache.borderRect.Y);
                context.Graphics.DrawLines(cache.solidBorderPen, cache.borderPoints);

                // Draw shadow lines at bottom
                context.Graphics.DrawLine(cache.shadowPen3, rect.X, rect.Bottom - 2, rect.Right, rect.Bottom - 2);
                context.Graphics.DrawLine(cache.shadowPen2, rect.X, rect.Bottom - 1, rect.Right, rect.Bottom - 1);
                context.Graphics.DrawLine(cache.shadowPen1, rect.X, rect.Bottom, rect.Right, rect.Bottom);
            }

            return memento;
        }
RenderStandard