Beispiel #1
0
        protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
        {
            if (e.ToolStrip is ToolStripDropDownMenu)
            {
                return;
            }

            #region Background

            using (LinearGradientBrush b = new LinearGradientBrush(
                       Point.Empty, new PointF(0, e.ToolStrip.Height),
                       ColorTable.BackgroundNorth,
                       ColorTable.BackgroundSouth))
            {
                using (GraphicsPath border = GetToolStripRectangle(e.ToolStrip))
                {
                    e.Graphics.FillPath(b, border);
                }
            }

            #endregion

            if (GlossyEffect)
            {
                #region Glossy Effect

                DrawGlossyEffect(e.Graphics, e.ToolStrip, 1);

                #endregion
            }

            if (BackgroundGlow)
            {
                #region BackroundGlow

                int       glowSize = Convert.ToInt32(Convert.ToSingle(e.ToolStrip.Height) * 0.15f);
                Rectangle glow     = new Rectangle(0,
                                                   e.ToolStrip.Height - glowSize - 1,
                                                   e.ToolStrip.Width - 1,
                                                   glowSize);

                using (LinearGradientBrush b = new LinearGradientBrush(
                           new Point(0, glow.Top - 1), new PointF(0, glow.Bottom),
                           Color.FromArgb(0, ColorTable.BackgroundGlow),
                           ColorTable.BackgroundGlow))
                {
                    using (GraphicsPath border =
                               GraphicsTools.CreateBottomRoundRectangle(glow, ToolStripRadius))
                    {
                        e.Graphics.FillPath(b, border);
                    }
                }


                #endregion
            }
        }
Beispiel #2
0
        /// <summary>
        /// Draws the background of a menu, vista style
        /// </summary>
        /// <param name="g"></param>
        /// <param name="r"></param>
        /// <param name="highlighted"></param>
        private void DrawVistaMenuBackground(Graphics g, Rectangle r, bool highlighted, bool isMainMenu)
        {
            //g.Clear(ColorTable.MenuBackground);

            int margin = 2;
            int left   = 22;

            #region IconSeparator

            if (!isMainMenu)
            {
                using (Pen p = new Pen(ColorTable.MenuDark))
                {
                    g.DrawLine(p,
                               new Point(r.Left + left, r.Top),
                               new Point(r.Left + left, r.Height - margin));
                }


                using (Pen p = new Pen(ColorTable.MenuLight))
                {
                    g.DrawLine(p,
                               new Point(r.Left + left + 1, r.Top),
                               new Point(r.Left + left + 1, r.Height - margin));
                }
            }

            #endregion

            if (highlighted)
            {
                #region Draw Rectangle

                using (GraphicsPath path = GraphicsTools.CreateRoundRectangle(
                           new Rectangle(r.X + margin, r.Y + margin, r.Width - margin * 2, r.Height - margin * 2), 3))
                {
                    using (Brush b = new LinearGradientBrush(
                               new Point(0, 2), new Point(0, r.Height - 2),
                               ColorTable.MenuHighlightNorth,
                               ColorTable.MenuHighlightSouth))
                    {
                        g.FillPath(b, path);
                    }

                    using (Pen p = new Pen(ColorTable.MenuHighlight))
                    {
                        g.DrawPath(p, path);
                    }
                }

                #endregion
            }
        }
Beispiel #3
0
        /// <summary>
        /// Draws the glossy effect on the toolbar
        /// </summary>
        /// <param name="g"></param>
        /// <param name="t"></param>
        /// <returns></returns>
        private void DrawGlossyEffect(Graphics g, ToolStrip t, int offset)
        {
            Rectangle glossyRect = new Rectangle(0, offset,
                                                 t.Width - 1,
                                                 (t.Height - 1) / 2);

            using (LinearGradientBrush b = new LinearGradientBrush(
                       glossyRect.Location, new PointF(0, glossyRect.Bottom),
                       ColorTable.GlossyEffectNorth,
                       ColorTable.GlossyEffectSouth))
            {
                using (GraphicsPath border =
                           GraphicsTools.CreateTopRoundRectangle(glossyRect, ToolStripRadius))
                {
                    g.FillPath(b, border);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Renders the background of a button on the specified rectangle using the specified device
        /// </summary>
        /// <param name="e"></param>
        private void DrawVistaButtonBackground(Graphics g, Rectangle r, bool selected, bool pressed, bool checkd)
        {
            g.SmoothingMode = SmoothingMode.AntiAlias;

            Rectangle outerBorder = new Rectangle(r.Left, r.Top, r.Width - 1, r.Height - 1);
            Rectangle border      = outerBorder; border.Inflate(-1, -1);
            Rectangle innerBorder = border; innerBorder.Inflate(-1, -1);
            Rectangle glossy      = outerBorder; glossy.Height /= 2;
            Rectangle fill        = innerBorder; fill.Height /= 2;
            Rectangle glow        = Rectangle.FromLTRB(outerBorder.Left,
                                                       outerBorder.Top + Convert.ToInt32(Convert.ToSingle(outerBorder.Height) * .5f),
                                                       outerBorder.Right, outerBorder.Bottom);

            if (selected || pressed || checkd)
            {
                #region Layers

                //Outer border
                using (GraphicsPath path =
                           GraphicsTools.CreateRoundRectangle(outerBorder, ButtonRadius))
                {
                    using (Pen p = new Pen(ColorTable.ButtonOuterBorder))
                    {
                        g.DrawPath(p, path);
                    }
                }

                //Checked fill
                if (checkd)
                {
                    using (GraphicsPath path = GraphicsTools.CreateRoundRectangle(innerBorder, 2))
                    {
                        using (Brush b = new SolidBrush(selected ? ColorTable.CheckedButtonFillHot : ColorTable.CheckedButtonFill))
                        {
                            g.FillPath(b, path);
                        }
                    }
                }

                //Glossy effefct
                using (GraphicsPath path = GraphicsTools.CreateTopRoundRectangle(glossy, ButtonRadius))
                {
                    using (Brush b = new LinearGradientBrush(
                               new Point(0, glossy.Top),
                               new Point(0, glossy.Bottom),
                               ColorTable.GlossyEffectNorth,
                               ColorTable.GlossyEffectSouth))
                    {
                        g.FillPath(b, path);
                    }
                }

                //Border
                using (GraphicsPath path =
                           GraphicsTools.CreateRoundRectangle(border, ButtonRadius))
                {
                    using (Pen p = new Pen(ColorTable.ButtonBorder))
                    {
                        g.DrawPath(p, path);
                    }
                }

                Color fillNorth = pressed ? ColorTable.ButtonFillNorthPressed : ColorTable.ButtonFillNorth;
                Color fillSouth = pressed ? ColorTable.ButtonFillSouthPressed : ColorTable.ButtonFillSouth;

                //Fill
                using (GraphicsPath path = GraphicsTools.CreateTopRoundRectangle(fill, ButtonRadius))
                {
                    using (Brush b = new LinearGradientBrush(
                               new Point(0, fill.Top),
                               new Point(0, fill.Bottom),
                               fillNorth, fillSouth))
                    {
                        g.FillPath(b, path);
                    }
                }

                Color innerBorderColor = pressed || checkd ? ColorTable.ButtonInnerBorderPressed : ColorTable.ButtonInnerBorder;

                //Inner border
                using (GraphicsPath path =
                           GraphicsTools.CreateRoundRectangle(innerBorder, ButtonRadius))
                {
                    using (Pen p = new Pen(innerBorderColor))
                    {
                        g.DrawPath(p, path);
                    }
                }

                //Glow
                using (GraphicsPath clip = GraphicsTools.CreateRoundRectangle(glow, 2))
                {
                    g.SetClip(clip, CombineMode.Intersect);

                    Color glowColor = ColorTable.Glow;

                    if (checkd)
                    {
                        if (selected)
                        {
                            glowColor = ColorTable.CheckedGlowHot;
                        }
                        else
                        {
                            glowColor = ColorTable.CheckedGlow;
                        }
                    }

                    using (GraphicsPath brad = CreateBottomRadialPath(glow))
                    {
                        using (PathGradientBrush pgr = new PathGradientBrush(brad))
                        {
                            unchecked
                            {
                                int        opacity = 255;
                                RectangleF bounds  = brad.GetBounds();
                                pgr.CenterPoint    = new PointF((bounds.Left + bounds.Right) / 2f, (bounds.Top + bounds.Bottom) / 2f);
                                pgr.CenterColor    = Color.FromArgb(opacity, glowColor);
                                pgr.SurroundColors = new Color[] { Color.FromArgb(0, glowColor) };
                            }
                            g.FillPath(pgr, brad);
                        }
                    }
                    g.ResetClip();
                }



                #endregion
            }
        }
Beispiel #5
0
 /// <summary>
 /// Gets a rounded rectangle representing the hole area of the toolstrip
 /// </summary>
 /// <param name="toolStrip"></param>
 /// <returns></returns>
 private GraphicsPath GetToolStripRectangle(ToolStrip toolStrip)
 {
     return(GraphicsTools.CreateRoundRectangle(
                new Rectangle(0, 0, toolStrip.Width - 1, toolStrip.Height - 1), ToolStripRadius));
 }