Exemple #1
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual void DrawRibbonTabContextSelectedTop(Rectangle rect,
                                                               Color c2,
                                                               MementoRibbonTabContextSelected cache)
        {
            GraphicsPath outsidePath = new GraphicsPath();

            // Create path for a curved dark border around the tab
            outsidePath.AddLine(rect.Left, rect.Bottom - 2, rect.Left + 1, rect.Bottom - 3);
            outsidePath.AddLine(rect.Left + 1, rect.Bottom - 3, rect.Left + 1, rect.Top + 1.5f);
            outsidePath.AddLine(rect.Left + 1, rect.Top + 1.5f, rect.Left + 3, rect.Top);
            outsidePath.AddLine(rect.Left + 3, rect.Top, rect.Right - 4, rect.Top);
            outsidePath.AddLine(rect.Right - 4, rect.Top, rect.Right - 2, rect.Top + 1.5f);
            outsidePath.AddLine(rect.Right - 2, rect.Top + 1.5f, rect.Right - 2, rect.Bottom - 3);
            outsidePath.AddLine(rect.Right - 2, rect.Bottom - 3, rect.Right - 1, rect.Bottom - 2);

            LinearGradientBrush leftBrush = new LinearGradientBrush(rect, Color.FromArgb(125, c2), Color.FromArgb(67, c2), 90f);
            LinearGradientBrush rightBrush = new LinearGradientBrush(rect, Color.FromArgb(16, c2), Color.FromArgb(67, c2), 90f);
            cache.leftPen = new Pen(leftBrush);
            cache.rightPen = new Pen(rightBrush);

            cache.interiorRect = new Rectangle(rect.Left + 2, rect.Top + 3, rect.Width - 4, rect.Height - 3);
            cache.insideBrush = new LinearGradientBrush(rect, Color.FromArgb(134, c2), Color.FromArgb(50, c2), 90f);
            cache.outsidePath = outsidePath;
        }
Exemple #2
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual void DrawRibbonTabContextSelectedTopDraw(Rectangle rect,
                                                                   MementoRibbonTabContextSelected cache,
                                                                   Graphics g)
        {
            g.DrawLine(Pens.White, rect.Left + 2, rect.Top + 3, rect.Right - 3, rect.Top + 3);
            g.DrawLine(cache.l3, rect.Left + 2, rect.Top + 3, rect.Right - 3, rect.Top + 3);
            g.DrawLine(Pens.White, rect.Left + 2, rect.Top + 2, rect.Right - 3, rect.Top + 2);
            g.DrawLine(cache.l2, rect.Left + 2, rect.Top + 2, rect.Right - 3, rect.Top + 2);
            g.DrawLine(Pens.White, rect.Left + 3, rect.Top + 1, rect.Right - 4, rect.Top + 1);
            g.DrawLine(cache.l1, rect.Left + 3, rect.Top + 1, rect.Right - 4, rect.Top + 1);

            // Draw the inside left, right and then bottom borders
            g.DrawLine(cache.leftPen, rect.Left + 2, rect.Top + 4, rect.Left + 2, rect.Bottom - 3);
            g.DrawLine(cache.rightPen, rect.Right - 3, rect.Top + 2, rect.Right - 3, rect.Bottom - 3);
            g.DrawLine(Pens.White, rect.Left + 2, rect.Bottom - 2, rect.Left + 1, rect.Bottom - 1);
            g.DrawLine(cache.bottomInnerPen, rect.Left + 2, rect.Bottom - 2, rect.Left + 1, rect.Bottom - 1);
            g.DrawLine(Pens.White, rect.Right - 3, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 1);
            g.DrawLine(cache.bottomInnerPen, rect.Right - 3, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 1);
            g.DrawLine(Pens.White, rect.Left + 1, rect.Bottom - 2, rect.Left, rect.Bottom - 1);
            g.DrawLine(cache.bottomOuterPen, rect.Left + 1, rect.Bottom - 2, rect.Left, rect.Bottom - 1);
            g.DrawLine(Pens.White, rect.Right - 2, rect.Bottom - 2, rect.Right - 1, rect.Bottom - 1);
            g.DrawLine(cache.bottomOuterPen, rect.Right - 2, rect.Bottom - 2, rect.Right - 1, rect.Bottom - 1);
        }
Exemple #3
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;
        }