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

DrawRibbonQATMinibarDouble() protected method

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

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

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

                    GraphicsPath borderPath = new GraphicsPath();
                    GraphicsPath topRight1 = new GraphicsPath();
                    GraphicsPath bottomLeft1 = new GraphicsPath();

                    // Find values needed for drawing the main border
                    int left = rect.X + 1;
                    int right = rect.Right - 3;
                    int top = rect.Y + 2;
                    int bottom = rect.Bottom - 3;
                    int middle = top + (bottom - top) / 2;

                    // Construct closed path for the main border
                    borderPath.AddLine(right - 8, top + 0.25f, right - 5, top + 1);
                    borderPath.AddLine(right - 5, top + 1, right - 1, top + 5);
                    borderPath.AddLine(right - 1, top + 5, right, top + 8);
                    borderPath.AddLine(right, top + 8, right + 0.40f, middle);
                    borderPath.AddLine(right + 0.40f, middle, right, bottom - 8.25f);
                    borderPath.AddLine(right, bottom - 8.25f, right - 1, bottom - 5.25f);
                    borderPath.AddLine(right - 1, bottom - 5.25f, right - 5, bottom - 1.25f);
                    borderPath.AddLine(right - 5, bottom - 1.25f, right - 8, bottom);
                    borderPath.AddLine(right - 8, bottom, left + 9, bottom);
                    borderPath.AddLine(left + 9, bottom, left + 6, bottom - 1.25f);
                    borderPath.AddLine(left + 6, bottom - 1.25f, left + 2, bottom - 5.25f);
                    borderPath.AddLine(left + 2, bottom - 5.25f, left + 1, bottom - 8.25f);
                    borderPath.AddLine(left + 1, bottom - 8.25f, left + 0.40f, middle);
                    borderPath.AddLine(left + 0.40f, middle, left + 1, top + 8);
                    borderPath.AddLine(left + 1, top + 8, left + 2, top + 5);
                    borderPath.AddLine(left + 2, top + 5, left + 6, top + 1);
                    borderPath.AddLine(left + 6, top + 1, left + 9, top + 0.25f);
                    borderPath.AddLine(left + 9, top + 0.25f, right - 8, top + 0.25f);

                    // Create the top right light paths
                    topRight1.AddLine(rect.Left + 8, rect.Top + 3.25f, rect.Left + 10, rect.Top + 1.25f);
                    topRight1.AddLine(rect.Left + 10, rect.Top + 1.25f, rect.Right - 11, rect.Top + 1.25f);
                    topRight1.AddLine(rect.Right - 11, rect.Top + 1.5f, rect.Right - 8, rect.Top + 2.25f);
                    topRight1.AddLine(rect.Right - 8, rect.Top + 2.25f, rect.Right - 5, rect.Top + 5.75f);

                    // Create the bottom left light paths
                    bottomLeft1.AddLine(rect.Left + 13, rect.Bottom - 2, rect.Right - 11, rect.Bottom - 2);
                    bottomLeft1.AddLine(rect.Right - 11, rect.Bottom - 2, rect.Right - 8.5f, rect.Bottom - 3);
                    bottomLeft1.AddLine(rect.Right - 8.5f, rect.Bottom - 3, rect.Right - 4.5f, rect.Bottom - 7);
                    bottomLeft1.AddLine(rect.Right - 4.5f, rect.Bottom - 7, rect.Right - 2.5f, rect.Bottom - 9);
                    bottomLeft1.AddLine(rect.Right - 2.5f, rect.Bottom - 9, rect.Right - 2, rect.Bottom - 11);
                    bottomLeft1.AddLine(rect.Right - 2, rect.Bottom - 11, rect.Right - 2, rect.Bottom - 15);

                    RectangleF gradientRect = rect;
                    gradientRect.Y += 1.5f;
                    gradientRect.Height *= 1.25f;
                    cache.innerBrush = new LinearGradientBrush(gradientRect, c2, c3, 90f);
                    cache.innerBrush.SetSigmaBellShape(0.5f);

                    cache.borderPath = borderPath;
                    cache.topRight1 = topRight1;
                    cache.bottomLeft1 = bottomLeft1;
                    cache.lightPen = new Pen(c4, 2f);
                    cache.borderPen = new Pen(c1);
                    cache.whitenPen = new Pen(c5);
                }

                using (AntiAlias aa = new AntiAlias(context.Graphics))
                {
                    if (!composition)
                    {
                        // Draw the light borders
                        context.Graphics.DrawPath(cache.lightPen, cache.topRight1);
                        context.Graphics.DrawPath(cache.lightPen, cache.bottomLeft1);

                        // Draw the inside background and main border
                        context.Graphics.FillPath(cache.innerBrush, cache.borderPath);
                        context.Graphics.DrawPath(cache.borderPen, cache.borderPath);
                    }
                    else
                    {
                        // Fill with a semi-transparent background/border
                        context.Graphics.FillPath(_compositionBrush, cache.borderPath);
                        context.Graphics.DrawPath(_compositionPen, cache.borderPath);
                    }
                }
            }

            return memento;
        }
RenderStandard