Beispiel #1
0
        /// <summary>
        /// Gets the second background color for the ribbon item.
        /// </summary>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>Color value.</returns>
        public Color GetRibbonBackColor2(PaletteState state)
        {
            Color retColor = _inherit.GetRibbonBackColor2(state);

            // If empty then try and recover the context specific color
            if (retColor == Color.Empty)
            {
                retColor = CheckForContextColor(state);
            }

            return(retColor);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the second background color for the ribbon item.
        /// </summary>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <param name="style">Style of the ribbon color requested.</param>
        /// <returns>Color value.</returns>
        public override Color GetRibbonBackColor2(PaletteRibbonBackStyle style, PaletteState state)
        {
            IPaletteRibbonBack inherit = GetBackInherit(state);

            if (inherit != null)
            {
                return(inherit.GetRibbonBackColor2(state));
            }
            else
            {
                return(Target.GetRibbonBackColor2(style, state));
            }
        }
        /// <summary>
        /// Gets the second background color for the ribbon item.
        /// </summary>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>Color value.</returns>
        public override Color GetRibbonBackColor2(PaletteState state)
        {
            if (_apply)
            {
                Color ret = _primaryBack.GetRibbonBackColor2(_override ? _state : state);

                if (ret == Color.Empty)
                    ret = _backupBack.GetRibbonBackColor2(state);

                return ret;
            }
            else
                return _backupBack.GetRibbonBackColor2(state);
        }
Beispiel #4
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected override IDisposable DrawRibbonQATFullbarSquare(RenderContext context,
                                                                  Rectangle rect,
                                                                  PaletteState state,
                                                                  IPaletteRibbonBack palette,
                                                                  IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color color = palette.GetRibbonBackColor2(state);

                bool generate = true;
                MementoRibbonQATFullbarSquare2016 cache;

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

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

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

                    cache.brush = new SolidBrush(color);
                }

                // Fill entire area in background brush
                context.Graphics.FillRectangle(cache.brush, rect);
            }

            return(memento);
        }
Beispiel #5
0
        /// <summary>
        /// Gets the second background color for the ribbon item.
        /// </summary>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>Color value.</returns>
        public override Color GetRibbonBackColor2(PaletteState state)
        {
            if (Apply)
            {
                Color ret = _primaryBack.GetRibbonBackColor2(Override ? OverrideState : state);

                if (ret == Color.Empty)
                {
                    ret = _backupBack.GetRibbonBackColor2(state);
                }

                return(ret);
            }
            else
            {
                return(_backupBack.GetRibbonBackColor2(state));
            }
        }
Beispiel #6
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonQATFullbarSquare(RenderContext context,
                                                                 Rectangle rect,
                                                                 PaletteState state,
                                                                 IPaletteRibbonBack palette,
                                                                 IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);
                Color c3 = palette.GetRibbonBackColor3(state);

                bool generate = true;
                MementoRibbonQATFullbarSquare cache;

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

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

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

                    cache.lightPen = new Pen(c1);
                    cache.mediumBrush = new SolidBrush(c2);
                    cache.darkPen = new Pen(c3);
                }

                // Fill entire area in background brush
                context.Graphics.FillRectangle(cache.mediumBrush, rect);

                // Draw the outside border
                context.Graphics.DrawRectangle(cache.darkPen, rect.X, rect.Y, rect.Width - 1, rect.Height - 1);

                // Draw ligher top and bottom lines
                context.Graphics.DrawLine(cache.lightPen, rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Y + 1);
                context.Graphics.DrawLine(cache.lightPen, rect.X + 1, rect.Bottom - 2, rect.Width - 2, rect.Bottom - 2);
            }

            return memento;
        }
Beispiel #7
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonAppMenuInner(RenderContext context,
                                                             Rectangle rect,
                                                             PaletteState state,
                                                             IPaletteRibbonBack palette,
                                                             IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);

                bool generate = true;
                MementoRibbonAppButtonInner cache;

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

                    cache = new MementoRibbonAppButtonInner(rect, c1, c2);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonAppButtonInner)memento;
                    generate = !cache.UseCachedValues(rect, c1, c2);
                }

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

                    cache.outsideBrush = new SolidBrush(c1);
                    cache.insideBrush = new SolidBrush(c2);
                }

                // Draw the outside in one color and the inside with another
                context.Graphics.FillRectangle(cache.outsideBrush, rect);
                rect.Inflate(-1, -1);
                context.Graphics.FillRectangle(cache.insideBrush, rect);
            }

            return memento;
        }
Beispiel #8
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonTabTracking2010(PaletteRibbonShape shape,
                                                                RenderContext context,
                                                                Rectangle rect,
                                                                PaletteState state,
                                                                IPaletteRibbonBack palette,
                                                                VisualOrientation orientation,
                                                                IDisposable memento,
                                                                bool standard)
        {
            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;
                MementoRibbonTabTracking2010 cache;

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

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

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

                    // If c5 has a colour then use that to highlight the tab
                    if (c5 != Color.Empty)
                    {
                        if (!standard)
                            c5 = CommonHelper.MergeColors(c5, 0.65f, Color.Black, 0.35f);

                        c1 = c5;
                        c2 = CommonHelper.MergeColors(c2, 0.8f, ControlPaint.Light(c5), 0.2f);
                        c3 = CommonHelper.MergeColors(c3, 0.7f, c5, 0.3f);
                    }

                    switch (orientation)
                    {
                        case VisualOrientation.Top:
                            DrawRibbonTabTrackingTop2010(rect, c3, c4, cache);
                            break;
                        case VisualOrientation.Left:
                            DrawRibbonTabTrackingLeft2010(rect, c3, c4, cache);
                            break;
                        case VisualOrientation.Right:
                            DrawRibbonTabTrackingRight2010(rect, c3, c4, cache);
                            break;
                        case VisualOrientation.Bottom:
                            DrawRibbonTabTrackingBottom2010(rect, c3, c4, cache);
                            break;
                    }

                    cache.outsidePen = new Pen(c1);
                    cache.outsideBrush = new SolidBrush(c2);
                }

                // Fill the full background
                context.Graphics.FillPath(cache.outsideBrush, cache.outsidePath);

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

                // Fill the inside area
                context.Graphics.FillPath(cache.insideBrush, cache.insidePath);
            }

            return memento;
        }
Beispiel #9
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonTabSelected2010(RenderContext context,
                                                                Rectangle rect,
                                                                PaletteState state,
                                                                IPaletteRibbonBack palette,
                                                                VisualOrientation orientation,
                                                                IDisposable memento,
                                                                bool standard)
        {
            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;
                MementoRibbonTabSelected2010 cache;

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

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

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

                    // If we have a context color to use then modify the drawing colors
                    if (c5 != Color.Empty)
                    {
                        if (!standard)
                            c5 = CommonHelper.MergeColors(c5, 0.65f, Color.Black, 0.35f);

                        c1 = Color.FromArgb(196, c5);
                    }

                    switch (orientation)
                    {
                        case VisualOrientation.Top:
                            DrawRibbonTabSelectedTop2010(rect, c2, c3, c5, cache);
                            break;
                        case VisualOrientation.Left:
                            DrawRibbonTabSelectedLeft2010(rect, c2, c3, c5, cache);
                            break;
                        case VisualOrientation.Right:
                            DrawRibbonTabSelectedRight2010(rect, c2, c3, c5, cache);
                            break;
                        case VisualOrientation.Bottom:
                            DrawRibbonTabSelectedBottom2010(rect, c2, c3, c5, cache);
                            break;
                    }

                    cache.outsidePen = new Pen(c1);
                    cache.centerPen = new Pen(c4);
                }

                context.Graphics.FillPath(cache.centerBrush, cache.outsidePath);

                if (c5 != Color.Empty)
                    context.Graphics.FillPath(cache.insideBrush, cache.insidePath);

                using (AntiAlias aa = new AntiAlias(context.Graphics))
                    context.Graphics.DrawPath(cache.outsidePen, cache.outsidePath);

                switch (orientation)
                {
                    case VisualOrientation.Top:
                        DrawRibbonTabSelectedTopDraw2010(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Left:
                        DrawRibbonTabSelectedLeftDraw2010(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Right:
                        DrawRibbonTabSelectedRightDraw2010(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Bottom:
                        DrawRibbonTabSelectedBottomDraw2010(rect, cache, context.Graphics);
                        break;
                }
            }

            return memento;
        }
Beispiel #10
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonTabHighlight(PaletteRibbonShape shape,
                                                             RenderContext context, 
                                                             Rectangle rect,
                                                             PaletteState state,
                                                             IPaletteRibbonBack palette,
                                                             VisualOrientation orientation,
                                                             IDisposable memento,
                                                             bool alternate)
        {
            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;
                MementoRibbonTabHighlight cache;

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

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

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

                    switch (orientation)
                    {
                        case VisualOrientation.Top:
                            DrawRibbonTabHighlightTop(rect, c4, c5, cache);
                            break;
                        case VisualOrientation.Left:
                            DrawRibbonTabHighlightLeft(rect, c4, c5, cache);
                            break;
                        case VisualOrientation.Right:
                            DrawRibbonTabHighlightRight(rect, c4, c5, cache);
                            break;
                        case VisualOrientation.Bottom:
                            DrawRibbonTabHighlightBottom(rect, c4, c5, cache);
                            break;
                    }

                    cache.innerVertPen = new Pen(c1);
                    cache.innerHorzPen = new Pen(c2);
                    cache.borderHorzPen = new Pen(c3);
                }

                // First of all draw as selected
                cache.selectedMemento = (MementoRibbonTabSelected2007)DrawRibbonTabSelected2007(context, rect, PaletteState.CheckedNormal, palette, orientation, cache.selectedMemento);

                switch (orientation)
                {
                    case VisualOrientation.Top:
                        DrawRibbonTabHighlightTopDraw(rect, c1, c2, c3, c4, c5, cache, context.Graphics, alternate);
                        break;
                    case VisualOrientation.Left:
                        DrawRibbonTabHighlightLeftDraw(rect, c1, c2, c3, c4, c5, cache, context.Graphics, alternate);
                        break;
                    case VisualOrientation.Right:
                        DrawRibbonTabHighlightRightDraw(rect, c1, c2, c3, c4, c5, cache, context.Graphics, alternate);
                        break;
                    case VisualOrientation.Bottom:
                        DrawRibbonTabHighlightBottomDraw(rect, c1, c2, c3, c4, c5, cache, context.Graphics, alternate);
                        break;
                }
            }

            return memento;
        }
Beispiel #11
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonTabContextSelected(PaletteRibbonShape shape,
                                                                   RenderContext context,
                                                                   Rectangle rect,
                                                                   PaletteState state,
                                                                   IPaletteRibbonBack palette,
                                                                   VisualOrientation orientation,
                                                                   IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);

                bool generate = true;
                MementoRibbonTabContextSelected cache;

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

                    cache = new MementoRibbonTabContextSelected(rect, c1, c2, orientation);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonTabContextSelected)memento;
                    generate = !cache.UseCachedValues(rect, c1, c2, orientation);
                }

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

                    switch (orientation)
                    {
                        case VisualOrientation.Top:
                            DrawRibbonTabContextSelectedTop(rect, c2, cache);
                            break;
                        case VisualOrientation.Left:
                            DrawRibbonTabContextSelectedLeft(rect, c2, cache);
                            break;
                        case VisualOrientation.Right:
                            DrawRibbonTabContextSelectedRight(rect, c2, cache);
                            break;
                        case VisualOrientation.Bottom:
                            DrawRibbonTabContextSelectedBottom(rect, c2, cache);
                            break;
                    }

                    cache.outsidePen = new Pen(c1);
                    cache.l1 = new Pen(Color.FromArgb(100, c2));
                    cache.l2 = new Pen(Color.FromArgb(75, c2));
                    cache.l3 = new Pen(Color.FromArgb(48, c2));
                    cache.bottomInnerPen = new Pen(Color.FromArgb(70, c2));
                    cache.bottomOuterPen = new Pen(Color.FromArgb(100, c2));
                }

                // Fill the interior using a gradient brush
                context.Graphics.FillRectangle(Brushes.White, cache.interiorRect);
                context.Graphics.FillRectangle(cache.insideBrush, cache.interiorRect);

                // Draw the actual border
                using (AntiAlias aa = new AntiAlias(context.Graphics))
                    context.Graphics.DrawPath(cache.outsidePen, cache.outsidePath);

                switch (orientation)
                {
                    case VisualOrientation.Top:
                        DrawRibbonTabContextSelectedTopDraw(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Left:
                        DrawRibbonTabContextSelectedLeftDraw(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Right:
                        DrawRibbonTabContextSelectedRightDraw(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Bottom:
                        DrawRibbonTabContextSelectedBottomDraw(rect, cache, context.Graphics);
                        break;
                }
            }

            return memento;
        }
Beispiel #12
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonGroupGradientTwo(RenderContext context,
                                                                 Rectangle rect,
                                                                 PaletteState state,
                                                                 IPaletteRibbonBack palette,
                                                                 float percent,
                                                                 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);

                bool generate = true;
                MementoRibbonGroupGradientTwo cache;

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

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

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

                    int topHeight = (int)(rect.Height * percent);
                    Rectangle topRect = new Rectangle(rect.Left, rect.Top, rect.Width, topHeight);
                    Rectangle bottomRect = new Rectangle(rect.Left, topRect.Bottom, rect.Width, rect.Height - topHeight);
                    RectangleF topRectF = new RectangleF(topRect.Left - 1, topRect.Top - 1, topRect.Width + 2, topRect.Height + 2);
                    RectangleF bottomRectF = new RectangleF(bottomRect.Left - 1, bottomRect.Top - 1, bottomRect.Width + 2, bottomRect.Height + 2);

                    cache.topBrush = new LinearGradientBrush(topRectF, c1, c2, 90f);
                    cache.bottomBrush = new LinearGradientBrush(bottomRectF, c3, c4, 90f);
                    cache.topRect = topRect;
                    cache.bottomRect = bottomRect;
                }

                // Perform actual drawing using the cache values
                context.Graphics.FillRectangle(cache.topBrush, cache.topRect);
                context.Graphics.FillRectangle(cache.bottomBrush, cache.bottomRect);
            }

            return memento;
        }
Beispiel #13
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonGroupCollapsedFrameBorder(RenderContext context,
                                                                          Rectangle rect,
                                                                          PaletteState state,
                                                                          IPaletteRibbonBack palette,
                                                                          IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);

                bool generate = true;
                MementoRibbonGroupCollapsedFrameBorder cache;

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

                    cache = new MementoRibbonGroupCollapsedFrameBorder(rect, c1, c2);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonGroupCollapsedFrameBorder)memento;
                    generate = !cache.UseCachedValues(rect, c1, c2);
                }

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

                    GraphicsPath solidPath = new GraphicsPath();

                    // Create the rounded complete border
                    solidPath.AddLine(rect.Left + 2, rect.Top, rect.Right - 3, rect.Top);
                    solidPath.AddLine(rect.Right - 3, rect.Top, rect.Right - 1, rect.Top + 2);
                    solidPath.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom - 3);
                    solidPath.AddLine(rect.Right - 1, rect.Bottom - 3, rect.Right - 3, rect.Bottom - 1);
                    solidPath.AddLine(rect.Right - 3, rect.Bottom - 1, rect.Left + 2, rect.Bottom - 1);
                    solidPath.AddLine(rect.Left + 2, rect.Bottom - 1, rect.Left, rect.Bottom - 3);
                    solidPath.AddLine(rect.Left, rect.Bottom - 3, rect.Left, rect.Top + 2);
                    solidPath.AddLine(rect.Left, rect.Top + 2, rect.Left + 2, rect.Top);

                    cache.solidPath = solidPath;
                    cache.titleBrush = new SolidBrush(c2);
                    cache.solidPen = new Pen(c1);
                }

                // Perform actual drawing using the cache values
                Rectangle titleRect = new Rectangle(rect.Left + 1, rect.Bottom - _groupFrameTitleHeight, rect.Width - 2, _groupFrameTitleHeight - 1);
                context.Graphics.FillRectangle(cache.titleBrush, titleRect);

                using (AntiAlias aa = new AntiAlias(context.Graphics))
                    context.Graphics.DrawPath(cache.solidPen, cache.solidPath);
            }

            return memento;
        }
Beispiel #14
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonGroupCollapsedBorder(RenderContext context,
                                                                     Rectangle rect,
                                                                     PaletteState state,
                                                                     IPaletteRibbonBack palette,
                                                                     IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                // Grab the colors needed for drawing
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);
                Color c3 = palette.GetRibbonBackColor3(state);
                Color c4 = palette.GetRibbonBackColor4(state);

                bool generate = true;
                MementoRibbonGroupCollapsedBorder cache;

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

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

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

                    GraphicsPath solidPath = new GraphicsPath();
                    GraphicsPath insidePath = new GraphicsPath();

                    // Create the rounded complete border
                    solidPath.AddLine(rect.Left + 1.25f, rect.Top, rect.Right - 2, rect.Top);
                    solidPath.AddLine(rect.Right - 2, rect.Top, rect.Right - 1, rect.Top + 2);
                    solidPath.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom - 3);
                    solidPath.AddLine(rect.Right - 1, rect.Bottom - 3, rect.Right - 3, rect.Bottom - 1);
                    solidPath.AddLine(rect.Right - 3, rect.Bottom - 1, rect.Left + 2, rect.Bottom - 1);
                    solidPath.AddLine(rect.Left + 2, rect.Bottom - 1, rect.Left, rect.Bottom - 3);
                    solidPath.AddLine(rect.Left, rect.Bottom - 3, rect.Left, rect.Top + 1.25f);
                    solidPath.AddLine(rect.Left, rect.Top + 1.25f, rect.Left + 1.25f, rect.Top);

                    // Create the inside border
                    insidePath.AddLine(rect.Left + 2, rect.Top + 1, rect.Right - 3, rect.Top + 1);
                    insidePath.AddLine(rect.Right - 3, rect.Top + 1, rect.Right - 2, rect.Top + 2);
                    insidePath.AddLine(rect.Right - 2, rect.Top + 2, rect.Right - 2, rect.Bottom - 3);
                    insidePath.AddLine(rect.Right - 2, rect.Bottom - 3, rect.Right - 3, rect.Bottom - 2);
                    insidePath.AddLine(rect.Right - 3, rect.Bottom - 2, rect.Left + 2, rect.Bottom - 2);
                    insidePath.AddLine(rect.Left + 2, rect.Bottom - 2, rect.Left + 1, rect.Bottom - 3);
                    insidePath.AddLine(rect.Left + 1, rect.Bottom - 3, rect.Left + 1, rect.Top + 2);
                    insidePath.AddLine(rect.Left + 1, rect.Top + 2, rect.Left + 2, rect.Top + 1);

                    RectangleF solidRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2);
                    RectangleF insideRectF = new RectangleF(rect.Left, rect.Top, rect.Width, rect.Height);

                    LinearGradientBrush solidBrush = new LinearGradientBrush(solidRectF, c1, c2, 90f);
                    LinearGradientBrush insideBrush = new LinearGradientBrush(insideRectF, c3, c4, 90f);

                    cache.solidPath = solidPath;
                    cache.insidePath = insidePath;
                    cache.solidPen = new Pen(solidBrush);
                    cache.insidePen = new Pen(insideBrush);
                }

                // Perform actual drawing using the cache values
                using (AntiAlias aa = new AntiAlias(context.Graphics))
                {
                    context.Graphics.DrawPath(cache.solidPen, cache.solidPath);
                    context.Graphics.DrawPath(cache.insidePen, cache.insidePath);
                }
            }

            return memento;
        }
Beispiel #15
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonGroupAreaBorderContext(RenderContext context,
                                                                       Rectangle rect,
                                                                       PaletteState state,
                                                                       IPaletteRibbonBack palette,
                                                                       IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);
                Color c3 = palette.GetRibbonBackColor3(state);

                bool generate = true;
                MementoRibbonGroupAreaBorderContext cache;

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

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

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

                    GraphicsPath outsidePath = new GraphicsPath();
                    GraphicsPath insidePath = new GraphicsPath();
                    GraphicsPath shadowPath = new GraphicsPath();

                    // Create path for the entire border
                    outsidePath.AddLine(rect.Left + 2, rect.Top, rect.Right - 3, rect.Top);
                    outsidePath.AddLine(rect.Right - 3, rect.Top, rect.Right - 1, rect.Top + 2);
                    outsidePath.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom - 3);
                    outsidePath.AddLine(rect.Right - 1, rect.Bottom - 3, rect.Right - 3, rect.Bottom - 1);
                    outsidePath.AddLine(rect.Right - 3, rect.Bottom - 1, rect.Left + 2, rect.Bottom - 1);
                    outsidePath.AddLine(rect.Left + 2, rect.Bottom - 1, rect.Left, rect.Bottom - 3);
                    outsidePath.AddLine(rect.Left, rect.Bottom - 3, rect.Left, rect.Top + 2);
                    outsidePath.AddLine(rect.Left, rect.Top + 2, rect.Left + 2, rect.Top);

                    // Create the path for the inside highlight
                    insidePath.AddLine(rect.Left + 1, rect.Top + 3, rect.Left + 1, rect.Bottom - 3);
                    insidePath.AddLine(rect.Left + 1, rect.Bottom - 3, rect.Left + 2, rect.Bottom - 2);
                    insidePath.AddLine(rect.Left + 2, rect.Bottom - 2, rect.Right - 3, rect.Bottom - 2);
                    insidePath.AddLine(rect.Right - 3, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 3);
                    insidePath.AddLine(rect.Right - 2, rect.Bottom - 3, rect.Right - 2, rect.Top + 3);

                    // Create the path for the outside shadow
                    shadowPath.AddLine(rect.Left, rect.Bottom - 2, rect.Left + 2, rect.Bottom);
                    shadowPath.AddLine(rect.Left + 2, rect.Bottom, rect.Right - 3, rect.Bottom);
                    shadowPath.AddLine(rect.Right - 4, rect.Bottom, rect.Right, rect.Bottom - 3);
                    shadowPath.AddLine(rect.Right, rect.Bottom - 3, rect.Right, rect.Top + 3);

                    LinearGradientBrush insideBrush = new LinearGradientBrush(rect, Color.Transparent, c2, 95f);
                    cache.insidePen = new Pen(insideBrush);

                    Rectangle rectGradient = new Rectangle(rect.Left - 1, rect.Top, rect.Width + 2, rect.Height + 1);
                    LinearGradientBrush shadowBrush = new LinearGradientBrush(rectGradient, _darken8, _darken38, 90f);
                    cache.shadowPen = new Pen(shadowBrush);

                    cache.fillBrush = new LinearGradientBrush(rect, Color.White, _242, 90f);
                    cache.fillBrush.Blend = _ribbonGroup3Blend;
                    cache.fillTopBrush = new LinearGradientBrush(rect, Color.FromArgb(75, c3), Color.Transparent, 90f);
                    cache.fillTopBrush.Blend = _ribbonGroup4Blend;
                    cache.outsidePath = outsidePath;
                    cache.insidePath = insidePath;
                    cache.shadowPath = shadowPath;
                    cache.outsidePen = new Pen(c1);
                }

                // Fill the inside area with a linear gradient
                context.Graphics.FillPath(cache.fillBrush, cache.outsidePath);

                // Clip drawing to the outside border
                using (Clipping clip = new Clipping(context.Graphics, cache.outsidePath))
                    context.Graphics.FillPath(cache.fillTopBrush, cache.outsidePath);

                using (AntiAlias aa = new AntiAlias(context.Graphics))
                {
                    // Draw the outside of the entire border line
                    context.Graphics.DrawPath(cache.outsidePen, cache.outsidePath);

                    // Draw the highlighting inside border
                    context.Graphics.DrawPath(cache.insidePen, cache.insidePath);
                }

                // Draw the shadow outside the bottom and right edges
                context.Graphics.DrawPath(cache.shadowPen, cache.shadowPath);
                context.Graphics.DrawLine(_medium2ShadowPen, rect.Left, rect.Bottom, rect.Left, rect.Bottom - 1);
                context.Graphics.DrawLine(_medium2ShadowPen, rect.Left, rect.Bottom - 1, rect.Left + 1, rect.Bottom);
                context.Graphics.DrawLine(_darkShadowPen, rect.Right, rect.Bottom - 2, rect.Right - 2, rect.Bottom);
                context.Graphics.DrawLine(_medium2ShadowPen, rect.Right, rect.Bottom - 1, rect.Right - 1, rect.Bottom);
            }

            return memento;
        }
Beispiel #16
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        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;
        }
Beispiel #17
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonAppMenuOuter(RenderContext context,
                                                             Rectangle rect,
                                                             PaletteState state,
                                                             IPaletteRibbonBack palette,
                                                             IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);
                Color c3 = palette.GetRibbonBackColor3(state);

                bool generate = true;
                MementoRibbonAppButtonOuter cache;

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

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

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

                    cache.wholeBrush = new SolidBrush(c1);
                    cache.backPath = new GraphicsPath();
                    cache.backPath.AddLine(rect.X + 1, rect.Y, rect.Right - 1, rect.Y);
                    cache.backPath.AddLine(rect.Right - 1, rect.Y, rect.Right, rect.Y + 1);
                    cache.backPath.AddLine(rect.Right, rect.Y + 1, rect.Right, rect.Bottom - 2);
                    cache.backPath.AddLine(rect.Right, rect.Bottom - 2, rect.Right - 2, rect.Bottom);
                    cache.backPath.AddLine(rect.Right - 2, rect.Bottom, rect.X + 1, rect.Bottom);
                    cache.backPath.AddLine(rect.X + 2, rect.Bottom, rect.X, rect.Bottom - 2);
                    cache.backPath.AddLine(rect.X, rect.Bottom - 2, rect.X, rect.Y + 1);
                    cache.backPath.AddLine(rect.X, rect.Y + 1, rect.X + 1, rect.Y);
                    cache.bottomDarkGradient = new LinearGradientBrush(new Point(rect.X, rect.Bottom - 15), new Point(rect.X, rect.Bottom), c2, c3);
                    cache.topLightenGradient = new LinearGradientBrush(new Point(rect.X, rect.Y - 1), new Point(rect.X, rect.Y + 7), _whiten64, _whiten32);
                }

                // Draw entire background in solid brush
                context.Graphics.FillPath(cache.wholeBrush, cache.backPath);
                context.Graphics.FillRectangle(cache.bottomDarkGradient, new Rectangle(rect.X, rect.Bottom - 14, rect.Width, 13));
                context.Graphics.FillRectangle(cache.topLightenGradient, new Rectangle(rect.X, rect.Y, rect.Width, 6));
            }

            return memento;
        }
Beispiel #18
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonQATMinibarSingle(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, bottom, left + 10.75f, bottom);
                    borderPath.AddLine(left + 10.75f, bottom, left + 10, bottom - 8f);
                    borderPath.AddLine(left + 10, bottom - 8f, left + 9, bottom - 11f);
                    borderPath.AddLine(left + 9, bottom - 11f, left + 8, bottom - 13f);
                    borderPath.AddLine(left + 8, bottom - 13f, left + 7, bottom - 15f);
                    borderPath.AddLine(left + 7, bottom - 15f, left + 1, top + 0.25f);
                    borderPath.AddLine(left + 1, top + 0.25f, left - 1, top + 0.25f);
                    borderPath.AddLine(left - 1, top + 0.25f, right - 8, top + 0.25f);
                    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);

                    // Create the top right light paths
                    topRight1.AddLine(rect.Left - 1, 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 + 10.75f, rect.Bottom - 11, rect.Left + 10.75f, rect.Bottom - 5);
                    bottomLeft1.AddLine(rect.Left + 10.75f, rect.Bottom - 5, rect.Left + 13, rect.Bottom - 2);
                    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);

                        // Overdraw top for lighter effect
                        context.Graphics.DrawLine(cache.whitenPen, rect.Left + 10, rect.Top + 2, rect.Right - 10, rect.Top + 2);
                        context.Graphics.DrawLine(cache.whitenPen, rect.Left + 12, rect.Top + 3, rect.Right - 8, rect.Top + 3);
                        context.Graphics.DrawLine(cache.whitenPen, rect.Left + 14, rect.Top + 4, rect.Right - 7, rect.Top + 4);
                    }
                    else
                    {
                        // Fill with a semi-transparent background/border
                        context.Graphics.FillPath(_compositionBrush, cache.borderPath);
                        context.Graphics.DrawPath(_compositionPen, cache.borderPath);
                    }
                }
            }

            return memento;
        }
Beispiel #19
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonQATOverflow(PaletteRibbonShape shape,
                                                            RenderContext context,
                                                            Rectangle rect,
                                                            PaletteState state,
                                                            IPaletteRibbonBack palette,
                                                            IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);

                bool generate = true;
                MementoRibbonQATOverflow cache;

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

                    cache = new MementoRibbonQATOverflow(rect, c1, c2);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonQATOverflow)memento;
                    generate = !cache.UseCachedValues(rect, c1, c2);
                }

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

                    cache.backBrush = new SolidBrush(c1);
                    cache.borderPen = new Pen(c2);
                }

                // Draw a gradient for the inside of the area
                context.Graphics.FillRectangle(cache.backBrush, rect);

                using (AntiAlias aa = new AntiAlias(context.Graphics))
                {
                    if (shape == PaletteRibbonShape.Office2010)
                    {
                        context.Graphics.DrawPolygon(cache.borderPen, new Point[]{ new Point(rect.Left + 1, rect.Top),
                                                                                   new Point(rect.Right - 2, rect.Top),
                                                                                   new Point(rect.Right - 1, rect.Top + 1),
                                                                                   new Point(rect.Right - 1, rect.Bottom - 2),
                                                                                   new Point(rect.Right - 2, rect.Bottom - 1),
                                                                                   new Point(rect.Left + 1, rect.Bottom - 1),
                                                                                   new Point(rect.Left, rect.Bottom - 2),
                                                                                   new Point(rect.Left, rect.Top + 1) } );
                    }
                    else
                    {
                        context.Graphics.DrawLine(cache.borderPen, rect.Left + 1f, rect.Top, rect.Right - 2f, rect.Top);
                        context.Graphics.DrawLine(cache.borderPen, rect.Right - 2f, rect.Top, rect.Right - 1f, rect.Top + 2f);
                        context.Graphics.DrawLine(cache.borderPen, rect.Right - 1f, rect.Top + 2f, rect.Right - 1f, rect.Bottom - 2f);
                        context.Graphics.DrawLine(cache.borderPen, rect.Right - 1f, rect.Bottom - 2f, rect.Right - 2f, rect.Bottom - 1f);
                        context.Graphics.DrawLine(cache.borderPen, rect.Right - 2f, rect.Bottom - 1f, rect.Left + 1f, rect.Bottom - 1f);
                        context.Graphics.DrawLine(cache.borderPen, rect.Left + 1f, rect.Bottom - 1f, rect.Left, rect.Bottom - 2f);
                        context.Graphics.DrawLine(cache.borderPen, rect.Left, rect.Bottom - 2f, rect.Left, rect.Top + 1f);
                        context.Graphics.DrawLine(cache.borderPen, rect.Left, rect.Top + 1f, rect.Left + 1f, rect.Top);
                    }
                }
            }

            return memento;
        }
Beispiel #20
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonGroupNormalBorder(RenderContext context,
                                                                  Rectangle rect,
                                                                  PaletteState state,
                                                                  IPaletteRibbonBack palette,
                                                                  bool tracking,
                                                                  bool lightInside,
                                                                  IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);

                bool generate = true;
                MementoRibbonGroupNormalBorder cache;

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

                    cache = new MementoRibbonGroupNormalBorder(rect, c1, c2);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonGroupNormalBorder)memento;
                    generate = !cache.UseCachedValues(rect, c1, c2);
                }

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

                    GraphicsPath solidPath = new GraphicsPath();
                    GraphicsPath insidePath = new GraphicsPath();
                    GraphicsPath outsidePath = new GraphicsPath();
                    GraphicsPath lightPath = new GraphicsPath();

                    // Create the rounded complete border
                    solidPath.AddLine(rect.Left + 2, rect.Top, rect.Right - 4, rect.Top);
                    solidPath.AddLine(rect.Right - 4, rect.Top, rect.Right - 2, rect.Top + 2);
                    solidPath.AddLine(rect.Right - 2, rect.Top + 2, rect.Right - 2, rect.Bottom - 4);
                    solidPath.AddLine(rect.Right - 2, rect.Bottom - 4, rect.Right - 4, rect.Bottom - 2);
                    solidPath.AddLine(rect.Right - 4, rect.Bottom - 2, rect.Left + 2, rect.Bottom - 2);
                    solidPath.AddLine(rect.Left + 2, rect.Bottom - 2, rect.Left, rect.Bottom - 4);
                    solidPath.AddLine(rect.Left, rect.Bottom - 4, rect.Left, rect.Top + 2);
                    solidPath.AddLine(rect.Left, rect.Top + 2, rect.Left + 2, rect.Top);

                    // Create the inside top and left path
                    insidePath.AddLine(rect.Right - 4, rect.Top + 1, rect.Left + 2, rect.Top + 1);
                    insidePath.AddLine(rect.Left + 2, rect.Top + 1, rect.Left + 1, rect.Top + 2);
                    insidePath.AddLine(rect.Left + 1, rect.Top + 2, rect.Left + 1, rect.Bottom - 4);

                    // Create the outside right and bottom path
                    outsidePath.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom - 3);
                    outsidePath.AddLine(rect.Right - 1, rect.Bottom - 3, rect.Right - 3, rect.Bottom - 1);
                    outsidePath.AddLine(rect.Right - 3, rect.Bottom - 1, rect.Left + 3, rect.Bottom - 1);

                    // Optional path for lightening area
                    lightPath.AddLine(rect.Left + 2, rect.Top + 1, rect.Right - 4, rect.Top + 1);
                    lightPath.AddLine(rect.Right - 4, rect.Top + 1, rect.Right - 3, rect.Top + 2);
                    lightPath.AddLine(rect.Right - 3, rect.Top + 2, rect.Right - 3, rect.Bottom - 4);
                    lightPath.AddLine(rect.Right - 3, rect.Bottom - 4, rect.Right - 4, rect.Bottom - 3);
                    lightPath.AddLine(rect.Right - 4, rect.Bottom - 3, rect.Left + 2, rect.Bottom - 3);
                    lightPath.AddLine(rect.Left + 2, rect.Bottom - 3, rect.Left + 1, rect.Bottom - 4);
                    lightPath.AddLine(rect.Left + 1, rect.Bottom - 4, rect.Left + 1, rect.Top + 2);
                    lightPath.AddLine(rect.Left + 1, rect.Top + 2, rect.Left + 2, rect.Top + 1);

                    RectangleF solidRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2);
                    LinearGradientBrush solidBrush = new LinearGradientBrush(solidRectF, c1, c2, 90f);
                    cache.solidPen = new Pen(solidBrush);

                    cache.backRect = new Rectangle(rect.Left + 2, rect.Top + 1, rect.Width - 4, rect.Height - 4);
                    cache.solidPath = solidPath;
                    cache.insidePath = insidePath;
                    cache.outsidePath = outsidePath;
                    cache.lightPath = lightPath;
                }

                // If tracking, lighten the background
                if (tracking)
                    context.Graphics.FillRectangle(lightInside ? _whitenLightLBrush : _whitenLightBrush, cache.backRect);

                using (AntiAlias aa = new AntiAlias(context.Graphics))
                {
                    // Draw the solid border
                    context.Graphics.DrawPath(cache.solidPen, cache.solidPath);

                    // Do now draw the inside and outside paths if ligtening the inside anyway
                    if (!lightInside)
                    {
                        // Draw the two areas that make a lighter shadow to the right and bottom of border
                        context.Graphics.DrawPath(_whitenMediumPen, cache.insidePath);
                        context.Graphics.DrawPath(_whitenMediumPen, cache.outsidePath);
                    }
                }

                if (lightInside)
                    context.Graphics.DrawPath(Pens.White, cache.lightPath);
            }

            return memento;
        }
Beispiel #21
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonTabGlowing(PaletteRibbonShape shape,
                                                           RenderContext context,
                                                           Rectangle rect,
                                                           PaletteState state,
                                                           IPaletteRibbonBack palette,
                                                           VisualOrientation orientation,
                                                           IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);
                Color insideColor = Color.FromArgb(36, c2);

                bool generate = true;
                MementoRibbonTabGlowing cache;

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

                    cache = new MementoRibbonTabGlowing(rect, c1, c2, insideColor, orientation);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonTabGlowing)memento;
                    generate = !cache.UseCachedValues(rect, c1, c2, insideColor, orientation);
                }

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

                    switch (orientation)
                    {
                        case VisualOrientation.Top:
                            DrawRibbonTabGlowingTop(rect, c1, c2, insideColor, cache);
                            break;
                        case VisualOrientation.Left:
                            DrawRibbonTabGlowingLeft(rect, c1, c2, insideColor, cache);
                            break;
                        case VisualOrientation.Right:
                            DrawRibbonTabGlowingRight(rect, c1, c2, insideColor, cache);
                            break;
                        case VisualOrientation.Bottom:
                            DrawRibbonTabGlowingBottom(rect, c1, c2, insideColor, cache);
                            break;
                    }
                }

                // Fill the path area with inside color
                context.Graphics.FillPath(cache.insideBrush, cache.outsidePath);

                switch (orientation)
                {
                    case VisualOrientation.Top:
                        // Draw the missing line from the bottom of the inside area
                        context.Graphics.DrawLine(cache.insidePen, rect.Left + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2);
                        break;
                    case VisualOrientation.Left:
                        // Draw the missing line from the right of the inside area
                        context.Graphics.DrawLine(cache.insidePen, rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Bottom - 2);
                        break;
                }

                // Draw the border over the edge of the inside color
                using (AntiAlias aa = new AntiAlias(context.Graphics))
                    context.Graphics.DrawPath(cache.outsidePen, cache.outsidePath);

                // Draw the top glass effect
                context.Graphics.FillPath(cache.topBrush, cache.topPath);

                // Cannot draw a path that contains a zero sized element
                if ((cache.ellipseRect.Width > 0) && (cache.ellipseRect.Height > 0))
                    context.Graphics.FillRectangle(cache.ellipseBrush, cache.fullRect);
            }

            return memento;
        }
Beispiel #22
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        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;
        }
Beispiel #23
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonTabSelected2007(RenderContext context, 
                                                                Rectangle rect,
                                                                PaletteState state,
                                                                IPaletteRibbonBack palette,
                                                                VisualOrientation orientation,
                                                                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;
                MementoRibbonTabSelected2007 cache;

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

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

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

                    switch (orientation)
                    {
                        case VisualOrientation.Top:
                            DrawRibbonTabSelectedTop2007(rect, c4, c5, cache);
                            break;
                        case VisualOrientation.Left:
                            DrawRibbonTabSelectedLeft2007(rect, c4, c5, cache);
                            break;
                        case VisualOrientation.Right:
                            DrawRibbonTabSelectedRight2007(rect, c4, c5, cache);
                            break;
                        case VisualOrientation.Bottom:
                            DrawRibbonTabSelectedBottom2007(rect, c4, c5, cache);
                            break;
                    }

                    cache.insideBrush = new SolidBrush(c3);
                    cache.outsidePen = new Pen(c1);
                    cache.middlePen = new Pen(c2);
                    cache.insidePen = new Pen(c3);
                    cache.centerPen = new Pen(c5);
                }

                // Fill the inside of the border
                context.Graphics.FillPath(cache.insideBrush, cache.outsidePath);

                // Draw the actual border
                using (AntiAlias aa = new AntiAlias(context.Graphics))
                    context.Graphics.DrawPath(cache.outsidePen, cache.outsidePath);

                switch (orientation)
                {
                    case VisualOrientation.Top:
                        DrawRibbonTabSelectedTopDraw2007(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Left:
                        DrawRibbonTabSelectedLeftDraw2007(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Right:
                        DrawRibbonTabSelectedRightDraw2007(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Bottom:
                        DrawRibbonTabSelectedBottomDraw2007(rect, cache, context.Graphics);
                        break;
                }

                // Fill in the center as a vertical gradient from tto bottom
                context.Graphics.FillRectangle(cache.centerBrush, cache.centerRect);
            }

            return memento;
        }
Beispiel #24
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonGroupNormalTitle(RenderContext context,
                                                                 Rectangle rect,
                                                                 PaletteState state,
                                                                 IPaletteRibbonBack palette,
                                                                 IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);

                bool generate = true;
                MementoRibbonGroupNormalTitle cache;

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

                    cache = new MementoRibbonGroupNormalTitle(rect, c1, c2);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonGroupNormalTitle)memento;
                    generate = !cache.UseCachedValues(rect, c1, c2);
                }

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

                    GraphicsPath titlePath = new GraphicsPath();

                    // Create the rounded bottom edge to fit inside a group border
                    titlePath.AddLine(rect.Left, rect.Top, rect.Right - 1, rect.Top);
                    titlePath.AddLine(rect.Right - 1, rect.Top, rect.Right - 1, rect.Bottom - 3);
                    titlePath.AddLine(rect.Right - 1, rect.Bottom - 3, rect.Right - 3, rect.Bottom - 1);
                    titlePath.AddLine(rect.Right - 3, rect.Bottom - 1, rect.Left + 2, rect.Bottom - 1);
                    titlePath.AddLine(rect.Left + 2, rect.Bottom - 1, rect.Left, rect.Bottom - 3);
                    titlePath.AddLine(rect.Left, rect.Bottom - 3, rect.Left, rect.Top);

                    RectangleF rectF = new RectangleF(rect.Left - 0.5f, rect.Top - 0.5f, rect.Width + 1, rect.Height + 1);
                    cache.titleBrush = new LinearGradientBrush(rectF, c1, c2, 90f);
                    cache.titlePath = titlePath;
                }

                // Fill path area with a gradient brush
                context.Graphics.FillPath(cache.titleBrush, cache.titlePath);
            }

            return memento;
        }
Beispiel #25
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonTabTracking2007(PaletteRibbonShape shape,
                                                                RenderContext context, 
                                                                Rectangle rect,
                                                                PaletteState state,
                                                                IPaletteRibbonBack palette,
                                                                VisualOrientation orientation,
                                                                IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);

                bool generate = true;
                MementoRibbonTabTracking2007 cache;

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

                    cache = new MementoRibbonTabTracking2007(rect, c1, c2, orientation);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonTabTracking2007)memento;
                    generate = !cache.UseCachedValues(rect, c1, c2, orientation);
                }

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

                    switch (orientation)
                    {
                        case VisualOrientation.Top:
                            DrawRibbonTabTrackingTop2007(rect, c1, c2, cache);
                            break;
                        case VisualOrientation.Left:
                            DrawRibbonTabTrackingLeft2007(rect, c1, c2, cache);
                            break;
                        case VisualOrientation.Right:
                            DrawRibbonTabTrackingRight2007(rect, c1, c2, cache);
                            break;
                        case VisualOrientation.Bottom:
                            DrawRibbonTabTrackingBottom2007(rect, c1, c2, cache);
                            break;
                    }
                }

                // Draw the left and right sides with light version of tracking color
                context.Graphics.FillRectangle(cache.half1LeftBrush, cache.half1Rect);
                context.Graphics.FillRectangle(cache.half1RightBrush, cache.half1Rect);

                // Draw over with glassy effect
                context.Graphics.FillRectangle(cache.half1LightBrush, cache.half1Rect);

                //// Use a solid fill for the bottom half
                context.Graphics.FillRectangle(cache.half2Brush, cache.half2Rect);

                // Cannot draw a path that contains a zero sized element
                if ((cache.ellipseRect.Width > 0) && (cache.ellipseRect.Height > 0))
                {
                    // Draw twice to get a deeper color effect, once is to pale
                    context.Graphics.FillRectangle(cache.ellipseBrush, cache.half2RectF);
                    context.Graphics.FillRectangle(cache.ellipseBrush, cache.half2RectF);
                }

                // Draw the actual border
                using (AntiAlias aa = new AntiAlias(context.Graphics))
                    context.Graphics.DrawPath(cache.outsidePen, cache.outsidePath);

                switch (orientation)
                {
                    case VisualOrientation.Top:
                        DrawRibbonTabTrackingTopDraw2007(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Left:
                        DrawRibbonTabTrackingLeftDraw2007(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Right:
                        DrawRibbonTabTrackingRightDraw2007(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Bottom:
                        DrawRibbonTabTrackingBottomDraw2007(rect, cache, context.Graphics);
                        break;
                }

                context.Graphics.DrawPath(cache.topPen, cache.topPath);
            }

            return memento;
        }
Beispiel #26
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected override IDisposable DrawRibbonTabSelected2010(RenderContext context,
                                                                 Rectangle rect,
                                                                 PaletteState state,
                                                                 IPaletteRibbonBack palette,
                                                                 VisualOrientation orientation,
                                                                 IDisposable memento,
                                                                 bool standard)
        {
            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;
                MementoRibbonTabSelected2010 cache;

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

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

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

                    // If we have a context color to use then modify the drawing colors
                    if (c5 != Color.Empty)
                    {
                        if (!standard)
                        {
                            c5 = CommonHelper.MergeColors(c5, 0.65f, Color.Black, 0.35f);
                        }

                        c1 = Color.FromArgb(196, c5);
                    }

                    switch (orientation)
                    {
                    case VisualOrientation.Top:
                        DrawRibbonTabSelectedTop2010(rect, c2, c3, c5, cache);
                        break;

                    case VisualOrientation.Left:
                        DrawRibbonTabSelectedLeft2010(rect, c2, c3, c5, cache);
                        break;

                    case VisualOrientation.Right:
                        DrawRibbonTabSelectedRight2010(rect, c2, c3, c5, cache);
                        break;

                    case VisualOrientation.Bottom:
                        DrawRibbonTabSelectedBottom2010(rect, c2, c3, c5, cache);
                        break;
                    }

                    cache.outsidePen = new Pen(c1);
                    cache.centerPen  = new Pen(c4);
                }

                context.Graphics.FillRectangle(cache.centerBrush, cache.rect);
                //context.Graphics.FillPath(cache.centerBrush, cache.outsidePath);

                //if (c5 != Color.Empty)
                //    context.Graphics.FillPath(cache.insideBrush, cache.insidePath);

                //using (AntiAlias aa = new AntiAlias(context.Graphics))
                //    context.Graphics.DrawPath(cache.outsidePen, cache.outsidePath);
                context.Graphics.DrawRectangle(cache.outsidePen, cache.rect);

                //switch (orientation)
                //{
                //    case VisualOrientation.Top:
                //        DrawRibbonTabSelectedTopDraw2010(rect, cache, context.Graphics);
                //        break;
                //    case VisualOrientation.Left:
                //        DrawRibbonTabSelectedLeftDraw2010(rect, cache, context.Graphics);
                //        break;
                //    case VisualOrientation.Right:
                //        DrawRibbonTabSelectedRightDraw2010(rect, cache, context.Graphics);
                //        break;
                //    case VisualOrientation.Bottom:
                //        DrawRibbonTabSelectedBottomDraw2010(rect, cache, context.Graphics);
                //        break;
                //}
            }

            return(memento);
        }
Beispiel #27
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonLinear(RenderContext context,
                                                       Rectangle rect,
                                                       PaletteState state,
                                                       IPaletteRibbonBack palette,
                                                       IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);

                bool generate = true;
                MementoRibbonLinear cache;

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

                    cache = new MementoRibbonLinear(rect, c1, c2);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonLinear)memento;
                    generate = !cache.UseCachedValues(rect, c1, c2);
                }

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

                    cache.linearBrush = new LinearGradientBrush(new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2), c1, c2, 90f);
                }

                context.Graphics.FillRectangle(cache.linearBrush, rect);
            }

            return memento;
        }
Beispiel #28
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonAppButton(PaletteRibbonShape shape,
                                                          RenderContext context,
                                                          Rectangle rect,
                                                          PaletteState state,
                                                          IPaletteRibbonBack palette,
                                                          bool trackBorderAsPressed,
                                                          IDisposable memento)
        {
            // Reduce the area of the actual button as the extra space is used for shadow
            rect.Width -= 3;
            rect.Height -= 3;

            if ((rect.Width > 0) && (rect.Height > 0))
            {
                // Get the colors from the palette
                Color topLight = palette.GetRibbonBackColor1(state);
                Color topMedium = palette.GetRibbonBackColor2(state);
                Color topDark = palette.GetRibbonBackColor3(state);
                Color bottomLight = palette.GetRibbonBackColor4(state);
                Color bottomMedium = palette.GetRibbonBackColor5(state);
                Color bottomDark = CommonHelper.MergeColors(topDark, 0.78f, Color.Empty, 0.22f);

                bool generate = true;
                MementoRibbonAppButton cache;

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

                    cache = new MementoRibbonAppButton(rect, topLight, topMedium,
                                                       topDark, bottomLight, bottomMedium);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonAppButton)memento;
                    generate = !cache.UseCachedValues(rect, topLight, topMedium,
                                                      topDark, bottomLight, bottomMedium);
                }

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

                    cache.borderShadow1 = new RectangleF(rect.X, rect.Y, rect.Width + 2, rect.Height + 2);
                    cache.borderShadow2 = new RectangleF(rect.X, rect.Y, rect.Width + 1, rect.Height + 1);
                    cache.borderMain1 = new RectangleF(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2);
                    cache.borderMain2 = new RectangleF(cache.borderMain1.X + 1, cache.borderMain1.Y + 1, cache.borderMain1.Width - 2, cache.borderMain1.Height - 2);
                    cache.borderMain3 = new RectangleF(cache.borderMain1.X + 1, cache.borderMain1.Y + 1, cache.borderMain1.Width - 2, cache.borderMain1.Height - 2);
                    cache.borderMain4 = new RectangleF(cache.borderMain2.X, cache.borderMain2.Y + 1, cache.borderMain2.Width, cache.borderMain2.Height - 2);
                    cache.rectBottomGlow = new RectangleF(0, 0, rect.Width * 0.75f, rect.Height * 0.75f);
                    cache.rectLower = new RectangleF(rect.X, rect.Y - 1, rect.Width, rect.Height + 1);
                    cache.rectUpperGlow = new RectangleF();
                    cache.rectUpperGlow.Width = rect.Width - 4;
                    cache.rectUpperGlow.Height = rect.Height / 8;
                    cache.rectUpperGlow.Y = rect.Y + (rect.Height - cache.rectUpperGlow.Height) / 2;
                    cache.rectUpperGlow.X = rect.X + (rect.Width - cache.rectUpperGlow.Width) / 2;

                    cache.brushUpper1 = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, LinearGradientMode.Horizontal);
                    cache.brushLower = new LinearGradientBrush(cache.rectLower, Color.Transparent, Color.Transparent, LinearGradientMode.Horizontal);
                }

                using (AntiAlias aa = new AntiAlias(context.Graphics))
                {
                    DrawRibbonAppButtonBorder1(context.Graphics, cache);
                    DrawRibbonAppButtonUpperHalf(context.Graphics, cache, state, topDark, bottomDark, topLight, topMedium, trackBorderAsPressed);
                    DrawRibbonAppButtonLowerHalf(context.Graphics, cache, state, bottomDark, bottomLight, bottomMedium);
                    DrawRibbonAppButtonGlowCenter(context.Graphics, cache, state, topLight, bottomLight);
                    DrawRibbonAppButtonGlowUpperBottom(context.Graphics, cache, state, bottomLight, bottomMedium, bottomDark);
                    DrawRibbonAppButtonBorder2(context.Graphics, cache, state, bottomLight, trackBorderAsPressed);
                }
            }

            return memento;
        }
Beispiel #29
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected override IDisposable DrawRibbonTabTracking2010(PaletteRibbonShape shape,
                                                                 RenderContext context,
                                                                 Rectangle rect,
                                                                 PaletteState state,
                                                                 IPaletteRibbonBack palette,
                                                                 VisualOrientation orientation,
                                                                 IDisposable memento,
                                                                 bool standard)
        {
            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;
                MementoRibbonTabTracking2010 cache;

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

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

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

                    // If c5 has a colour then use that to highlight the tab
                    if (c5 != Color.Empty)
                    {
                        if (!standard)
                        {
                            c5 = CommonHelper.MergeColors(c5, 0.65f, Color.Black, 0.35f);
                        }

                        c1 = c5;
                        c2 = CommonHelper.MergeColors(c2, 0.8f, ControlPaint.Light(c5), 0.2f);
                        c3 = CommonHelper.MergeColors(c3, 0.7f, c5, 0.3f);
                    }

                    switch (orientation)
                    {
                    case VisualOrientation.Top:
                        DrawRibbonTabTrackingTop2010(rect, c3, c4, cache);
                        break;

                    case VisualOrientation.Left:
                        DrawRibbonTabTrackingLeft2010(rect, c3, c4, cache);
                        break;

                    case VisualOrientation.Right:
                        DrawRibbonTabTrackingRight2010(rect, c3, c4, cache);
                        break;

                    case VisualOrientation.Bottom:
                        DrawRibbonTabTrackingBottom2010(rect, c3, c4, cache);
                        break;
                    }

                    cache.outsidePen   = new Pen(c1);
                    cache.outsideBrush = new SolidBrush(c2);
                }

                // Fill the full background
                //context.Graphics.FillPath(cache.outsideBrush, cache.outsidePath);
                context.Graphics.FillRectangle(cache.outsideBrush, cache.rect);

                // Draw the border
                //using (AntiAlias aa = new AntiAlias(context.Graphics))
                //    context.Graphics.DrawPath(cache.outsidePen, cache.borderPath);
                context.Graphics.DrawRectangle(cache.outsidePen, cache.rect);

                // Fill the inside area
                //context.Graphics.FillPath(cache.insideBrush, cache.insidePath);
            }

            return(memento);
        }
Beispiel #30
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonLinearBorder(RenderContext context,
                                                             Rectangle rect,
                                                             PaletteState state,
                                                             IPaletteRibbonBack palette,
                                                             IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);

                bool generate = true;
                MementoRibbonLinearBorder cache;

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

                    cache = new MementoRibbonLinearBorder(rect, c1, c2);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonLinearBorder)memento;
                    generate = !cache.UseCachedValues(rect, c1, c2);
                }

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

                    cache.linearBrush = new LinearGradientBrush(new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2), c1, c2, 90f);
                    cache.linearPen = new Pen(cache.linearBrush);

                    // Create the rounded complete border
                    GraphicsPath borderPath = new GraphicsPath();
                    borderPath.AddLine(rect.Left + 2, rect.Top, rect.Right - 3, rect.Top);
                    borderPath.AddLine(rect.Right - 3, rect.Top, rect.Right - 1, rect.Top + 2);
                    borderPath.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom - 3);
                    borderPath.AddLine(rect.Right - 1, rect.Bottom - 3, rect.Right - 3, rect.Bottom - 1);
                    borderPath.AddLine(rect.Right - 3, rect.Bottom - 1, rect.Left + 2, rect.Bottom - 1);
                    borderPath.AddLine(rect.Left + 2, rect.Bottom - 1, rect.Left, rect.Bottom - 3);
                    borderPath.AddLine(rect.Left, rect.Bottom - 3, rect.Left, rect.Top + 2);
                    borderPath.AddLine(rect.Left, rect.Top + 2, rect.Left + 2, rect.Top);
                    cache.borderPath = borderPath;

                }

                context.Graphics.DrawPath(cache.linearPen, cache.borderPath);
            }

            return memento;
        }
        /// <summary>
        /// Gets the second background color for the ribbon item.
        /// </summary>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <param name="style">Style of the ribbon color requested.</param>
        /// <returns>Color value.</returns>
        public override Color GetRibbonBackColor2(PaletteRibbonBackStyle style, PaletteState state)
        {
            IPaletteRibbonBack inherit = GetBackInherit(state);

            return(inherit?.GetRibbonBackColor2(state) ?? Target.GetRibbonBackColor2(style, state));
        }
Beispiel #32
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonQATFullbarRound(RenderContext context,
                                                                Rectangle rect,
                                                                PaletteState state,
                                                                IPaletteRibbonBack palette,
                                                                IDisposable memento)
        {
            // We never draw the top line
            rect.Y++;
            rect.Height--;

            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);
                Color c3 = palette.GetRibbonBackColor3(state);

                bool generate = true;
                MementoRibbonQATFullbarRound cache;

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

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

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

                    cache.innerRect = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2);
                    cache.innerBrush = new LinearGradientBrush(rect, c1, c2, 90f);
                    cache.darkPen = new Pen(c3);

                    GraphicsPath darkPath = new GraphicsPath();
                    GraphicsPath lightPath1 = new GraphicsPath();
                    GraphicsPath lightPath2 = new GraphicsPath();

                    // Create the dark border
                    darkPath.AddLine(rect.Left, rect.Top + 0.75f, rect.Left + 1, rect.Top);
                    darkPath.AddLine(rect.Left + 1, rect.Top, rect.Right - 3.5f, rect.Top);
                    darkPath.AddLine(rect.Right - 3.5f, rect.Top, rect.Right - 2, rect.Top + 2);
                    darkPath.AddLine(rect.Right - 2, rect.Top + 2, rect.Right - 2, rect.Bottom - 3.25f);
                    darkPath.AddLine(rect.Right - 2, rect.Bottom - 3.25f, rect.Right - 3.25f, rect.Bottom - 2);
                    darkPath.AddLine(rect.Right - 3.25f, rect.Bottom - 2, rect.Left, rect.Bottom - 2);

                    // Create the first light border
                    lightPath1.AddLine(rect.Left, rect.Bottom - 3, rect.Left, rect.Top + 2.5f);
                    lightPath1.AddLine(rect.Left, rect.Top + 2.5f, rect.Left + 1, rect.Top + 1);
                    lightPath1.AddLine(rect.Left + 1, rect.Top + 1, rect.Right - 4, rect.Top + 1);

                    // Create the second light border
                    lightPath2.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom - 2);
                    lightPath2.AddLine(rect.Right - 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 1);
                    lightPath2.AddLine(rect.Right - 2, rect.Bottom - 1, rect.Left + 1, rect.Bottom - 1);

                    cache.darkPath = darkPath;
                    cache.lightPath1 = lightPath1;
                    cache.lightPath2 = lightPath2;
                }

                // Draw a gradient for the inside of the area
                context.Graphics.FillRectangle(cache.innerBrush, cache.innerRect);

                // Draw the dark/light lines
                using (AntiAlias aa = new AntiAlias(context.Graphics))
                {
                    context.Graphics.DrawPath(cache.darkPen, cache.darkPath);
                    context.Graphics.DrawPath(_light1Pen, cache.lightPath1);
                    context.Graphics.DrawPath(_light2Pen, cache.lightPath2);
                }
            }

            return memento;
        }