public override Region CreateRegion(SkinForm form)
        {
            var rect = new Rectangle(Point.Empty, form.Size);

            using (GraphicsPath path = GraphicsHelper.CreatePath(rect, form.Radius, form.RoundStyle, false))
            {
                return(new Region(path));
            }
        }
 public static void CreateRegion(Control control, Rectangle bounds, int radius, RoundStyle roundStyle)
 {
     using (GraphicsPath path =
                GraphicsHelper.CreatePath(
                    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;
     }
 }
        protected override void OnRenderGroundFormBackground(FormBackgroundRenderEventArgs e)
        {
            Graphics  g    = e.Graphics;
            Rectangle rect = e.ClipRectangle;
            SkinForm  form = e.Form;

            using (SmoothingModeGraphics antiGraphics = new SmoothingModeGraphics(g))
            {
                using (Brush brush = new SolidBrush(StyleSet.BaseColor))
                {
                    using (GraphicsPath path = GraphicsHelper.CreatePath(
                               rect, form.Radius, form.RoundStyle, false))
                    {
                        g.FillPath(brush, path);
                    }
                }
            }
        }
        private void DrawBorder(Graphics g, Rectangle rect, RoundStyle roundStyle, int radius)
        {
            rect.Width  -= 1;
            rect.Height -= 1;
            using (GraphicsPath path = GraphicsHelper.CreatePath(rect, radius, roundStyle, false))
            {
                using (Pen pen = new Pen(StyleSet.FormBorderColor))
                {
                    g.DrawPath(pen, path);
                }
            }

            rect.Inflate(-1, -1);
            using (GraphicsPath path = GraphicsHelper.CreatePath(rect, radius, roundStyle, false))
            {
                using (Pen pen = new Pen(StyleSet.FormInnerBorderColor))
                {
                    g.DrawPath(pen, path);
                }
            }
        }
        protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics  graphics  = e.Graphics;
            Rectangle bounds    = e.AffectedBounds;

            if (toolStrip is ToolStripDropDown)
            {
                using (SmoothingModeGraphics sg = new SmoothingModeGraphics(graphics))
                {
                    using (GraphicsPath path = GraphicsHelper.CreatePath(bounds, 8, RoundStyle.All, true))
                    {
                        using (Pen pen = new Pen(StyleSet.ToolStripDropDownBorderColor))
                        //using (Pen pen = new Pen(Color.Red))
                        {
                            path.Widen(pen);
                            graphics.DrawPath(pen, path);
                        }
                    }
                }

                if (!(toolStrip is ToolStripOverflow))
                {
                    bounds.Inflate(-1, -1);
                    using (GraphicsPath innerPath = GraphicsHelper.CreatePath(
                               bounds, 8, RoundStyle.All, true))
                    {
                        using (Pen pen = new Pen(StyleSet.HeadToolStripItemInnerBorderColor))
                        {
                            graphics.DrawPath(pen, innerPath);
                        }
                    }
                }
            }
            else
            {
                base.OnRenderToolStripBorder(e);
            }
        }
Beispiel #6
0
        public static void DrawBackground(
            System.Drawing.Graphics g,
            Rectangle rect,
            Color baseColor,
            Color borderColor,
            Color innerBorderColor,
            RoundStyle style,
            int roundWidth,
            float basePosition,
            bool ifDrawBorder,
            bool ifDrawGlass,
            LinearGradientMode mode)
        {
            if (ifDrawBorder)
            {
                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, 35, 24, 9);

                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 =
                               GraphicsHelper.CreatePath(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 = GraphicsHelper.CreatePath(
                                   rectTop, roundWidth, RoundStyle.Top, false))
                        {
                            using (SolidBrush brushAlpha =
                                       new SolidBrush(Color.FromArgb(128, 255, 255, 255)))
                            {
                                g.FillPath(brushAlpha, pathTop);
                            }
                        }
                    }

                    if (ifDrawGlass)
                    {
                        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;
                        }
                        GraphicsHelper.DrawGlass(g, glassRect, 170, 0);
                    }

                    if (ifDrawBorder)
                    {
                        using (GraphicsPath path =
                                   GraphicsHelper.CreatePath(rect, roundWidth, style, false))
                        {
                            using (Pen pen = new Pen(borderColor))
                            {
                                g.DrawPath(pen, path);
                            }
                        }

                        rect.Inflate(-1, -1);
                        using (GraphicsPath path =
                                   GraphicsHelper.CreatePath(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(128, 255, 255, 255)))
                        {
                            g.FillRectangle(brushAlpha, rectTop);
                        }
                    }

                    if (ifDrawGlass)
                    {
                        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;
                        }
                        GraphicsHelper.DrawGlass(g, glassRect, 200, 0);
                    }

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

                        rect.Inflate(-1, -1);
                        using (Pen pen = new Pen(innerBorderColor))
                        {
                            g.DrawRectangle(pen, rect);
                        }
                    }
                }
            }
        }