Ejemplo n.º 1
0
 /// <summary>
 ///     Renders the Ribbon Orb's DropDown background
 /// </summary>
 /// <param name="e"></param>
 public virtual void OnRenderOrbDropDownBackground(RibbonOrbDropDownEventArgs e)
 {
 }
        public override void OnRenderOrbDropDownBackground(RibbonOrbDropDownEventArgs e)
        {
            int Width = e.RibbonOrbDropDown.Width;
            int Height = e.RibbonOrbDropDown.Height;

            Rectangle OrbDDContent = e.RibbonOrbDropDown.ContentBounds;
            Rectangle Bcontent = e.RibbonOrbDropDown.ContentButtonsBounds;
            Rectangle OuterRect = new Rectangle(0, 0, Width - 1, Height - 1);
            Rectangle InnerRect = new Rectangle(1, 1, Width - 3, Height - 3);
            Rectangle NorthNorthRect = new Rectangle(1, 1, Width - 3, OrbDDContent.Top / 2);
            Rectangle northSouthRect = new Rectangle(1, NorthNorthRect.Bottom, NorthNorthRect.Width, OrbDDContent.Top / 2);
            Rectangle southSouthRect = Rectangle.FromLTRB(1,
                (Height - OrbDDContent.Bottom) / 2 + OrbDDContent.Bottom, Width - 1, Height - 1);

            Color OrbDropDownDarkBorder = ColorTable.OrbDropDownDarkBorder;
            Color OrbDropDownLightBorder = ColorTable.OrbDropDownLightBorder;
            Color OrbDropDownBack = ColorTable.OrbDropDownBack;
            Color OrbDropDownNorthA = ColorTable.OrbDropDownNorthA;
            Color OrbDropDownNorthB = ColorTable.OrbDropDownNorthB;
            Color OrbDropDownNorthC = ColorTable.OrbDropDownNorthC;
            Color OrbDropDownNorthD = ColorTable.OrbDropDownNorthD;
            Color OrbDropDownSouthC = ColorTable.OrbDropDownSouthC;
            Color OrbDropDownSouthD = ColorTable.OrbDropDownSouthD;
            Color OrbDropDownContentbg = ColorTable.OrbDropDownContentbg;
            Color OrbDropDownContentbglight = ColorTable.OrbDropDownContentbglight;
            Color OrbDropDownSeparatorlight = ColorTable.OrbDropDownSeparatorlight;
            Color OrbDropDownSeparatordark = ColorTable.OrbDropDownSeparatordark;

            GraphicsPath innerPath = RoundRectangle(InnerRect, 6);
            GraphicsPath outerPath = RoundRectangle(OuterRect, 6);

            e.Graphics.SmoothingMode = SmoothingMode.None;

            using (Brush b = new SolidBrush(Color.FromArgb(0x8e, 0x8e, 0x8e)))
            {
                e.Graphics.FillRectangle(b, new Rectangle(Width - 10, Height - 10, 10, 10));
            }

            using (Brush b = new SolidBrush(OrbDropDownBack))
            {
                e.Graphics.FillPath(b, outerPath);
            }

            GradientRect(e.Graphics, NorthNorthRect, OrbDropDownNorthA, OrbDropDownNorthB);
            GradientRect(e.Graphics, northSouthRect, OrbDropDownNorthC, OrbDropDownNorthD);
            GradientRect(e.Graphics, southSouthRect, OrbDropDownSouthC, OrbDropDownSouthD);

            using (Pen p = new Pen(OrbDropDownDarkBorder))
            {
                e.Graphics.DrawPath(p, outerPath);
            }

            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

            using (Pen p = new Pen(OrbDropDownLightBorder))
            {
                e.Graphics.DrawPath(p, innerPath);
            }

            innerPath.Dispose();
            outerPath.Dispose();

            #region Content
            InnerRect = OrbDDContent; InnerRect.Inflate(0, 0);
            OuterRect = OrbDDContent; OuterRect.Inflate(1, 1);

            using (SolidBrush b = new SolidBrush(OrbDropDownContentbg))
            {
                e.Graphics.FillRectangle(b, OrbDDContent);
            }

            using (SolidBrush b = new SolidBrush(OrbDropDownContentbglight))
            {
                e.Graphics.FillRectangle(b, Bcontent);
            }

            using (Pen p = new Pen(OrbDropDownSeparatorlight))
            {
                e.Graphics.DrawLine(p, Bcontent.Right, Bcontent.Top, Bcontent.Right, Bcontent.Bottom);
            }

            using (Pen p = new Pen(OrbDropDownSeparatordark))
            {
                e.Graphics.DrawLine(p, Bcontent.Right - 1, Bcontent.Top, Bcontent.Right - 1, Bcontent.Bottom);
            }

            using (Pen p = new Pen(OrbDropDownLightBorder))
            {
                e.Graphics.DrawRectangle(p, OuterRect);
            }

            using (Pen p = new Pen(OrbDropDownDarkBorder))
            {
                e.Graphics.DrawRectangle(p, InnerRect);
            } 
            #endregion

            #region Orb
            Rectangle orbb = e.Ribbon.RectangleToScreen(e.Ribbon.OrbBounds);
            orbb = e.RibbonOrbDropDown.RectangleToClient(orbb);
            DrawOrb(e.Graphics, orbb, e.Ribbon.OrbImage, e.Ribbon.OrbSelected, e.Ribbon.OrbPressed); 
            #endregion
        }