예제 #1
0
 /// <summary>
 /// Internal rendering method.
 /// </summary>
 protected virtual void DrawRibbonTabHighlightTop(Rectangle rect,
                                                  Color c4, Color c5,
                                                  MementoRibbonTabHighlight cache)
 {
     RectangleF hF = new RectangleF(rect.Left - 2, rect.Top - 1, rect.Width + 4, 6);
     RectangleF vF = new RectangleF(rect.Left - 2, rect.Top + 1, rect.Width + 4, rect.Height - 1);
     cache.topBorderBrush = new LinearGradientBrush(hF, Color.FromArgb(48, c5), Color.FromArgb(64, c5), 90f);
     cache.borderVertBrush = new LinearGradientBrush(vF, c5, c4, 90f);
     cache.outsideVertBrush = new LinearGradientBrush(vF, Color.FromArgb(48, c5), c5, 90f);
 }
예제 #2
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual void DrawRibbonTabHighlightTopDraw(Rectangle rect,
                                                             Color c1, Color c2,
                                                             Color c3, Color c4,
                                                             Color c5,
                                                             MementoRibbonTabHighlight cache,
                                                             Graphics g,
                                                             bool alternate)
        {
            g.FillRectangle(cache.topBorderBrush, rect.Left - 1, rect.Top - 1, rect.Width + 2, 4);
            g.DrawLine(cache.innerVertPen, rect.Left + 2, rect.Bottom - 2, rect.Left + 2, rect.Top + 3);
            g.DrawLine(cache.innerVertPen, rect.Right - 3, rect.Bottom - 2, rect.Right - 3, rect.Top + 3);
            g.DrawLine(cache.innerHorzPen, rect.Left + 2, rect.Top + 2, rect.Right - 3, rect.Top + 2);

            if (alternate)
            {
                g.DrawLine(cache.innerHorzPen, rect.Left + 2, rect.Top + 1, rect.Right - 3, rect.Top + 1);
                g.DrawLine(cache.borderHorzPen, rect.Left + 3, rect.Top, rect.Right - 4, rect.Top);
            }
            else
            {
                g.DrawLine(cache.innerHorzPen, rect.Left + 3, rect.Top + 1, rect.Right - 4, rect.Top + 1);
                g.DrawLine(cache.borderHorzPen, rect.Left + 4, rect.Top, rect.Right - 5, rect.Top);
            }

            g.FillRectangle(cache.borderVertBrush, rect.Left + 1, rect.Top + 2, 1, rect.Height - 3);
            g.FillRectangle(cache.borderVertBrush, rect.Right - 2, rect.Top + 2, 1, rect.Height - 3);
            g.FillRectangle(cache.outsideVertBrush, rect.Left, rect.Top + 3, 1, rect.Height - 4);
            g.FillRectangle(cache.outsideVertBrush, rect.Left - 1, rect.Top + 3, 1, rect.Height - 4);
            g.FillRectangle(cache.outsideVertBrush, rect.Right - 1, rect.Top + 3, 1, rect.Height - 4);
            g.FillRectangle(cache.outsideVertBrush, rect.Right, rect.Top + 3, 1, rect.Height - 4);
        }
예제 #3
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;
        }