Set the SmoothingMode=AntiAlias until instance disposed.
Inheritance: GlobalId, IDisposable
        /// <summary>
        /// Draw a background for an expert style button with pressed effect.
        /// </summary>
        /// <param name="context">Rendering context.</param>
        /// <param name="rect">Rectangle to draw.</param>
        /// <param name="backColor1">First color.</param>
        /// <param name="backColor2">Second color.</param>
        /// <param name="orientation">Drawing orientation.</param>
        /// <param name="path">Clipping path.</param>
        /// <param name="memento">Cache used for drawing.</param>
        public static IDisposable DrawBackExpertPressed(RenderContext context,
                                                        Rectangle rect,
                                                        Color backColor1,
                                                        Color backColor2,
                                                        VisualOrientation orientation,
                                                        GraphicsPath path,
                                                        IDisposable memento)
        {
            using (Clipping clip = new Clipping(context.Graphics, path))
            {
                // Cannot draw a zero length rectangle
                if ((rect.Width > 0) && (rect.Height > 0))
                {
                    bool generate = true;
                    MementoBackExpertShadow cache;

                    // Access a cache instance and decide if cache resources need generating
                    if (!(memento is MementoBackExpertShadow))
                    {
                        memento?.Dispose();

                        cache   = new MementoBackExpertShadow(rect, backColor1, backColor2);
                        memento = cache;
                    }
                    else
                    {
                        cache    = (MementoBackExpertShadow)memento;
                        generate = !cache.UseCachedValues(rect, backColor1, backColor2);
                    }

                    // Do we need to generate the contents of the cache?
                    if (generate)
                    {
                        rect.X      -= 1;
                        rect.Y      -= 1;
                        rect.Width  += 2;
                        rect.Height += 2;

                        // Dispose of existing values
                        cache.Dispose();
                        cache.path1  = CreateBorderPath(rect, ITEM_CUT);
                        cache.path2  = CreateBorderPath(new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2), ITEM_CUT);
                        cache.path3  = CreateBorderPath(new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4), ITEM_CUT);
                        cache.brush1 = new SolidBrush(CommonHelper.MergeColors(backColor2, 0.4f, backColor1, 0.6f));
                        cache.brush2 = new SolidBrush(CommonHelper.MergeColors(backColor2, 0.2f, backColor1, 0.8f));
                        cache.brush3 = new SolidBrush(backColor1);
                    }

                    using (AntiAlias aa = new AntiAlias(context.Graphics))
                    {
                        context.Graphics.FillRectangle(cache.brush3, rect);
                        context.Graphics.FillPath(cache.brush1, cache.path1);
                        context.Graphics.FillPath(cache.brush2, cache.path2);
                        context.Graphics.FillPath(cache.brush3, cache.path3);
                    }
                }

                return(memento);
            }
        }
Esempio n. 2
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;
        }
Esempio n. 3
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual void DrawRibbonTabSelectedTopDraw2010(Rectangle rect,
                                                                MementoRibbonTabSelected2010 cache,
                                                                Graphics g)
        {
            // Fill in the bottom two lines that the 'FillPath' above missed
            g.DrawLine(cache.centerPen, rect.Left + 2, rect.Bottom - 2, rect.Right - 3, rect.Bottom - 2);
            g.DrawLine(cache.centerPen, rect.Left + 1, rect.Bottom - 1, rect.Right - 2, rect.Bottom - 1);

            using (AntiAlias aa = new AntiAlias(g))
            {
                // Draw shadow lines on the outside of the left and right edges
                g.DrawLine(_mediumShadowPen, rect.Left, rect.Bottom - 3, rect.Left, rect.Top + 2);
                g.DrawLine(_mediumShadowPen, rect.Right - 1, rect.Bottom - 3, rect.Right - 1, rect.Top + 2);
            }
        }
Esempio n. 4
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;
        }
Esempio n. 5
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;
        }
Esempio n. 6
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;
        }
Esempio n. 7
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;
        }
Esempio n. 8
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;
        }
        /// <summary>
        /// Raises the RenderToolStripBorder event. 
        /// </summary>
        /// <param name="e">An ToolStripRenderEventArgs containing the event data.</param>
        protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
        {
            if ((e.ToolStrip is ContextMenuStrip) ||
                (e.ToolStrip is ToolStripDropDownMenu))
            {
                // If there is a connected area to be drawn
                if (!e.ConnectedArea.IsEmpty)
                    using (SolidBrush excludeBrush = new SolidBrush(KCT.ToolStripDropDownBackground))
                        e.Graphics.FillRectangle(excludeBrush, e.ConnectedArea);

                // Create border and clipping paths
                using (GraphicsPath borderPath = CreateBorderPath(e.AffectedBounds, e.ConnectedArea, _cutContextMenu),
                                    insidePath = CreateInsideBorderPath(e.AffectedBounds, e.ConnectedArea, _cutContextMenu),
                                      clipPath = CreateClipBorderPath(e.AffectedBounds, e.ConnectedArea, _cutContextMenu))
                {
                    // Create the different pen colors we need
                    using (Pen borderPen = new Pen(KCT.MenuBorder),
                               insidePen = new Pen(KCT.ToolStripDropDownBackground))
                    {
                        // Clip all drawing to within the border path
                        using (Clipping clipping = new Clipping(e.Graphics, clipPath))
                        {
                            // Drawing with anti aliasing to create smoother appearance
                            using (AntiAlias aa = new AntiAlias(e.Graphics))
                            {
                                // Draw the inside area first
                                e.Graphics.DrawPath(insidePen, insidePath);

                                // Draw the border area second, so any overlapping gives it priority
                                e.Graphics.DrawPath(borderPen, borderPath);
                            }

                            // Draw the pixel at the bottom right of the context menu
                            e.Graphics.DrawLine(borderPen, e.AffectedBounds.Right, e.AffectedBounds.Bottom,
                                                           e.AffectedBounds.Right - 1, e.AffectedBounds.Bottom - 1);
                        }
                    }
                }
            }
            else if (!(e.ToolStrip is StatusStrip))
            {
                base.OnRenderToolStripBorder(e);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Raises the RenderToolStripBackground event. 
        /// </summary>
        /// <param name="e">An ToolStripRenderEventArgs containing the event data.</param>
        protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
        {
            // Make sure the font is current
            if (e.ToolStrip.Font != KCT.MenuStripFont)
                e.ToolStrip.Font = KCT.MenuStripFont;

            if ((e.ToolStrip is ContextMenuStrip) ||
                (e.ToolStrip is ToolStripDropDownMenu))
            {
                // Create border and clipping paths
                using (GraphicsPath borderPath = CreateBorderPath(e.AffectedBounds, _cutContextMenu),
                                      clipPath = CreateClipBorderPath(e.AffectedBounds, _cutContextMenu))
                {
                    // Clip all drawing to within the border path
                    using (Clipping clipping = new Clipping(e.Graphics, clipPath))
                    {
                        // Create the background brush
                        using (SolidBrush backBrush = new SolidBrush(KCT.ToolStripDropDownBackground))
                            e.Graphics.FillPath(backBrush, borderPath);
                    }
                }
            }
            else if (e.ToolStrip is StatusStrip)
            {
                // Create rectangle that covers the status strip area
                RectangleF backRect = new RectangleF(0, 0, e.ToolStrip.Width, e.ToolStrip.Height);

                Form owner = e.ToolStrip.FindForm();

                // Check if the status strip is inside a KryptonForm and using the Sparkle renderer, in
                // which case we want to extend the drawing down into the border area for an integrated look
                if ((owner != null) &&
                    (owner is KryptonForm) &&
                    e.ToolStrip.Visible &&
                    (e.ToolStrip.Dock == DockStyle.Bottom) &&
                    (e.ToolStrip.Bottom == owner.ClientSize.Height) &&
                    (e.ToolStrip.RenderMode == ToolStripRenderMode.ManagerRenderMode) &&
                    (ToolStripManager.Renderer is KryptonSparkleRenderer))
                {
                    // Get the window borders
                    KryptonForm kryptonForm = (KryptonForm)owner;

                    // Finally check that the actual form is using custom chrome
                    if (kryptonForm.ApplyCustomChrome)
                    {
                        // Extend down into the bottom border
                        Padding borders = kryptonForm.RealWindowBorders;
                        backRect.Height += borders.Bottom;
                        backRect.Width += borders.Horizontal;
                        backRect.X -= borders.Left;
                    }
                }

                // Cannot paint a zero sized area
                if ((backRect.Width > 0) && (backRect.Height > 0))
                {
                    // Draw entire background
                    using (SolidBrush backBrush = new SolidBrush(KCT.MenuStripGradientBegin))
                        e.Graphics.FillRectangle(backBrush, backRect);

                    // Create path for the rounded bottom edges
                    using (GraphicsPath innerPath = new GraphicsPath())
                    {
                        RectangleF innerRectF = new RectangleF(backRect.X + 2, backRect.Y, backRect.Width - 4, backRect.Height - 2);

                        innerPath.AddLine(innerRectF.Right - 1, innerRectF.Top, innerRectF.Right - 1, innerRectF.Bottom - 7);
                        innerPath.AddArc(innerRectF.Right - 7, innerRectF.Bottom - 7, 6, 6, 0f, 90f);
                        innerPath.AddArc(innerRectF.Left, innerRectF.Bottom - 7, 6, 6, 90f, 90f);
                        innerPath.AddLine(innerRectF.Left, innerRectF.Bottom - 7, innerRectF.Left, innerRectF.Top);

                        // Make the last and first arc join up
                        innerPath.CloseFigure();

                        // Fill with a gradient brush
                        using (LinearGradientBrush innerBrush = new LinearGradientBrush(new Rectangle((int)backRect.X - 1, (int)backRect.Y - 1,
                                                                                                      (int)backRect.Width + 2, (int)backRect.Height + 1),
                                                                                        KCT.StatusStripGradientBegin,
                                                                                        KCT.StatusStripGradientEnd,
                                                                                        90f))
                        {
                            innerBrush.Blend = _statusStripBlend;

                            using(AntiAlias aa = new AntiAlias(e.Graphics))
                                e.Graphics.FillPath(innerBrush, innerPath);
                        }
                    }
                }
            }
            else
                base.OnRenderToolStripBackground(e);
        }
Esempio n. 11
0
        /// <summary>
        /// Raises the RenderItemCheck event. 
        /// </summary>
        /// <param name="e">An ToolStripItemImageRenderEventArgs containing the event data.</param>
        protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
        {
            // Staring size of the checkbox is the image rectangle
            Rectangle checkBox = e.ImageRectangle;

            // Make the border of the check box 1 pixel bigger on all sides, as a minimum
            checkBox.Inflate(1, 1);

            // Can we extend upwards?
            if (checkBox.Top > _checkInset)
            {
                int diff = checkBox.Top - _checkInset;
                checkBox.Y -= diff;
                checkBox.Height += diff;
            }

            // Can we extend downwards?
            if (checkBox.Height <= (e.Item.Bounds.Height - (_checkInset * 2)))
            {
                int diff = e.Item.Bounds.Height - (_checkInset * 2) - checkBox.Height;
                checkBox.Height += diff;
            }

            // Drawing with anti aliasing to create smoother appearance
            using (AntiAlias aa = new AntiAlias(e.Graphics))
            {
                // Create border path for the check box
                using (GraphicsPath borderPath = CreateBorderPath(checkBox, _cutMenuItemBack))
                {
                    Color colorFill = KCT.CheckBackground;
                    Color colorBorder = CommonHelper.BlackenColor(KCT.CheckBackground, 0.89f, 0.88f, 0.98f);
                    if (!e.Item.Enabled)
                    {
                        colorFill = CommonHelper.ColorToBlackAndWhite(colorFill);
                        colorBorder = CommonHelper.ColorToBlackAndWhite(colorBorder);
                    }

                    // Fill the background in a solid color
                    using (SolidBrush fillBrush = new SolidBrush(colorFill))
                        e.Graphics.FillPath(fillBrush, borderPath);

                    // Draw the border around the check box
                    using (Pen borderPen = new Pen(colorBorder))
                        e.Graphics.DrawPath(borderPen, borderPath);

                    // If there is not an image, then we can draw the tick, square etc...
                    if (e.Item.Image == null)
                    {
                        CheckState checkState = CheckState.Unchecked;

                        // Extract the check state from the item
                        if (e.Item is ToolStripMenuItem)
                        {
                            ToolStripMenuItem item = (ToolStripMenuItem)e.Item;
                            checkState = item.CheckState;
                        }

                        // Decide what graphic to draw
                        Image drawImage = null;
                        switch (checkState)
                        {
                            case CheckState.Checked:
                                drawImage = _contextMenuChecked;
                                break;
                            case CheckState.Indeterminate:
                                drawImage = _contextMenuIndeterminate;
                                break;
                        }

                        if (drawImage != null)
                        {
                            // Draw the image centered in the available space
                            int xOffset = e.ImageRectangle.Width - drawImage.Width;
                            int yOffset = e.ImageRectangle.Height - drawImage.Height;
                            Rectangle drawRect = new Rectangle(e.ImageRectangle.X + xOffset,
                                                               e.ImageRectangle.Y + yOffset,
                                                               drawImage.Width,
                                                               drawImage.Height);

                            // Do we need to draw disabled?
                            if (e.Item.Enabled)
                                e.Graphics.DrawImage(drawImage, e.ImageRectangle);
                            else
                            {
                                using (ImageAttributes attribs = new ImageAttributes())
                                {
                                    attribs.SetColorMatrix(CommonHelper.MatrixDisabled);

                                    // Draw using the disabled matrix to make it look disabled
                                    e.Graphics.DrawImage(drawImage, e.ImageRectangle,
                                                         0, 0, drawImage.Width, drawImage.Height,
                                                         GraphicsUnit.Pixel, attribs);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        private static void DrawSolidBorder(Graphics g,
                                            Rectangle backRect,
                                            GradientItemColors colors)
        {
            // Drawing with anti aliasing to create smoother appearance
            using (AntiAlias aa = new AntiAlias(g))
            {
                Rectangle backRectI = backRect;
                backRectI.Inflate(1, 1);

                // Use solid color for the border
                using (Pen borderPen = new Pen(colors.Border))
                    using (GraphicsPath borderPath = CreateBorderPath(backRect, _cutMenuItemBack))
                        g.DrawPath(borderPen, borderPath);
            }
        }
Esempio n. 13
0
 private static void DrawLinearGradientBorder(Graphics g,
                                              Rectangle backRect,
                                              LinearItemColors colors)
 {
     // Drawing with anti aliasing to create smoother appearance
     using (AntiAlias aa = new AntiAlias(g))
         using (Pen borderPen = new Pen(colors.Border))
             using (GraphicsPath borderPath = CreateBorderPath(backRect, _cutMenuItemBack))
                 g.DrawPath(borderPen, borderPath);
 }
        /// <summary>
        /// Raises the RenderItemCheck event. 
        /// </summary>
        /// <param name="e">An ToolStripItemImageRenderEventArgs containing the event data.</param>
        protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
        {
            // Staring size of the checkbox is the image rectangle
            Rectangle checkBox = e.ImageRectangle;

            // Make the border of the check box 1 pixel bigger on all sides, as a minimum
            checkBox.Inflate(1, 1);

            // Can we extend upwards?
            if (checkBox.Top > _checkInset)
            {
                int diff = checkBox.Top - _checkInset;
                checkBox.Y -= diff;
                checkBox.Height += diff;
            }

            // Can we extend downwards?
            if (checkBox.Height <= (e.Item.Bounds.Height - (_checkInset * 2)))
            {
                int diff = e.Item.Bounds.Height - (_checkInset * 2) - checkBox.Height;
                checkBox.Height += diff;
            }

            // Drawing with anti aliasing to create smoother appearance
            using (AntiAlias aa = new AntiAlias(e.Graphics))
            {
                // Create border path for the check box
                using (GraphicsPath borderPath = CreateBorderPath(checkBox, _cutItemMenu))
                {
                    // Fill the background in a solid color
                    using (SolidBrush fillBrush = new SolidBrush(KCT.CheckBackground))
                        e.Graphics.FillPath(fillBrush, borderPath);

                    // Draw the border around the check box
                    using (Pen borderPen = new Pen(CommonHelper.WhitenColor(KCT.CheckBackground, 1.05f, 1.52f, 2.75f)))
                        e.Graphics.DrawPath(borderPen, borderPath);

                    // If there is not an image, then we can draw the tick, square etc...
                    if (e.Item.Image == null)
                    {
                        CheckState checkState = CheckState.Unchecked;

                        // Extract the check state from the item
                        if (e.Item is ToolStripMenuItem)
                        {
                            ToolStripMenuItem item = (ToolStripMenuItem)e.Item;
                            checkState = item.CheckState;
                        }

                        // Decide what graphic to draw
                        switch (checkState)
                        {
                            case CheckState.Checked:
                                // Create a path for the tick
                                using (GraphicsPath tickPath = CreateTickPath(checkBox))
                                {
                                    // Draw the tick with a thickish brush
                                    using (Pen tickPen = new Pen(CommonHelper.WhitenColor(KCT.CheckBackground, 3.86f, 3.02f, 1.07f), _contextCheckTickThickness))
                                        e.Graphics.DrawPath(tickPen, tickPath);
                                }
                                break;
                            case CheckState.Indeterminate:
                                // Create a path for the indeterminate diamond
                                using (GraphicsPath tickPath = CreateIndeterminatePath(checkBox))
                                {
                                    // Draw the tick with a thickish brush
                                    using (SolidBrush tickBrush = new SolidBrush(CommonHelper.WhitenColor(KCT.CheckBackground, 3.86f, 3.02f, 1.07f)))
                                        e.Graphics.FillPath(tickBrush, tickPath);
                                }
                                break;
                        }
                    }
                }
            }
        }
Esempio n. 15
0
        private void DrawDragDockingArrow(RenderContext context,
                                          Color active,
                                          Rectangle rect,
                                          VisualOrientation orientation)
        {
            using (GraphicsPath innerPath = new GraphicsPath())
            {
                float angle = 0f;
                switch (orientation)
                {
                    case VisualOrientation.Left:
                        rect = new Rectangle(rect.Right - _dragArrowHeight - _dragArrowGap,
                                             rect.Y + (rect.Height - _dragArrowWidth) / 2,
                                             _dragArrowHeight, _dragArrowWidth);

                        innerPath.AddLines(new Point[] { new Point(rect.X + 1, rect.Top + 6),
                                                         new Point(rect.Right - 1, rect.Top + 1),
                                                         new Point(rect.Right - 1, rect.Bottom - 2)});
                        break;
                    case VisualOrientation.Right:
                        rect = new Rectangle(rect.Left + _dragArrowGap,
                                             rect.Y + (rect.Height - _dragArrowWidth) / 2,
                                             _dragArrowHeight, _dragArrowWidth);

                        innerPath.AddLines(new Point[] { new Point(rect.X + 1, rect.Top + 1),
                                                         new Point(rect.X + 1, rect.Bottom - 2),
                                                         new Point(rect.Right - 1, rect.Top + 6) });
                        angle = 180f;
                        break;
                    case VisualOrientation.Top:
                        rect = new Rectangle(rect.X + (rect.Width - _dragArrowWidth) / 2,
                                             rect.Bottom - _dragArrowHeight - _dragArrowGap - 1,
                                             _dragArrowWidth, _dragArrowHeight);

                        innerPath.AddLines(new Point[] { new Point(rect.X + 1, rect.Bottom),
                                                         new Point(rect.Right - 1, rect.Bottom),
                                                         new Point(rect.X + 6, rect.Top + 1) });
                        angle = 90f;
                        break;
                    case VisualOrientation.Bottom:
                        rect = new Rectangle(rect.X + (rect.Width - _dragArrowWidth) / 2,
                                             rect.Top + _dragArrowGap,
                                             _dragArrowWidth, _dragArrowHeight);

                        innerPath.AddLines(new Point[] { new Point(rect.X + 2, rect.Top + 1),
                                                         new Point(rect.Right - 2, rect.Top + 1),
                                                         new Point(rect.X + 6, rect.Bottom - 1) });
                        angle = 270f;
                        break;
                }

                // Draw background in white top highlight the arrow
                using(AntiAlias aa = new AntiAlias(context.Graphics))
                    context.Graphics.FillPath(Brushes.White, innerPath);

                // Draw the actual arrow itself
                using(LinearGradientBrush innerBrush = new LinearGradientBrush(rect, ControlPaint.Dark(active), ControlPaint.Light(active), angle))
                    context.Graphics.FillPath(innerBrush, innerPath);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Draw the track bar position glyph.
        /// </summary>
        /// <param name="context">Render context.</param>
        /// <param name="state">Element state.</param>
        /// <param name="elementPalette">Source of palette colors.</param>
        /// <param name="drawRect">Drawing rectangle that should contain the track.</param>
        /// <param name="orientation">Drawing orientation.</param>
        /// <param name="tickStyle">Tick marks that surround the position.</param>
        public override void DrawTrackPositionGlyph(RenderContext context,
                                                    PaletteState state,
                                                    IPaletteElementColor elementPalette,
                                                    Rectangle drawRect,
                                                    Orientation orientation,
                                                    TickStyle tickStyle)
        {
            GraphicsPath border = null;

            drawRect.Inflate(-1, -1);

            if (orientation == Orientation.Horizontal)
            {
                switch (tickStyle)
                {
                case TickStyle.None:
                case TickStyle.Both:
                    border = CreatePositionPathsBoth(drawRect);
                    break;

                case TickStyle.TopLeft:
                    border = CreatePositionPathsTop(drawRect);
                    break;

                case TickStyle.BottomRight:
                    border = CreatePositionPathsBottom(drawRect);
                    break;
                }
            }
            else
            {
                switch (tickStyle)
                {
                case TickStyle.None:
                case TickStyle.Both:
                    border = CreatePositionPathsBoth(drawRect);
                    break;

                case TickStyle.TopLeft:
                    border = CreatePositionPathsLeft(drawRect);
                    break;

                case TickStyle.BottomRight:
                    border = CreatePositionPathsRight(drawRect);
                    break;
                }
            }

            if (border != null)
            {
                using (AntiAlias aa = new AntiAlias(context.Graphics))
                {
                    using (SolidBrush insideBrush = new SolidBrush(elementPalette.GetElementColor2(state)))
                        context.Graphics.FillPath(insideBrush, border);

                    using (Pen borderPen = new Pen(elementPalette.GetElementColor1(state)))
                        context.Graphics.DrawPath(borderPen, border);
                }

                border.Dispose();
            }
        }
Esempio n. 17
0
        private void DrawDragDockingRoundedMiddle(RenderContext context,
                                                  Color inside, Color border,
                                                  Color active, Color inactive,
                                                  RenderDragDockingData dragData)
        {
            Color borderColor = (dragData.ActiveMiddle ? active : border);
            Color insideColor = (dragData.ActiveMiddle ? active : inside);
            using (AntiAlias aa = new AntiAlias(context.Graphics))
            {
                using (GraphicsPath borderPath = new GraphicsPath(),
                                    insidePath = new GraphicsPath())
                {
                    // Generate the graphics paths for the border and the inside area which is just inside the border
                    Rectangle rect = dragData.RectMiddle;
                    Rectangle rectInside = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4);
                    DrawDragDockingMiddleLines(borderPath, dragData.RectMiddle, 13);
                    DrawDragDockingMiddleLines(insidePath, rectInside, 9);

                    // Fill the entire border area
                    using (SolidBrush borderBrush = new SolidBrush(Color.FromArgb(196, Color.White)))
                        context.Graphics.FillPath(borderBrush, borderPath);

                    // Fill with gradient the area inside the border
                    RectangleF rectBoundsF = new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2);
                    using (LinearGradientBrush insideBrush = new LinearGradientBrush(rectBoundsF, Color.FromArgb(196, Color.White), insideColor, 90))
                    {
                        insideBrush.Blend = _dragRoundedInsideBlend;
                        context.Graphics.FillPath(insideBrush, insidePath);
                    }

                    using (Pen borderPen = new Pen(borderColor))
                    {
                        // Finally draw the actual border
                        context.Graphics.DrawPath(borderPen, borderPath);

                        // Draw the two extra tabs
                        context.Graphics.DrawLine(borderPen, new Point(rect.Right - 2, rect.Bottom - 3), new Point(rect.Right - 2, rect.Bottom - 2));
                        context.Graphics.DrawLine(borderPen, new Point(rect.Right - 10, rect.Bottom - 3), new Point(rect.Right - 10, rect.Bottom - 2));
                        context.Graphics.DrawLine(borderPen, new Point(rect.Right - 3, rect.Bottom - 1), new Point(rect.X + 9, rect.Bottom - 1));
                    }
                }
            }
        }
Esempio n. 18
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;
        }
Esempio n. 19
0
        private void DrawDragDockingRoundedRect(RenderContext context,
                                                Color inside,
                                                Color border,
                                                Rectangle drawRect,
                                                int rounding)
        {
            using (AntiAlias aa = new AntiAlias(context.Graphics))
            {
                RectangleF rectBoundsF = new RectangleF(drawRect.X - 1, drawRect.Y - 1, drawRect.Width + 2, drawRect.Height + 1);
                Rectangle rectInside = new Rectangle(drawRect.X + 2, drawRect.Y + 2, drawRect.Width - 4, drawRect.Height - 4);
                using (GraphicsPath borderPath = CreateBorderBackPath(true, true, drawRect, PaletteDrawBorders.All, 1, rounding, true, 0),
                                    insidePath = CreateBorderBackPath(true, true, rectInside, PaletteDrawBorders.All, 1, rounding - 1, true, 0))
                {
                    using(SolidBrush borderBrush = new SolidBrush(Color.FromArgb(196, Color.White)))
                        context.Graphics.FillPath(borderBrush, borderPath);

                    using (LinearGradientBrush insideBrush = new LinearGradientBrush(rectBoundsF, Color.FromArgb(196, Color.White), inside, 90))
                    {
                        insideBrush.Blend = _dragRoundedInsideBlend;
                        context.Graphics.FillPath(insideBrush, insidePath);
                    }

                    using (Pen borderPen = new Pen(border))
                        context.Graphics.DrawPath(borderPen, borderPath);
                }
            }
        }
Esempio n. 20
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;
        }
Esempio n. 21
0
        /// <summary>
        /// Draw the track bar track glyph.
        /// </summary>
        /// <param name="context">Render context.</param>
        /// <param name="state">Element state.</param>
        /// <param name="elementPalette">Source of palette colors.</param>
        /// <param name="drawRect">Drawing rectangle that should contain the track.</param>
        /// <param name="orientation">Drawing orientation.</param>
        /// <param name="volumeControl">Drawing as a volume control or standard slider.</param>
        public override void DrawTrackGlyph(RenderContext context,
                                            PaletteState state,
                                            IPaletteElementColor elementPalette,
                                            Rectangle drawRect,
                                            Orientation orientation,
                                            bool volumeControl)
        {
            // The position indicator leavesa gap at the left/right ends for horizontal and top/bottom for vertical
            // so we do not draw that last pixel so that when the indicator is at the end the track does not stick out
            if (orientation == Orientation.Horizontal)
                drawRect.Inflate(-1, 0);
            else
                drawRect.Inflate(0, -1);

            using (Pen border1Pen = new Pen(elementPalette.GetElementColor1(state)),
                       border2Pen = new Pen(elementPalette.GetElementColor2(state)))
            {
                using (SolidBrush insideBrush = new SolidBrush(elementPalette.GetElementColor3(state)))
                {
                    if (!volumeControl)
                    {
                        context.Graphics.FillRectangle(insideBrush, drawRect.X + 1, drawRect.Y + 1, drawRect.Width - 2, drawRect.Height - 2);

                        context.Graphics.DrawLines(border1Pen, new Point[]{ new Point(drawRect.Right - 1, drawRect.Y),
                                                                            new Point(drawRect.X, drawRect.Y),
                                                                            new Point(drawRect.X, drawRect.Bottom - 1)});

                        context.Graphics.DrawLines(border2Pen, new Point[]{ new Point(drawRect.Right - 1, drawRect.Y + 1),
                                                                            new Point(drawRect.Right - 1, drawRect.Bottom - 1),
                                                                            new Point(drawRect.X + 1, drawRect.Bottom - 1)});
                    }
                    else
                    {
                        if (orientation == Orientation.Horizontal)
                        {
                            using (AntiAlias aa = new AntiAlias(context.Graphics))
                            {
                                context.Graphics.FillPolygon(insideBrush, new Point[]{ new Point(drawRect.X, drawRect.Bottom - 2),
                                                                                       new Point(drawRect.Right - 1, drawRect.Y),
                                                                                       new Point(drawRect.Right - 1, drawRect.Bottom - 1),
                                                                                       new Point(drawRect.X, drawRect.Bottom - 1),
                                                                                       new Point(drawRect.X, drawRect.Bottom - 2)});

                                context.Graphics.DrawLines(border1Pen, new Point[]{ new Point(drawRect.Right - 1, drawRect.Y),
                                                                                    new Point(drawRect.Right - 1, drawRect.Bottom - 1),
                                                                                    new Point(drawRect.X, drawRect.Bottom - 1),
                                                                                    new Point(drawRect.X, drawRect.Bottom - 2),
                                                                                    new Point(drawRect.Right - 1, drawRect.Y)});
                            }

                        }
                        else
                        {
                            using (AntiAlias aa = new AntiAlias(context.Graphics))
                            {
                                context.Graphics.FillPolygon(insideBrush, new Point[]{ new Point(drawRect.X + 1, drawRect.Bottom - 1),
                                                                                       new Point(drawRect.Right - 1, drawRect.Y + 1),
                                                                                       new Point(drawRect.X, drawRect.Y + 1),
                                                                                       new Point(drawRect.X, drawRect.Bottom - 1),
                                                                                       new Point(drawRect.X + 1, drawRect.Bottom - 1)});

                                context.Graphics.DrawLines(border1Pen, new Point[]{ new Point(drawRect.Right - 1, drawRect.Y + 1),
                                                                                    new Point(drawRect.X, drawRect.Y + 1),
                                                                                    new Point(drawRect.X, drawRect.Bottom - 1),
                                                                                    new Point(drawRect.X + 1, drawRect.Bottom - 1),
                                                                                    new Point(drawRect.Right - 1, drawRect.Y + 1)});
                            }
                        }
                    }
                }
            }
        }
Esempio n. 22
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;
        }
Esempio n. 23
0
        /// <summary>
        /// Draw the track bar position glyph.
        /// </summary>
        /// <param name="context">Render context.</param>
        /// <param name="state">Element state.</param>
        /// <param name="elementPalette">Source of palette colors.</param>
        /// <param name="drawRect">Drawing rectangle that should contain the track.</param>
        /// <param name="orientation">Drawing orientation.</param>
        /// <param name="tickStyle">Tick marks that surround the position.</param>
        public override void DrawTrackPositionGlyph(RenderContext context,
                                                    PaletteState state,
                                                    IPaletteElementColor elementPalette,
                                                    Rectangle drawRect,
                                                    Orientation orientation,
                                                    TickStyle tickStyle)
        {
            GraphicsPath outside = null;
            GraphicsPath border = null;
            GraphicsPath inside = null;

            if (orientation == Orientation.Horizontal)
            {
                switch (tickStyle)
                {
                    case TickStyle.None:
                    case TickStyle.Both:
                        CreatePositionPathsBoth(drawRect, ref outside, ref border, ref inside);
                        break;
                    case TickStyle.TopLeft:
                        CreatePositionPathsTop(drawRect, ref outside, ref border, ref inside);
                        break;
                    case TickStyle.BottomRight:
                        CreatePositionPathsBottom(drawRect, ref outside, ref border, ref inside);
                        break;
                }
            }
            else
            {
                switch (tickStyle)
                {
                    case TickStyle.None:
                    case TickStyle.Both:
                        CreatePositionPathsBoth(drawRect, ref outside, ref border, ref inside);
                        break;
                    case TickStyle.TopLeft:
                        CreatePositionPathsLeft(drawRect, ref outside, ref border, ref inside);
                        break;
                    case TickStyle.BottomRight:
                        CreatePositionPathsRight(drawRect, ref outside, ref border, ref inside);
                        break;
                }
            }

            if ((outside != null) && (border != null) && (inside != null))
            {
                using (AntiAlias aa = new AntiAlias(context.Graphics))
                {
                    using(Pen outsidePen = new Pen(elementPalette.GetElementColor1(state)),
                              borderPen = new Pen(elementPalette.GetElementColor2(state)))
                    {
                        context.Graphics.DrawPath(outsidePen, outside);

                        using(SolidBrush insideBrush = new SolidBrush(elementPalette.GetElementColor3(state)))
                            context.Graphics.FillPath(insideBrush, border);

                        context.Graphics.DrawPath(borderPen, border);

                        using (LinearGradientBrush innerBrush = new LinearGradientBrush(inside.GetBounds(),
                                                                                        elementPalette.GetElementColor4(state),
                                                                                        elementPalette.GetElementColor5(state),
                                                                                        90f))
                        {
                            context.Graphics.FillPath(innerBrush, inside);
                        }
                    }
                }

                outside.Dispose();
                border.Dispose();
                inside.Dispose();
            }
        }
Esempio n. 24
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;
        }
Esempio n. 25
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;
        }
Esempio n. 26
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual void DrawRibbonTabSelectedTopDraw2007(Rectangle rect,
                                                                MementoRibbonTabSelected2007 cache,
                                                                Graphics g)
        {
            // Fill in the bottom two lines that the 'FillPath' above missed
            g.DrawLine(cache.insidePen, rect.Left + 1, rect.Bottom - 1, rect.Right - 2, rect.Bottom - 1);
            g.DrawLine(cache.insidePen, rect.Left + 2, rect.Bottom - 2, rect.Right - 3, rect.Bottom - 2);
            g.DrawLine(cache.centerPen, rect.Left + 3, rect.Bottom - 1, rect.Right - 4, rect.Bottom - 1);

            using (AntiAlias aa = new AntiAlias(g))
            {
                // Draw a line on the inside of the left and right border edges
                g.DrawLine(cache.middlePen, rect.Left + 0.5f, rect.Bottom - 1, rect.Left + 2, rect.Bottom - 3);
                g.DrawLine(cache.middlePen, rect.Left + 2, rect.Bottom - 3, rect.Left + 2, rect.Top + 2);
                g.DrawLine(cache.middlePen, rect.Right - 1.5f, rect.Bottom - 1, rect.Right - 3, rect.Bottom - 3);
                g.DrawLine(cache.middlePen, rect.Right - 3, rect.Bottom - 3, rect.Right - 3, rect.Top + 2);

                // Draw shadow lines on the outside of the left and right edges
                g.DrawLine(_paleShadowPen, rect.Left - 1, rect.Bottom - 2, rect.Left - 1, rect.Top + 8);
                g.DrawLine(_lightShadowPen, rect.Left, rect.Bottom - 3, rect.Left, rect.Top + 5);
                g.DrawLine(_darkShadowPen, rect.Right - 1, rect.Bottom - 3, rect.Right - 1, rect.Top + 3);
                g.DrawLine(_mediumShadowPen, rect.Right, rect.Bottom - 2, rect.Right, rect.Top + 7);
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonAppTab(PaletteRibbonShape shape,
                                                       RenderContext context,
                                                       Rectangle rect,
                                                       PaletteState state,
                                                       Color baseColor1,
                                                       Color baseColor2,
                                                       IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                bool generate = true;
                MementoRibbonAppTab cache;

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

                    cache = new MementoRibbonAppTab(rect, baseColor1, baseColor2);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonAppTab)memento;
                    generate = !cache.UseCachedValues(rect, baseColor1, baseColor2);
                }

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

                    // Create common paths to all the app tab states
                    cache.GeneratePaths(rect, state);
                    cache.borderPen = new Pen(baseColor1);

                    // Create state specific colors/brushes/pens
                    switch (state)
                    {
                        case PaletteState.Normal:
                            cache.borderBrush = new SolidBrush(CommonHelper.MergeColors(baseColor1, 0.2f, baseColor2, 0.8f));
                            cache.insideFillBrush = new LinearGradientBrush(new RectangleF(rect.X, rect.Y + 1, rect.Width, rect.Height),
                                                                            CommonHelper.MergeColors(baseColor1, 0.3f, baseColor2, 0.7f),
                                                                            CommonHelper.MergeColors(baseColor1, 0.6f, baseColor2, 0.4f),
                                                                            90f);

                            cache.insideFillBrush.SetSigmaBellShape(0.33f);
                            cache.highlightBrush.CenterColor = Color.FromArgb(64, Color.White);
                            break;
                        case PaletteState.Tracking:
                            cache.borderBrush = new SolidBrush(baseColor2);
                            cache.insideFillBrush = new LinearGradientBrush(new RectangleF(rect.X, rect.Y + 1, rect.Width, rect.Height),
                                                                            CommonHelper.MergeColors(baseColor1, 0.3f, baseColor2, 0.7f),
                                                                            CommonHelper.MergeColors(baseColor1, 0.6f, baseColor2, 0.4f),
                                                                            90f);

                            cache.insideFillBrush.SetSigmaBellShape(0.33f);
                            cache.highlightBrush.CenterColor = Color.FromArgb(100, Color.White);
                            break;
                        case PaletteState.Tracking | PaletteState.FocusOverride:
                            cache.borderBrush = new SolidBrush(ControlPaint.LightLight(baseColor2));
                            cache.insideFillBrush = new LinearGradientBrush(new RectangleF(rect.X, rect.Y + 1, rect.Width, rect.Height),
                                                                            CommonHelper.MergeColors(baseColor1, 0.3f, baseColor2, 0.7f),
                                                                            CommonHelper.MergeColors(baseColor1, 0.6f, baseColor2, 0.4f),
                                                                            90f);

                            cache.insideFillBrush.SetSigmaBellShape(0.33f);
                            cache.highlightBrush.CenterColor = ControlPaint.LightLight(baseColor2);
                            break;
                        case PaletteState.Pressed:
                            cache.borderBrush = new SolidBrush(CommonHelper.MergeColors(baseColor1, 0.5f, baseColor2, 0.5f));
                            cache.insideFillBrush = new LinearGradientBrush(new RectangleF(rect.X, rect.Y + 1, rect.Width, rect.Height),
                                                                            CommonHelper.MergeColors(baseColor1, 0.3f, baseColor2, 0.7f),
                                                                            CommonHelper.MergeColors(baseColor1, 0.75f, baseColor2, 0.25f),
                                                                            90f);

                            cache.insideFillBrush.SetSigmaBellShape(0f);
                            cache.highlightBrush.CenterColor = Color.FromArgb(90, Color.White);
                            break;
                    }
                }

                // Fill the entire tab area and then add a border around the edge
                context.Graphics.FillPath(cache.borderBrush, cache.borderFillPath);

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

                // Fill inside area
                context.Graphics.FillPath(cache.insideFillBrush, cache.insideFillPath);

                // Draw highlight over bottom half
                using(Clipping clip = new Clipping(context.Graphics, cache.insideFillPath))
                    context.Graphics.FillPath(cache.highlightBrush, cache.highlightPath);
            }

            return memento;
        }
Esempio n. 28
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;
        }
Esempio n. 29
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;
        }
        /// <summary>
        /// Perform rendering before child elements are rendered.
        /// </summary>
        /// <param name="context">Rendering context.</param>
        public override void RenderBefore(RenderContext context)
        {
            // Reduce background to fit inside the border
            Rectangle backRect = ClientRectangle;
            backRect.Inflate(-1, -1);

            // If disabled then we need to reflect that immediately
            if (!Enabled)
                ElementState = PaletteState.Disabled;
            else if (ElementState == PaletteState.Disabled)
                ElementState = PaletteState.Normal;

            // Create border paths
            using (GraphicsPath borderPath = CreateBorderPath(ClientRectangle))
            {
                // Are we allowed to draw a background?
                if (_paletteBack.GetBackDraw(State) == InheritBool.True)
                {
                    _mementoBack = context.Renderer.RenderStandardBack.DrawBack(context, backRect, borderPath, _paletteBack,
                                                                                VisualOrientation.Top, State, _mementoBack);
                }

                // Are we allowed to draw the content?
                if (_paletteContent.GetContentDraw(State) == InheritBool.True)
                {
                    context.Renderer.RenderStandardContent.DrawContent(context, ClientRectangle, _paletteContent,
                                                                       _mementoContent, VisualOrientation.Top,
                                                                       State, false, false,  false);
                }

                // Are we allowed to draw border?
                if (_paletteBorder.GetBorderDraw(State) == InheritBool.True)
                {
                    // Get the border color from palette
                    Color borderColor = _paletteBorder.GetBorderColor1(State);

                    // Draw the border last to overlap the background
                    using (AntiAlias aa = new AntiAlias(context.Graphics))
                        using (Pen borderPen = new Pen(borderColor))
                            context.Graphics.DrawPath(borderPen, borderPath);
                }
            }
        }
Esempio n. 31
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;
        }
        /// <summary>
        /// Draw a background for an expert style button with pressed effect.
        /// </summary>
        /// <param name="context">Rendering context.</param>
        /// <param name="rect">Rectangle to draw.</param>
        /// <param name="backColor1">First color.</param>
        /// <param name="backColor2">Second color.</param>
        /// <param name="orientation">Drawing orientation.</param>
        /// <param name="path">Clipping path.</param>
        /// <param name="memento">Cache used for drawing.</param>
        public static IDisposable DrawBackExpertPressed(RenderContext context,
                                                        Rectangle rect,
                                                        Color backColor1,
                                                        Color backColor2,
                                                        VisualOrientation orientation,
                                                        GraphicsPath path,
                                                        IDisposable memento)
        {
            using (Clipping clip = new Clipping(context.Graphics, path))
            {
                // Cannot draw a zero length rectangle
                if ((rect.Width > 0) && (rect.Height > 0))
                {
                    bool generate = true;
                    MementoBackExpertShadow cache;

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

                        cache = new MementoBackExpertShadow(rect, backColor1, backColor2);
                        memento = cache;
                    }
                    else
                    {
                        cache = (MementoBackExpertShadow)memento;
                        generate = !cache.UseCachedValues(rect, backColor1, backColor2);
                    }

                    // Do we need to generate the contents of the cache?
                    if (generate)
                    {
                        rect.X -= 1;
                        rect.Y -= 1;
                        rect.Width += 2;
                        rect.Height += 2;

                        // Dispose of existing values
                        cache.Dispose();
                        cache.path1 = CreateBorderPath(rect, _itemCut);
                        cache.path2 = CreateBorderPath(new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2), _itemCut);
                        cache.path3 = CreateBorderPath(new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4), _itemCut);
                        cache.brush1 = new SolidBrush(CommonHelper.MergeColors(backColor2, 0.4f, backColor1, 0.6f));
                        cache.brush2 = new SolidBrush(CommonHelper.MergeColors(backColor2, 0.2f, backColor1, 0.8f));
                        cache.brush3 = new SolidBrush(backColor1);
                    }

                    using (AntiAlias aa = new AntiAlias(context.Graphics))
                    {
                        context.Graphics.FillRectangle(cache.brush3, rect);
                        context.Graphics.FillPath(cache.brush1, cache.path1);
                        context.Graphics.FillPath(cache.brush2, cache.path2);
                        context.Graphics.FillPath(cache.brush3, cache.path3);
                    }
                }

                return memento;
            }
        }
Esempio n. 33
0
        /// <summary>
        /// Draw the track bar track glyph.
        /// </summary>
        /// <param name="context">Render context.</param>
        /// <param name="state">Element state.</param>
        /// <param name="elementPalette">Source of palette colors.</param>
        /// <param name="drawRect">Drawing rectangle that should contain the track.</param>
        /// <param name="orientation">Drawing orientation.</param>
        /// <param name="volumeControl">Drawing as a volume control or standard slider.</param>
        public override void DrawTrackGlyph(RenderContext context,
                                            PaletteState state,
                                            IPaletteElementColor elementPalette,
                                            Rectangle drawRect,
                                            Orientation orientation,
                                            bool volumeControl)
        {
            // The position indicator leavesa gap at the left/right ends for horizontal and top/bottom for vertical
            // so we do not draw that last pixel so that when the indicator is at the end the track does not stick out
            if (orientation == Orientation.Horizontal)
            {
                drawRect.Inflate(-1, 0);
            }
            else
            {
                drawRect.Inflate(0, -1);
            }

            using (Pen border1Pen = new Pen(elementPalette.GetElementColor1(state)))
            {
                using (SolidBrush insideBrush = new SolidBrush(elementPalette.GetElementColor2(state)))
                {
                    if (!volumeControl)
                    {
                        context.Graphics.FillRectangle(insideBrush, drawRect.X + 1, drawRect.Y + 1, drawRect.Width - 2, drawRect.Height - 2);

                        context.Graphics.DrawLines(border1Pen, new Point[] { new Point(drawRect.Right - 1, drawRect.Y),
                                                                             new Point(drawRect.X, drawRect.Y),
                                                                             new Point(drawRect.X, drawRect.Bottom - 1) });

                        context.Graphics.DrawLines(border1Pen, new Point[] { new Point(drawRect.Right - 1, drawRect.Y + 1),
                                                                             new Point(drawRect.Right - 1, drawRect.Bottom - 1),
                                                                             new Point(drawRect.X + 1, drawRect.Bottom - 1) });

                        //context.Graphics.FillRectangle(insideBrush, drawRect);
                        //context.Graphics.DrawRectangle(border1Pen, drawRect);
                    }
                    else
                    {
                        if (orientation == Orientation.Horizontal)
                        {
                            using (AntiAlias aa = new AntiAlias(context.Graphics))
                            {
                                context.Graphics.FillPolygon(insideBrush, new Point[] { new Point(drawRect.X, drawRect.Bottom - 2),
                                                                                        new Point(drawRect.Right - 1, drawRect.Y),
                                                                                        new Point(drawRect.Right - 1, drawRect.Bottom - 1),
                                                                                        new Point(drawRect.X, drawRect.Bottom - 1),
                                                                                        new Point(drawRect.X, drawRect.Bottom - 2) });

                                context.Graphics.DrawLines(border1Pen, new Point[] { new Point(drawRect.Right - 1, drawRect.Y),
                                                                                     new Point(drawRect.Right - 1, drawRect.Bottom - 1),
                                                                                     new Point(drawRect.X, drawRect.Bottom - 1),
                                                                                     new Point(drawRect.X, drawRect.Bottom - 2),
                                                                                     new Point(drawRect.Right - 1, drawRect.Y) });
                            }
                        }
                        else
                        {
                            using (AntiAlias aa = new AntiAlias(context.Graphics))
                            {
                                context.Graphics.FillPolygon(insideBrush, new Point[] { new Point(drawRect.X + 1, drawRect.Bottom - 1),
                                                                                        new Point(drawRect.Right - 1, drawRect.Y + 1),
                                                                                        new Point(drawRect.X, drawRect.Y + 1),
                                                                                        new Point(drawRect.X, drawRect.Bottom - 1),
                                                                                        new Point(drawRect.X + 1, drawRect.Bottom - 1) });

                                context.Graphics.DrawLines(border1Pen, new Point[] { new Point(drawRect.Right - 1, drawRect.Y + 1),
                                                                                     new Point(drawRect.X, drawRect.Y + 1),
                                                                                     new Point(drawRect.X, drawRect.Bottom - 1),
                                                                                     new Point(drawRect.X + 1, drawRect.Bottom - 1),
                                                                                     new Point(drawRect.Right - 1, drawRect.Y + 1) });
                            }
                        }
                    }
                }
            }
        }