protected override void OnRenderSkinFormBorder(SkinFormBorderRenderEventArgs e)
 {
     Graphics g = e.Graphics;
     using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g))
     {
         DrawBorder(
             g,
             e.ClipRectangle,
             e.SkinForm.RoundStyle,
             e.SkinForm.Radius);
     }
 }
        /// <summary>
        /// 呈现窗体的标题
        /// </summary>
        /// <param name="e"></param>
        protected override void OnRenderSkinFormCaption(SkinFormCaptionRenderEventArgs e)
        {
            Graphics g = e.Graphics;
            Rectangle rect = e.ClipRectangle;//标题栏的矩形
            SkinForm form = e.SkinForm;
            Rectangle iconRect = form.IconRect;
            Rectangle textRect = Rectangle.Empty;

            bool closeBox = form.ControlBox;
            bool minimizeBox = form.ControlBox && form.MinimizeBox;
            bool maximizeBox = form.ControlBox && form.MaximizeBox;

            int textWidthDec = 0;
            if (closeBox)
            {
                textWidthDec += form.CloseBoxSize.Width + form.ControlBoxOffset.X;
            }

            if (maximizeBox)
            {
                textWidthDec += form.MaximizeBoxSize.Width + form.ControlBoxSpace;
            }

            if (minimizeBox)
            {
                textWidthDec += form.MinimizeBoxSize.Width + form.ControlBoxSpace;
            }

            int textRectHeight = form.IconRect.Height; //form.BorderWidth + (int)form.CaptionFont.GetHeight() + 2;
            if (form.ShowIcon == false)
            {
                textRectHeight = form.BorderWidth + (int)form.CaptionFont.GetHeight() + 2;
            }
            textRect = new Rectangle(
                iconRect.Right + 3,
                form.BorderWidth,
                rect.Width - iconRect.Right - textWidthDec - 6,
                textRectHeight );

            using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g))
            {
                DrawCaptionBackground(
                   g,
                   rect,                  
                   e.Active,
                    e.BackColor,
                    e.BackImage);

                if (form.ShowIcon && form.Icon != null)
                {
                    DrawIcon(g, iconRect, form.Icon);
                }

                if (!string.IsNullOrEmpty(form.Text))
                {
                    DrawCaptionText(
                        g,
                        textRect,
                        form.Text,                      
                        form.CaptionFont,
                        form.ForeColor);
                }
            }
        }
        private void RenderSkinFormCloseBoxInternal(
           Graphics g,
           Rectangle rect,
           ControlBoxState state,
           bool active,
           bool minimizeBox,
           bool maximizeBox,
           SkinForm form)
        {
            Bitmap image = null;
            Color baseColor = ColorTable.ControlBoxActive;
            SkinPictureForm imageForm = (SkinPictureForm) form;
            
            if (state == ControlBoxState.Pressed)
            {
                image = (Bitmap)imageForm.CloseDownBack;
                baseColor = ColorTable.ControlCloseBoxPressed;
            }
            else if (state == ControlBoxState.Hover)
            {
                image = (Bitmap)imageForm.CloseMouseBack;
                baseColor = ColorTable.ControlCloseBoxHover;
            }
            else
            {
                image = (Bitmap)imageForm.CloseNormlBack;
                baseColor = active ? ColorTable.ControlBoxActive : ColorTable.ControlBoxDeactive;
            }

            if (image != null)
            {
                g.DrawImage(image , rect );
            }
            else
            {
                RoundStyle roundStyle = minimizeBox || maximizeBox ?
                    RoundStyle.BottomRight : RoundStyle.Bottom;

                using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g))
                {
                    RenderHelper.RenderBackgroundInternal(
                        g,
                        rect,
                        baseColor,
                        baseColor,
                        ColorTable.ControlBoxInnerBorder,
                        roundStyle,
                        6,
                        .38F,
                        true,
                        false,
                        LinearGradientMode.Vertical);

                    using (Pen pen = new Pen(ColorTable.Border))
                    {
                        g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);
                    }

                    using (GraphicsPath path = DrawUtil.CreateCloseFlagPath(rect))
                    {
                        g.FillPath(Brushes.White, path);
                        using (Pen pen = new Pen(baseColor))
                        {
                            g.DrawPath(pen, path);
                        }
                    }
                }
            }
        }
        private void DrawFormBackground(Graphics g, Rectangle rect , int radius , RoundStyle style)
        {
            using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g))
            {
                Image formImage = ColorTable.CaptionBackground;
                if (formImage == null) return;
                g.SmoothingMode = SmoothingMode.AntiAlias;
                //g.CompositingQuality = CompositingQuality.HighQuality;
                //g.DrawImage(formImage, rect );


                using (Brush brush = new TextureBrush(formImage , WrapMode.Clamp))
                {
                    rect.X -= 1;
                    rect.Y -= 1;
                    rect.Width += 1;
                    rect.Height += 1;
                    using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                       rect, radius, style, false))
                    {
                        g.FillPath(brush, path);
                    }
                }
            }
            
        }
        private void RenderSkinFormMaximizeBoxInternal(
            Graphics g,
            Rectangle rect,
            ControlBoxState state,
            bool active,
            bool minimizeBox,
            bool maximize)
        {
            Color baseColor = ColorTable.ControlBoxActive;

            if (state == ControlBoxState.Pressed)
            {
                baseColor = ColorTable.ControlBoxPressed;
            }
            else if (state == ControlBoxState.Hover)
            {
                baseColor = ColorTable.ControlBoxHover;
            }
            else
            {
                baseColor = active ?
                    ColorTable.ControlBoxActive :
                    ColorTable.ControlBoxDeactive;
            }

            RoundStyle roundStyle = minimizeBox ?
                RoundStyle.None : RoundStyle.BottomLeft;

            using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g))
            {
                RenderHelper.RenderBackgroundInternal(
                    g,
                    rect,
                    baseColor,
                    baseColor,
                    ColorTable.ControlBoxInnerBorder,
                    roundStyle,
                    6,
                    .38F,
                    true,
                    false,
                    LinearGradientMode.Vertical);

                using (Pen pen = new Pen(ColorTable.Border))
                {
                    g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);
                }

                using (GraphicsPath path = DrawUtil.CreateMaximizeFlafPath(rect, maximize))
                {
                    g.FillPath(Brushes.White, path);
                    using (Pen pen = new Pen(baseColor))
                    {
                        g.DrawPath(pen, path);
                    }
                }
            }
        }
 protected override void OnRenderSkinFormBackground(
     SkinFormBackgroundRenderEventArgs e)
 {
     Graphics g = e.Graphics;
     Rectangle rect = e.ClipRectangle;
     SkinForm form = e.SkinForm;
     using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g))
     {
         using (Brush brush = new SolidBrush(ColorTable.Back))
         {
             using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                 rect, form.Radius, form.RoundStyle, false))
             {
                 g.FillPath(brush, path);
             }
         }
     }
 }