/// <summary>
        /// Gets the fourth 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 GetRibbonBackColor4(PaletteState state)
        {
            if (Apply)
            {
                Color ret = _primaryBack.GetRibbonBackColor4(Override ? OverrideState : state);

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

                return(ret);
            }
            else
            {
                return(_backupBack.GetRibbonBackColor4(state));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets the fourth 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 GetRibbonBackColor4(PaletteState state)
        {
            Color retColor = _inherit.GetRibbonBackColor4(state);

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

            return retColor;
        }
Beispiel #3
0
 /// <summary>
 /// Gets the fourth 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 GetRibbonBackColor4(PaletteState state)
 {
     if (BackColor4 != Color.Empty)
     {
         return(BackColor4);
     }
     else
     {
         return(_inheritBack.GetRibbonBackColor4(state));
     }
 }
Beispiel #4
0
        /// <summary>
        /// Gets the fourth 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 GetRibbonBackColor4(PaletteRibbonBackStyle style, PaletteState state)
        {
            IPaletteRibbonBack inherit = GetBackInherit(state);

            if (inherit != null)
            {
                return(inherit.GetRibbonBackColor4(state));
            }
            else
            {
                return(Target.GetRibbonBackColor4(style, state));
            }
        }
        /// <summary>
        /// Gets the fourth 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 GetRibbonBackColor4(PaletteState state)
        {
            if (_apply)
            {
                Color ret = _primaryBack.GetRibbonBackColor4(_override ? _state : state);

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

                return ret;
            }
            else
                return _backupBack.GetRibbonBackColor4(state);
        }
Beispiel #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
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 #14
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonGroupAreaBorder1And2(RenderContext context, 
                                                                     Rectangle rect,
                                                                     PaletteState state,
                                                                     IPaletteRibbonBack palette,
                                                                     bool limited,
                                                                     bool fading,
                                                                     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);

                if (fading)
                    c5 = Color.FromArgb(146, c5);

                bool generate = true;
                MementoRibbonGroupAreaBorder cache;

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

                    cache = new MementoRibbonGroupAreaBorder(rect, c1, c2, c3, c4, c5);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonGroupAreaBorder)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 outsidePath = new GraphicsPath();
                    GraphicsPath insidePathN = new GraphicsPath();
                    GraphicsPath insidePathL = 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
                    insidePathL.AddLine(rect.Left + 2, rect.Bottom - 2, rect.Right - 3, rect.Bottom - 2);
                    insidePathN.AddLine(rect.Left + 1, rect.Top + 3, rect.Left + 1, rect.Bottom - 3);
                    insidePathN.AddLine(rect.Left + 1, rect.Bottom - 3, rect.Left + 2, rect.Bottom - 2);
                    insidePathN.AddLine(rect.Left + 2, rect.Bottom - 2, rect.Right - 3, rect.Bottom - 2);
                    insidePathN.AddLine(rect.Right - 3, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 3);
                    insidePathN.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 shadowBrushN = new LinearGradientBrush(rectGradient, _darken8, _darken38, 90f);
                    LinearGradientBrush shadowBrushL = new LinearGradientBrush(rectGradient, _darken8, _darken18, 90f);
                    cache.shadowPenN = new Pen(shadowBrushN);
                    cache.shadowPenL = new Pen(shadowBrushL);

                    cache.insidePathN = insidePathN;
                    cache.insidePathL = insidePathL;
                    cache.fillBrush = new LinearGradientBrush(rect, c3, c4, 90f);
                    cache.fillBrush.Blend = _ribbonGroup1Blend;
                    cache.fillTopBrush = new LinearGradientBrush(rect, c5, Color.Transparent, 90f);
                    cache.fillTopBrush.Blend = _ribbonGroup2Blend;
                    cache.outsidePath = outsidePath;
                    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, (limited ? cache.insidePathL : cache.insidePathN));
                }

                Pen shadowMedium = (limited ? _lightShadowPen : _medium2ShadowPen);
                Pen shadowDark = (limited ? _medium2ShadowPen : _darkShadowPen);
                context.Graphics.DrawPath(limited ? cache.shadowPenL : cache.shadowPenN, cache.shadowPath);
                context.Graphics.DrawLine(shadowMedium, rect.Left, rect.Bottom, rect.Left, rect.Bottom - 1);
                context.Graphics.DrawLine(shadowMedium, rect.Left, rect.Bottom - 1, rect.Left + 1, rect.Bottom);
                context.Graphics.DrawLine(shadowDark, rect.Right, rect.Bottom - 2, rect.Right - 2, rect.Bottom);
                context.Graphics.DrawLine(shadowMedium, rect.Right, rect.Bottom - 1, rect.Right - 1, rect.Bottom);
            }

            return memento;
        }
Beispiel #15
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 #16
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 #17
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;
        }
        /// <summary>
        /// Gets the fourth 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 GetRibbonBackColor4(PaletteRibbonBackStyle style, PaletteState state)
        {
            IPaletteRibbonBack inherit = GetBackInherit(state);

            return(inherit?.GetRibbonBackColor4(state) ?? Target.GetRibbonBackColor4(style, state));
        }
Beispiel #19
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;
        }