Пример #1
0
        /// <summary>
        /// Draw the application tab.
        /// </summary>
        /// <param name="shape">Ribbon shape.</param>
        /// <param name="context">Rendering context.</param>
        /// <param name="rect">Target rectangle.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="baseColor1">Base color1 used for drawing the ribbon tab.</param>
        /// <param name="baseColor2">Base color2 used for drawing the ribbon tab.</param>
        /// <param name="memento">Cached values to use when drawing.</param>
        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))
            {
                var generate = true;
                MementoRibbonAppTab2013 cache;

                // Access a cache instance and decide if cache resources need generating
                if (memento is MementoRibbonAppTab2013 tab2013)
                {
                    cache    = tab2013;
                    generate = !cache.UseCachedValues(rect, baseColor1);
                }
                else
                {
                    memento?.Dispose();

                    cache   = new MementoRibbonAppTab2013(rect, baseColor1);
                    memento = cache;
                }

                // 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
                    cache.insideFillBrush = state switch
                    {
                        PaletteState.Normal =>
                        //cache.borderBrush = new SolidBrush(baseColor1);
                        new SolidBrush(baseColor1),
                        PaletteState.Tracking => new SolidBrush(baseColor2),
                        PaletteState.Tracking | PaletteState.FocusOverride => new SolidBrush(
                            ControlPaint.LightLight(baseColor2)),
                        PaletteState.Pressed => new SolidBrush(baseColor2),
                        _ => cache.insideFillBrush
                    };
                }

                // 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);
        }
Пример #2
0
        /// <summary>
        /// Draw the application tab.
        /// </summary>
        /// <param name="shape">Ribbon shape.</param>
        /// <param name="context">Rendering context.</param>
        /// <param name="rect">Target rectangle.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="baseColor1">Base color1 used for drawing the ribbon tab.</param>
        /// <param name="baseColor2">Base color2 used for drawing the ribbon tab.</param>
        /// <param name="memento">Cached values to use when drawing.</param>
        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);
        }
Пример #3
0
        /// <summary>
        /// Draw the application tab.
        /// </summary>
        /// <param name="shape">Ribbon shape.</param>
        /// <param name="context">Rendering context.</param>
        /// <param name="rect">Target rectangle.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="baseColor1">Base color1 used for drawing the ribbon tab.</param>
        /// <param name="baseColor2">Base color2 used for drawing the ribbon tab.</param>
        /// <param name="memento">Cached values to use when drawing.</param>
        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;
        }