Example #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;

            using (GraphicsPath path = GraphicsPathHelper.CreateFilletRectangle(
                       ClientRectangle, 8, RoundStyle.All, false))
            {
                using (SolidBrush brush = new SolidBrush(ColorTable.BackColorNormal))
                {
                    g.FillPath(brush, path);
                }
                using (Pen pen = new Pen(ColorTable.BorderColor))
                {
                    g.DrawPath(pen, path);

                    using (GraphicsPath innerPath = GraphicsPathHelper.CreateFilletRectangle(
                               ClientRectangle, 8, RoundStyle.All, true))
                    {
                        g.DrawPath(pen, innerPath);
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rect"></param>
        /// <param name="begin"></param>
        /// <param name="end"></param>
        /// <param name="border"></param>
        /// <param name="innerBorder"></param>
        /// <param name="blend"></param>
        /// <param name="mode"></param>
        /// <param name="radios"></param>
        /// <param name="roundStyle"></param>
        /// <param name="drawBorder"></param>
        /// <param name="drawInnderBorder"></param>
        internal static void DrawGradientRoundRect(Graphics g, Rectangle rect, Color begin, Color end, Color border,
                                                   Color innerBorder, Blend blend, LinearGradientMode mode, int radios,
                                                   RoundStyle roundStyle, bool drawBorder, bool drawInnderBorder)
        {
            using (GraphicsPath path = GraphicsPathHelper.CreateFilletRectangle(rect, radios, roundStyle, true))
            {
                using (var brush = new LinearGradientBrush(rect, begin, end, mode))
                {
                    brush.Blend = blend;
                    g.FillPath(brush, path);
                }

                if (drawBorder)
                {
                    using (var pen = new Pen(border))
                    {
                        g.DrawPath(pen, path);
                    }
                }
            }

            if (drawInnderBorder)
            {
                rect.Inflate(-1, -1);
                using (GraphicsPath path = GraphicsPathHelper.CreateFilletRectangle(rect, radios, roundStyle, true))
                {
                    using (var pen = new Pen(innerBorder))
                    {
                        g.DrawPath(pen, path);
                    }
                }
            }
        }
Example #3
0
 /// <summary>
 /// 绘制半透明区域.
 /// </summary>
 /// <param name="g"></param>
 /// <param name="rect"></param>
 /// <param name="roundWidth"></param>
 private static void DrawTranslucence(Graphics g, Rectangle rect, int roundWidth)
 {
     using (GraphicsPath pathTop = GraphicsPathHelper.CreateFilletRectangle(rect, roundWidth, RoundStyle.Top, false))
     {
         using (SolidBrush brushAlpha = new SolidBrush(Color.FromArgb(128, 255, 255, 255)))
         {
             g.FillPath(brushAlpha, pathTop);
         }
     }
 }
Example #4
0
 private void SetRegion()
 {
     using (GraphicsPath path = GraphicsPathHelper.CreateFilletRectangle(
                ClientRectangle, 8, RoundStyle.All, false))
     {
         if (base.Region != null)
         {
             base.Region.Dispose();
         }
         base.Region = new Region(path);
     }
 }
        protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics  g         = e.Graphics;
            Rectangle bounds    = e.AffectedBounds;

            if (toolStrip is ToolStripDropDown)
            {
                using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
                {
                    using (GraphicsPath path =
                               GraphicsPathHelper.CreateFilletRectangle(bounds, 8, RoundStyle.All, true))
                    {
                        using (Pen pen = new Pen(ColorTable.DropDownImageSeparator))
                        {
                            path.Widen(pen);
                            g.DrawPath(pen, path);
                        }
                    }
                }

                bounds.Inflate(-1, -1);
                using (GraphicsPath innerPath = GraphicsPathHelper.CreateFilletRectangle(
                           bounds, 8, RoundStyle.All, true))
                {
                    using (Pen pen = new Pen(ColorTable.BackNormal))
                    {
                        g.DrawPath(pen, innerPath);
                    }
                }
            }
            else if (toolStrip is StatusStrip)
            {
                using (Pen pen = new Pen(ColorTable.Border))
                {
                    e.Graphics.DrawRectangle(
                        pen, 0, 0, e.ToolStrip.Width - 1, e.ToolStrip.Height - 1);
                }
            }
            else if (toolStrip is MenuStrip)
            {
                base.OnRenderToolStripBorder(e);
            }
            else
            {
                using (Pen pen = new Pen(ColorTable.Border))
                {
                    g.DrawRectangle(
                        pen, 0, 0, e.ToolStrip.Width - 1, e.ToolStrip.Height - 1);
                }
            }
        }
Example #6
0
        protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)

        {
            Color     baseColor = ColorTable.BackColorNormal;
            ToolStrip toolStrip = e.ToolStrip;
            Graphics  g         = e.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;

            if (toolStrip is ToolStripDropDown)
            {
                RegionHelper.SetControlRegion(e.ToolStrip, e.AffectedBounds);

                Rectangle rect = e.AffectedBounds;

                using (GraphicsPath path = GraphicsPathHelper.CreateFilletRectangle(
                           rect, 8, RoundStyle.All, false))
                {
                    using (SolidBrush brush = new SolidBrush(ColorTable.BackColorNormal))
                    {
                        g.FillPath(brush, path);
                    }
                    using (Pen pen = new Pen(ColorTable.BorderColor))
                    {
                        g.DrawPath(pen, path);

                        using (GraphicsPath innerPath = GraphicsPathHelper.CreateFilletRectangle(
                                   rect, 8, RoundStyle.All, true))
                        {
                            g.DrawPath(pen, innerPath);
                        }
                    }
                }
            }
            else
            {
                LinearGradientMode mode =
                    e.ToolStrip.Orientation == Orientation.Horizontal ?
                    LinearGradientMode.Vertical : LinearGradientMode.Horizontal;
                RenderBackgroundInternal(
                    g,
                    e.AffectedBounds,
                    ColorTable.BackColorHover,
                    ColorTable.BorderColor,
                    ColorTable.BackColorNormal,
                    RoundStyle.All,
                    false,
                    true,
                    mode);
            }
        }
Example #7
0
 /// <summary>
 /// 为控件设置关联的窗口区域.
 /// </summary>
 /// <param name="control">要设置窗口区域的控件.</param>
 /// <param name="bounds">窗口区域.</param>
 /// <param name="radius">圆角半径.</param>
 /// <param name="roundStyle">圆角样式.</param>
 public static void SetControlRegion(Control control, Rectangle bounds, int radius = 8, RoundStyle roundStyle = RoundStyle.All)
 {
     using (GraphicsPath path = GraphicsPathHelper.CreateFilletRectangle(bounds, radius, roundStyle, true))
     {
         Region region = new Region(path);
         path.Widen(Pens.White);
         region.Union(path);
         if (control.Region != null)
         {
             control.Region.Dispose();
         }
         control.Region = region;
     }
 }
Example #8
0
        /// <summary>
        /// 绘制圆角边框.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rect"></param>
        /// <param name="borderColor"></param>
        /// <param name="innerBorderColor"></param>
        /// <param name="style"></param>
        /// <param name="roundWidth"></param>
        private static void DrawRoundBorder(Graphics g, Rectangle rect, Color borderColor, Color innerBorderColor, RoundStyle style, int roundWidth)
        {
            using (GraphicsPath path = GraphicsPathHelper.CreateFilletRectangle(rect, roundWidth, style, false))
            {
                using (Pen pen = new Pen(borderColor))
                {
                    g.DrawPath(pen, path);
                }
            }

            rect.Inflate(-1, -1);
            using (GraphicsPath path = GraphicsPathHelper.CreateFilletRectangle(rect, roundWidth, style, false))
            {
                using (Pen pen = new Pen(innerBorderColor))
                {
                    g.DrawPath(pen, path);
                }
            }
        }
Example #9
0
        internal void RenderBackgroundInternal(Graphics g, Rectangle rect, Color baseColor, Color borderColor,
                                               Color innerBorderColor, RoundStyle style, int roundWidth, float basePosition, bool drawBorder, bool drawGlass, LinearGradientMode mode)
        {
            if (drawBorder)
            {
                rect.Width--;
                rect.Height--;
            }

            using (LinearGradientBrush brush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, mode))
            {
                Color[] colors = new Color[4];
                colors[0] = GetColor(baseColor, 0, 35, 24, 9);
                colors[1] = GetColor(baseColor, 0, 13, 8, 3);
                colors[2] = baseColor;
                colors[3] = GetColor(baseColor, 0, 68, 69, 54);

                ColorBlend blend = new ColorBlend();
                blend.Positions           = new float[] { 0.0f, basePosition, basePosition + 0.05f, 1.0f };
                blend.Colors              = colors;
                brush.InterpolationColors = blend;
                if (style != RoundStyle.None)
                {
                    using (GraphicsPath path =
                               GraphicsPathHelper.CreateFilletRectangle(rect, roundWidth, style, false))
                    {
                        g.FillPath(brush, path);
                    }

                    if (baseColor.A > 80)
                    {
                        Rectangle rectTop = rect;

                        if (mode == LinearGradientMode.Vertical)
                        {
                            rectTop.Height = (int)(rectTop.Height * basePosition);
                        }
                        else
                        {
                            rectTop.Width = (int)(rect.Width * basePosition);
                        }
                        using (GraphicsPath pathTop = GraphicsPathHelper.CreateFilletRectangle(
                                   rectTop, roundWidth, RoundStyle.Top, false))
                        {
                            using (SolidBrush brushAlpha =
                                       new SolidBrush(Color.FromArgb(80, 255, 255, 255)))
                            {
                                g.FillPath(brushAlpha, pathTop);
                            }
                        }
                    }

                    if (drawGlass)
                    {
                        RectangleF glassRect = rect;
                        if (mode == LinearGradientMode.Vertical)
                        {
                            glassRect.Y      = rect.Y + rect.Height * basePosition;
                            glassRect.Height = (rect.Height - rect.Height * basePosition) * 2;
                        }
                        else
                        {
                            glassRect.X     = rect.X + rect.Width * basePosition;
                            glassRect.Width = (rect.Width - rect.Width * basePosition) * 2;
                        }
                        ControlPaintEx.DrawGlass(g, glassRect, 170, 0);
                    }

                    if (drawBorder)
                    {
                        using (GraphicsPath path =
                                   GraphicsPathHelper.CreateFilletRectangle(rect, roundWidth, style, false))
                        {
                            using (Pen pen = new Pen(borderColor))
                            {
                                g.DrawPath(pen, path);
                            }
                        }

                        rect.Inflate(-1, -1);
                        using (GraphicsPath path =
                                   GraphicsPathHelper.CreateFilletRectangle(rect, roundWidth, style, false))
                        {
                            using (Pen pen = new Pen(innerBorderColor))
                            {
                                g.DrawPath(pen, path);
                            }
                        }
                    }
                }
                else
                {
                    g.FillRectangle(brush, rect);
                    if (baseColor.A > 80)
                    {
                        Rectangle rectTop = rect;
                        if (mode == LinearGradientMode.Vertical)
                        {
                            rectTop.Height = (int)(rectTop.Height * basePosition);
                        }
                        else
                        {
                            rectTop.Width = (int)(rect.Width * basePosition);
                        }
                        using (SolidBrush brushAlpha =
                                   new SolidBrush(Color.FromArgb(80, 255, 255, 255)))
                        {
                            g.FillRectangle(brushAlpha, rectTop);
                        }
                    }

                    if (drawGlass)
                    {
                        RectangleF glassRect = rect;
                        if (mode == LinearGradientMode.Vertical)
                        {
                            glassRect.Y      = rect.Y + rect.Height * basePosition;
                            glassRect.Height = (rect.Height - rect.Height * basePosition) * 2;
                        }
                        else
                        {
                            glassRect.X     = rect.X + rect.Width * basePosition;
                            glassRect.Width = (rect.Width - rect.Width * basePosition) * 2;
                        }
                        ControlPaintEx.DrawGlass(g, glassRect, 200, 0);
                    }

                    if (drawBorder)
                    {
                        using (Pen pen = new Pen(borderColor))
                        {
                            g.DrawRectangle(pen, rect);
                        }

                        rect.Inflate(-1, -1);
                        using (Pen pen = new Pen(innerBorderColor))
                        {
                            g.DrawRectangle(pen, rect);
                        }
                    }
                }
            }
        }
        protected override void OnRenderImageMargin(ToolStripRenderEventArgs e)

        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics  g         = e.Graphics;
            Rectangle bounds    = e.AffectedBounds;

            if (toolStrip is ToolStripDropDown)
            {
                bool bDrawLogo    = NeedDrawLogo(toolStrip);
                bool bRightToLeft = toolStrip.RightToLeft == RightToLeft.Yes;

                Rectangle imageBackRect = bounds;
                imageBackRect.Width = OffsetMargin;

                if (bDrawLogo)
                {
                    Rectangle logoRect = bounds;
                    logoRect.Width = OffsetMargin;
                    if (bRightToLeft)
                    {
                        logoRect.X     -= 2;
                        imageBackRect.X = logoRect.X - OffsetMargin;
                    }
                    else
                    {
                        logoRect.X     += 2;
                        imageBackRect.X = logoRect.Right;
                    }
                    logoRect.Y      += 1;
                    logoRect.Height -= 2;

                    using (LinearGradientBrush brush = new LinearGradientBrush(
                               logoRect,
                               ColorTable.BackHover,
                               ColorTable.BackNormal,
                               90f))
                    {
                        Blend blend = new Blend();
                        blend.Positions  = new float[] { 0f, .2f, 1f };
                        blend.Factors    = new float[] { 0f, 0.1f, .9f };
                        brush.Blend      = blend;
                        logoRect.Y      += 1;
                        logoRect.Height -= 2;
                        using (GraphicsPath path =
                                   GraphicsPathHelper.CreateFilletRectangle(logoRect, 8, RoundStyle.All, false))
                        {
                            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
                            {
                                g.FillPath(brush, path);
                            }
                        }
                    }

                    StringFormat sf   = new StringFormat(StringFormatFlags.NoWrap);
                    Font         font = new Font(
                        toolStrip.Font.FontFamily, 11, FontStyle.Bold);
                    sf.Alignment     = StringAlignment.Near;
                    sf.LineAlignment = StringAlignment.Center;
                    sf.Trimming      = StringTrimming.EllipsisCharacter;

                    g.TranslateTransform(logoRect.X, logoRect.Bottom);
                    g.RotateTransform(270f);

                    if (!string.IsNullOrEmpty(MenuLogoString))
                    {
                        Rectangle newRect = new Rectangle(
                            0, 0, logoRect.Height, logoRect.Width);

                        using (Brush brush = new SolidBrush(ColorTable.Fore))
                        {
                            using (TextRenderingHintGraphics tg =
                                       new TextRenderingHintGraphics(g))
                            {
                                g.DrawString(
                                    MenuLogoString,
                                    font,
                                    brush,
                                    newRect,
                                    sf);
                            }
                        }
                    }

                    g.ResetTransform();
                }
                else
                {
                    if (bRightToLeft)
                    {
                        imageBackRect.X -= 3;
                    }
                    else
                    {
                        imageBackRect.X += 3;
                    }
                }

                imageBackRect.Y      += 2;
                imageBackRect.Height -= 4;
                using (SolidBrush brush = new SolidBrush(ColorTable.DropDownImageBack))
                {
                    g.FillRectangle(brush, imageBackRect);
                }

                Point ponitStart;
                Point pointEnd;
                if (bRightToLeft)
                {
                    ponitStart = new Point(imageBackRect.X, imageBackRect.Y);
                    pointEnd   = new Point(imageBackRect.X, imageBackRect.Bottom);
                }
                else
                {
                    ponitStart = new Point(imageBackRect.Right - 1, imageBackRect.Y);
                    pointEnd   = new Point(imageBackRect.Right - 1, imageBackRect.Bottom);
                }

                using (Pen pen = new Pen(ColorTable.DropDownImageSeparator))
                {
                    g.DrawLine(pen, ponitStart, pointEnd);
                }
            }
            else
            {
                base.OnRenderImageMargin(e);
            }
        }
Example #11
0
        protected override void OnRenderImageMargin(
            ToolStripRenderEventArgs e)
        {
            if (e.ToolStrip is ToolStripDropDownMenu)
            {
                Rectangle rect = e.AffectedBounds;
                Graphics  g    = e.Graphics;
                rect.Width = OffsetMargin;
                if (e.ToolStrip.RightToLeft == RightToLeft.Yes)
                {
                    rect.X -= 2;
                }
                else
                {
                    rect.X += 2;
                }
                rect.Y         += 1;
                rect.Height    -= 2;
                g.SmoothingMode = SmoothingMode.AntiAlias;
                using (LinearGradientBrush brush = new LinearGradientBrush(
                           rect,
                           ColorTable.BackColorHover,
                           Color.White,
                           90f))
                {
                    Blend blend = new Blend();
                    blend.Positions = new float[] { 0f, .2f, 1f };
                    blend.Factors   = new float[] { 0f, 0.1f, .9f };
                    brush.Blend     = blend;
                    rect.Y         += 1;
                    rect.Height    -= 2;
                    using (GraphicsPath path =
                               GraphicsPathHelper.CreateFilletRectangle(rect, 8, RoundStyle.All, false))
                    {
                        g.FillPath(brush, path);
                    }
                }

                g.TextRenderingHint = TextRenderingHint.AntiAlias;
                StringFormat sf   = new StringFormat(StringFormatFlags.NoWrap);
                Font         font = new Font(
                    e.ToolStrip.Font.FontFamily, 11, FontStyle.Bold);
                sf.Alignment     = StringAlignment.Near;
                sf.LineAlignment = StringAlignment.Center;
                sf.Trimming      = StringTrimming.EllipsisCharacter;

                g.TranslateTransform(rect.X, rect.Bottom);
                g.RotateTransform(270f);

                if (!string.IsNullOrEmpty(MenuLogoString))
                {
                    Rectangle newRect = new Rectangle(
                        rect.X, rect.Y, rect.Height, rect.Width);

                    using (Brush brush = new SolidBrush(ColorTable.ForeColor))
                    {
                        g.DrawString(
                            MenuLogoString,
                            font,
                            brush,
                            newRect,
                            sf);
                    }
                }

                g.ResetTransform();
                return;
            }

            base.OnRenderImageMargin(e);
        }
Example #12
0
 internal void RenderBackgroundInternal(Graphics g, Rectangle rect, Color baseColor, Color borderColor,
                                        Color innerBorderColor, RoundStyle style, int roundWidth, float basePosition, bool drawBorder, bool drawGlass, LinearGradientMode mode)
 {
     if (drawBorder)
     {
         rect.Width--;
         rect.Height--;
     }
     using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, mode))
     {
         Color[] colors = new Color[]
         {
             this.GetColor(baseColor, 0, 35, 24, 9),
             this.GetColor(baseColor, 0, 13, 8, 3),
             baseColor,
             this.GetColor(baseColor, 0, 68, 69, 54)
         };
         linearGradientBrush.InterpolationColors = new ColorBlend
         {
             Positions = new float[]
             {
                 0f,
                 basePosition,
                 basePosition + 0.05f,
                 1f
             },
             Colors = colors
         };
         if (style != RoundStyle.None)
         {
             using (GraphicsPath graphicsPath = GraphicsPathHelper.CreateFilletRectangle(rect, roundWidth, style, false))
             {
                 g.FillPath(linearGradientBrush, graphicsPath);
             }
             if (baseColor.A > 80)
             {
                 Rectangle rect2 = rect;
                 if (mode == LinearGradientMode.Vertical)
                 {
                     rect2.Height = (int)((float)rect2.Height * basePosition);
                 }
                 else
                 {
                     rect2.Width = (int)((float)rect.Width * basePosition);
                 }
                 using (GraphicsPath graphicsPath2 = GraphicsPathHelper.CreateFilletRectangle(rect2, roundWidth, RoundStyle.Top, false))
                 {
                     using (SolidBrush solidBrush = new SolidBrush(Color.FromArgb(80, 255, 255, 255)))
                     {
                         g.FillPath(solidBrush, graphicsPath2);
                     }
                 }
             }
             if (drawGlass)
             {
                 RectangleF glassRect = rect;
                 if (mode == LinearGradientMode.Vertical)
                 {
                     glassRect.Y      = (float)rect.Y + (float)rect.Height * basePosition;
                     glassRect.Height = ((float)rect.Height - (float)rect.Height * basePosition) * 2f;
                 }
                 else
                 {
                     glassRect.X     = (float)rect.X + (float)rect.Width * basePosition;
                     glassRect.Width = ((float)rect.Width - (float)rect.Width * basePosition) * 2f;
                 }
                 this.DrawGlass(g, glassRect, 170, 0);
             }
             if (drawBorder)
             {
                 using (GraphicsPath graphicsPath = GraphicsPathHelper.CreateFilletRectangle(rect, roundWidth, style, false))
                 {
                     using (Pen pen = new Pen(borderColor))
                     {
                         g.DrawPath(pen, graphicsPath);
                     }
                 }
                 rect.Inflate(-1, -1);
                 using (GraphicsPath graphicsPath = GraphicsPathHelper.CreateFilletRectangle(rect, roundWidth, style, false))
                 {
                     using (Pen pen = new Pen(innerBorderColor))
                     {
                         g.DrawPath(pen, graphicsPath);
                     }
                 }
             }
         }
         else
         {
             g.FillRectangle(linearGradientBrush, rect);
             if (baseColor.A > 80)
             {
                 Rectangle rect2 = rect;
                 if (mode == LinearGradientMode.Vertical)
                 {
                     rect2.Height = (int)((float)rect2.Height * basePosition);
                 }
                 else
                 {
                     rect2.Width = (int)((float)rect.Width * basePosition);
                 }
                 using (SolidBrush solidBrush = new SolidBrush(Color.FromArgb(80, 255, 255, 255)))
                 {
                     g.FillRectangle(solidBrush, rect2);
                 }
             }
             if (drawGlass)
             {
                 RectangleF glassRect = rect;
                 if (mode == LinearGradientMode.Vertical)
                 {
                     glassRect.Y      = (float)rect.Y + (float)rect.Height * basePosition;
                     glassRect.Height = ((float)rect.Height - (float)rect.Height * basePosition) * 2f;
                 }
                 else
                 {
                     glassRect.X     = (float)rect.X + (float)rect.Width * basePosition;
                     glassRect.Width = ((float)rect.Width - (float)rect.Width * basePosition) * 2f;
                 }
                 this.DrawGlass(g, glassRect, 200, 0);
             }
             if (drawBorder)
             {
                 using (Pen pen = new Pen(borderColor))
                 {
                     g.DrawRectangle(pen, rect);
                 }
                 rect.Inflate(-1, -1);
                 using (Pen pen = new Pen(innerBorderColor))
                 {
                     g.DrawRectangle(pen, rect);
                 }
             }
         }
     }
 }
Example #13
0
        /// <summary>
        /// 渲染内部背景.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rect">渲染的区域.</param>
        /// <param name="baseColor">基色</param>
        /// <param name="borderColor">边框颜色</param>
        /// <param name="innerBorderColor">内边框颜色.</param>
        /// <param name="style">指定圆角的风格.</param>
        /// <param name="roundWidth">指定圆角的半径</param>
        /// <param name="drawBorder"></param>
        /// <param name="drawGlass"></param>
        /// <param name="mode">指定线性渐变的方向.</param>
        /// <param name="basePosition"></param>
        public static void RenderBackgroundInternal(Graphics g, Rectangle rect, Color baseColor, Color borderColor,
                                                    Color innerBorderColor, RoundStyle style, int roundWidth, float basePosition, bool drawBorder, bool drawGlass, LinearGradientMode mode)
        {
            if (drawBorder)
            {
                rect.Width--;
                rect.Height--;
            }

            if (rect.Width == 0 || rect.Height == 0)
            {
                return;
            }

            using (LinearGradientBrush brush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, mode))
            {
                DecoratorBrush(brush, baseColor, basePosition);
                if (style != RoundStyle.None)
                {
                    using (GraphicsPath path = GraphicsPathHelper.CreateFilletRectangle(rect, roundWidth, style, false))
                    {
                        g.FillPath(brush, path);//填充区域.
                    }

                    if (baseColor.A > 80)
                    {
                        Rectangle rectTop = GetGradientModeRectangle(rect, basePosition, mode);
                        DrawTranslucence(g, rectTop, roundWidth);
                    }

                    if (drawGlass)
                    {
                        RectangleF glassRect = GetGlassRectangle(rect, basePosition, mode);
                        ControlPaintEx.DrawGlass(g, glassRect, 170, 0);
                    }

                    if (drawBorder)
                    {
                        DrawRoundBorder(g, rect, borderColor, innerBorderColor, style, roundWidth);
                    }
                }
                else
                {
                    g.FillRectangle(brush, rect);
                    if (baseColor.A > 80)
                    {
                        Rectangle rectTop = GetGradientModeRectangle(rect, basePosition, mode);

                        using (SolidBrush brushAlpha = new SolidBrush(Color.FromArgb(128, 255, 255, 255)))
                        {
                            g.FillRectangle(brushAlpha, rectTop);
                        }
                    }

                    if (drawGlass)
                    {
                        RectangleF glassRect = GetGlassRectangle(rect, basePosition, mode);
                        ControlPaintEx.DrawGlass(g, glassRect, 200, 0);
                    }

                    if (drawBorder)
                    {
                        DrawNormalBorder(g, rect, borderColor, innerBorderColor);
                    }
                }
            }
        }