ComponentFactory.Krypton.Toolkit.RenderOffice2013.DrawRibbonApplicationTab C# (CSharp) Method

DrawRibbonApplicationTab() public method

Draw the application tab.
public DrawRibbonApplicationTab ( PaletteRibbonShape shape, RenderContext context, Rectangle rect, PaletteState state, Color baseColor1, Color baseColor2, IDisposable memento ) : IDisposable
shape PaletteRibbonShape Ribbon shape.
context RenderContext Rendering context.
rect System.Drawing.Rectangle Target rectangle.
state PaletteState State associated with rendering.
baseColor1 Color Base color1 used for drawing the ribbon tab.
baseColor2 Color Base color2 used for drawing the ribbon tab.
memento IDisposable Cached values to use when drawing.
return IDisposable
        public override IDisposable DrawRibbonApplicationTab(PaletteRibbonShape shape,
                                                             RenderContext context,
                                                             Rectangle rect,
                                                             PaletteState state,
                                                             Color baseColor1,
                                                             Color baseColor2,
                                                             IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                bool generate = true;
                MementoRibbonAppTab2013 cache;

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

                    cache = new MementoRibbonAppTab2013(rect, baseColor1);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonAppTab2013)memento;
                    generate = !cache.UseCachedValues(rect, baseColor1);
                }

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

                    // Create common paths to all the app tab states
                    cache.GeneratePaths(rect, state);
                    //cache.borderPen = new Pen(baseColor1);

                    // Create state specific colors/brushes/pens
                    switch (state)
                    {
                        case PaletteState.Normal:
                            //cache.borderBrush = new SolidBrush(baseColor1);
                            cache.insideFillBrush = new SolidBrush(baseColor1);

                            //cache.insideFillBrush.SetSigmaBellShape(0.33f);
                            //cache.highlightBrush.CenterColor = Color.FromArgb(64, Color.White);
                            break;
                        case PaletteState.Tracking:
                            cache.insideFillBrush = new SolidBrush(baseColor2);
                            //cache.borderBrush = new SolidBrush(baseColor2);
                            //cache.insideFillBrush = new LinearGradientBrush(new RectangleF(rect.X, rect.Y + 1, rect.Width, rect.Height),
                            //                                                CommonHelper.MergeColors(baseColor1, 0.3f, baseColor2, 0.7f),
                            //                                                CommonHelper.MergeColors(baseColor1, 0.6f, baseColor2, 0.4f),
                            //                                                90f);

                            //cache.insideFillBrush.SetSigmaBellShape(0.33f);
                            //cache.highlightBrush.CenterColor = Color.FromArgb(100, Color.White);
                            break;
                        case PaletteState.Tracking | PaletteState.FocusOverride:
                            cache.insideFillBrush = new SolidBrush(ControlPaint.LightLight(baseColor2));
                            //cache.borderBrush = new SolidBrush(ControlPaint.LightLight(baseColor2));
                            //cache.insideFillBrush = new LinearGradientBrush(new RectangleF(rect.X, rect.Y + 1, rect.Width, rect.Height),
                            //                                                CommonHelper.MergeColors(baseColor1, 0.3f, baseColor2, 0.7f),
                            //                                                CommonHelper.MergeColors(baseColor1, 0.6f, baseColor2, 0.4f),
                            //                                                90f);

                            //cache.insideFillBrush.SetSigmaBellShape(0.33f);
                            //cache.highlightBrush.CenterColor = ControlPaint.LightLight(baseColor2);
                            break;
                        case PaletteState.Pressed:
                            cache.insideFillBrush = new SolidBrush(baseColor2);

                            //cache.borderBrush = new SolidBrush(CommonHelper.MergeColors(baseColor1, 0.5f, baseColor2, 0.5f));
                            //cache.insideFillBrush = new LinearGradientBrush(new RectangleF(rect.X, rect.Y + 1, rect.Width, rect.Height),
                            //                                                CommonHelper.MergeColors(baseColor1, 0.3f, baseColor2, 0.7f),
                            //                                                CommonHelper.MergeColors(baseColor1, 0.75f, baseColor2, 0.25f),
                            //                                                90f);

                            //cache.insideFillBrush.SetSigmaBellShape(0f);
                            //cache.highlightBrush.CenterColor = Color.FromArgb(90, Color.White);
                            break;
                    }
                }

                // Fill the entire tab area and then add a border around the edge
                //context.Graphics.FillPath(cache.borderBrush, cache.borderFillPath);

                // Draw the outside border
                //using (AntiAlias aa = new AntiAlias(context.Graphics))
                //    context.Graphics.DrawPath(cache.borderPen, cache.borderPath);

                // Fill inside area
                //context.Graphics.FillPath(cache.insideFillBrush, cache.insideFillPath);
                context.Graphics.FillRectangle(cache.insideFillBrush, cache.rect);

                // Draw highlight over bottom half
                //using (Clipping clip = new Clipping(context.Graphics, cache.insideFillPath))
                //    context.Graphics.FillPath(cache.highlightBrush, cache.highlightPath);
            }

            return memento;
        }