示例#1
0
 /// <summary>
 /// Renders the Ribbon Orb's DropDown background
 /// </summary>
 /// <param name="e"></param>
 public virtual void OnRenderOrbDropDownBackground(RibbonOrbDropDownEventArgs e)
 {
 }
 /// <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);
            }

            SmoothingMode sm = e.Graphics.SmoothingMode;
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

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

            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);
            }

            //Steve - Recent Items Caption
            if (e.RibbonOrbDropDown.ContentRecentItemsCaptionBounds.Height > 0)
            {
                Rectangle cb = e.RibbonOrbDropDown.ContentRecentItemsCaptionBounds;

                //draw the lines first since we need to adjust the bounds for the text portion
                int linePos = Convert.ToInt32(e.RibbonOrbDropDown.RecentItemsCaptionLineSpacing / 2);

                using (Pen p = new Pen(OrbDropDownSeparatorlight))
                {
                    e.Graphics.DrawLine(p,
                         new Point(OrbDDContent.Left, cb.Bottom - linePos),
                         new Point(OrbDDContent.Right, cb.Bottom - linePos));
                }
                using (Pen p = new Pen(OrbDropDownSeparatordark))
                {
                    e.Graphics.DrawLine(p,
                         new Point(OrbDDContent.Left, cb.Bottom - linePos - 1),
                         new Point(OrbDDContent.Right, cb.Bottom - linePos - 1));
                }

                //adjust the bounds for the text margins and line height
                cb.X += e.Ribbon.ItemMargin.Left;
                cb.Width -= (e.Ribbon.ItemMargin.Left + e.Ribbon.ItemMargin.Right);
                cb.Height -= e.RibbonOrbDropDown.RecentItemsCaptionLineSpacing;

                StringFormat sf = new StringFormat();
                sf.LineAlignment = StringAlignment.Center;
                if (e.Ribbon.RightToLeft == RightToLeft.Yes)
                {
                    sf.Alignment = StringAlignment.Far;
                }
                else
                {
                    sf.Alignment = StringAlignment.Near;
                }
                e.Graphics.DrawString(e.RibbonOrbDropDown.RecentItemsCaption, new Font(e.Ribbon.RibbonTabFont.FontFamily, e.Ribbon.RibbonTabFont.Size, FontStyle.Bold), Brushes.DarkBlue, cb, sf);
            }

            using (SolidBrush b = new SolidBrush(OrbDropDownContentbglight))
            {
                //Menu items
                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
            if (e.Ribbon.OrbVisible && e.Ribbon.CaptionBarVisible && e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2007)
            {
                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
        }
        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
        }