//画自定义系统按钮集合
        private void RenderSkinFormCmSysBottomInternal(Graphics g, Rectangle rect, ControlBoxState state, bool active, CCSkinMain form, CmSysButton cmSysButton)
        {
            Bitmap btm       = null;
            Color  baseColor = ColorTable.ControlBoxActive;

            if (cmSysButton.BoxState == ControlBoxState.Pressed)
            {
                btm       = (Bitmap)cmSysButton.SysButtonDown;
                baseColor = ColorTable.ControlBoxPressed;
            }
            else if (state == ControlBoxState.Hover)
            {
                btm       = (Bitmap)cmSysButton.SysButtonMouse;
                baseColor = ColorTable.ControlBoxHover;
            }
            else
            {
                btm       = (Bitmap)cmSysButton.SysButtonNorml;
                baseColor = active ?
                            ColorTable.ControlBoxActive :
                            ColorTable.ControlBoxDeactive;
            }

            //绘制图片样式
            if (btm != null)
            {
                g.DrawImage(btm, rect);
            }
            else //绘制默认样式
            {
                RoundStyle roundStyle = 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);
                    }
                }
            }
        }
        //画边框
        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,
                    e.SkinForm);
            }
        }
        //画标题和ICO
        protected override void OnRenderSkinFormCaption(
            SkinFormCaptionRenderEventArgs e)
        {
            Graphics   g        = e.Graphics;
            Rectangle  rect     = e.ClipRectangle;
            CCSkinMain 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.MaxSize.Width + form.ControlBoxSpace;
            }

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

            foreach (CmSysButton item in form.ControlBoxManager.SysButtonItems)
            {
                if (form.ControlBox && item.Visibale)
                {
                    textWidthDec += item.Size.Width + form.ControlBoxSpace;
                }
            }

            textRect = new Rectangle(
                iconRect.Right + 3,
                form.BorderPadding.Left,
                rect.Width - iconRect.Right - textWidthDec - 6,
                rect.Height - form.BorderPadding.Left);

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

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

                if (!string.IsNullOrEmpty(form.Text))
                {
                    Color EfColor    = form.EffectBack;
                    Color TitleColor = form.TitleColor;
                    //判断是否根据背景色适应颜色
                    if (form.TitleSuitColor)
                    {
                        //如果背景色为暗色
                        if (SkinTools.ColorSlantsDarkOrBright(form.BackColor))
                        {
                            TitleColor = Color.White;
                            EfColor    = Color.Black;
                        }
                        else//如果背景色为亮色
                        {
                            TitleColor = Color.Black;
                            EfColor    = Color.White;
                        }
                    }
                    DrawCaptionText(
                        g,
                        textRect,
                        form.Text,
                        form.CaptionFont,
                        form.EffectCaption,
                        EfColor,
                        form.EffectWidth,
                        TitleColor,
                        form.TitleOffset);
                }
            }
        }
        //画关闭按钮
        private void RenderSkinFormCloseBoxInternal(
            Graphics g,
            Rectangle rect,
            ControlBoxState state,
            bool active,
            bool minimizeBox,
            bool maximizeBox,
            CCSkinMain form)
        {
            Bitmap btm       = null;
            Color  baseColor = ColorTable.ControlBoxActive;

            if (state == ControlBoxState.Pressed)
            {
                btm       = (Bitmap)form.CloseDownBack;
                baseColor = ColorTable.ControlCloseBoxPressed;
            }
            else if (state == ControlBoxState.Hover)
            {
                btm       = (Bitmap)form.CloseMouseBack;
                baseColor = ColorTable.ControlCloseBoxHover;
            }
            else
            {
                btm       = (Bitmap)form.CloseNormlBack;
                baseColor = active ?
                            ColorTable.ControlBoxActive :
                            ColorTable.ControlBoxDeactive;
            }
            //绘制图片样式
            if (btm != null)
            {
                g.DrawImage(btm, 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 = CreateCloseFlagPath(rect))
                    {
                        g.FillPath(Brushes.White, path);
                        using (Pen pen = new Pen(baseColor))
                        {
                            g.DrawPath(pen, path);
                        }
                    }
                }
            }
        }
        //画最小化按钮
        private void RenderSkinFormMinimizeBoxInternal(
            Graphics g,
            Rectangle rect,
            ControlBoxState state,
            bool active,
            CCSkinMain form)
        {
            Bitmap btm = null;
            Color baseColor = ColorTable.ControlBoxActive;

            if (state == ControlBoxState.Pressed)
            {
                btm = (Bitmap)form.MiniDownBack;
                baseColor = ColorTable.ControlBoxPressed;
            }
            else if (state == ControlBoxState.Hover)
            {
                btm = (Bitmap)form.MiniMouseBack;
                baseColor = ColorTable.ControlBoxHover;
            }
            else
            {
                btm = (Bitmap)form.MiniNormlBack;
                baseColor = active ?
                    ColorTable.ControlBoxActive :
                    ColorTable.ControlBoxDeactive;
            }
            //绘制图片样式
            if (btm != null)
            {
                g.DrawImage(btm, rect);
            }
            else //绘制默认样式
            {
                RoundStyle roundStyle = RoundStyle.BottomLeft;
                //g.DrawImage(btm,rect);
                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 = CreateMinimizeFlagPath(rect))
                    {
                        g.FillPath(Brushes.White, path);
                        using (Pen pen = new Pen(baseColor))
                        {
                            g.DrawPath(pen, path);
                        }
                    }
                }
            }
        }
        //画自定义系统按钮集合
        private void RenderSkinFormCmSysBottomInternal(Graphics g, Rectangle rect, ControlBoxState state, bool active, CCSkinMain form, CmSysButton cmSysButton)
        {
            Bitmap btm = null;
            Color baseColor = ColorTable.ControlBoxActive;

            if (cmSysButton.BoxState == ControlBoxState.Pressed)
            {
                btm = (Bitmap)cmSysButton.SysButtonDown;
                baseColor = ColorTable.ControlBoxPressed;
            }
            else if (state == ControlBoxState.Hover)
            {
                btm = (Bitmap)cmSysButton.SysButtonMouse;
                baseColor = ColorTable.ControlBoxHover;
            }
            else
            {
                btm = (Bitmap)cmSysButton.SysButtonNorml;
                baseColor = active ?
                    ColorTable.ControlBoxActive :
                    ColorTable.ControlBoxDeactive;
            }

            //绘制图片样式
            if (btm != null)
            {
                g.DrawImage(btm, rect);
            }
            else //绘制默认样式
            {
                RoundStyle roundStyle = 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);
                    }
                }
            }
        }
        //画标题和ICO
        protected override void OnRenderSkinFormCaption(
            SkinFormCaptionRenderEventArgs e)
        {
            Graphics g = e.Graphics;
            Rectangle rect = e.ClipRectangle;
            CCSkinMain 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.MaxSize.Width + form.ControlBoxSpace;
            }

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

            foreach (CmSysButton item in form.ControlBoxManager.SysButtonItems)
            {
                if (form.ControlBox && item.Visibale)
                {
                    textWidthDec += item.Size.Width + form.ControlBoxSpace;
                }
            }

            textRect = new Rectangle(
                iconRect.Right + 3,
                form.BorderPadding.Left,
                rect.Width - iconRect.Right - textWidthDec - 6,
                rect.Height - form.BorderPadding.Left);

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

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

                if (!string.IsNullOrEmpty(form.Text))
                {
                    Color EfColor = form.EffectBack;
                    Color TitleColor = form.TitleColor;
                    //判断是否根据背景色适应颜色
                    if (form.TitleSuitColor)
                    {
                        //如果背景色为暗色
                        if (SkinTools.ColorSlantsDarkOrBright(form.BackColor))
                        {
                            TitleColor = Color.White;
                            EfColor = Color.Black;
                        }
                        else//如果背景色为亮色
                        {
                            TitleColor = Color.Black;
                            EfColor = Color.White;
                        }
                    }
                    DrawCaptionText(
                        g,
                        textRect,
                        form.Text,
                        form.CaptionFont,
                        form.EffectCaption,
                        EfColor,
                        form.EffectWidth,
                        TitleColor,
                        form.TitleOffset);
                }
            }
        }
 //画边框
 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,
             e.SkinForm);
     }
 }