Beispiel #1
0
 private void RenderBorder(System.Drawing.Graphics g, Rectangle bounds)
 {
     if (RoundStyle == RoundStyle.None)
     {
         ControlPaint.DrawBorder(
             g,
             bounds,
             ColorTable.Border,
             ButtonBorderStyle.Solid);
     }
     else
     {
         using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
         {
             using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                 bounds, Radius, RoundStyle, true))
             {
                 using (Pen pen = new Pen(ColorTable.Border))
                 {
                     g.DrawPath(pen, path);
                 }
             }
         }
     }
 }
        protected override void OnPaintCaption(PaintEventArgs e)
        {
            System.Drawing.Graphics g = e.Graphics;
            Rectangle captionRect = CaptionRect;
            LinearGradientMode gradientMode = LinearGradientMode.Vertical;
            RoundStyle roundStyle = RoundStyle.None;

            Color backColor;
            switch (CaptionState)
            {
                case ControlState.Hover:
                    backColor = ColorTable.CaptionBackHover;
                    break;
                case ControlState.Pressed:
                    backColor = ColorTable.CaptionBackPressed;
                    break;
                default:
                    backColor = ColorTable.CaptionBackNormal;
                    break;
            }

            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
            {
                RenderHelper.RenderBackgroundInternal(
                    g,
                    captionRect,
                    backColor,
                    ColorTable.Border,
                    Color.White,
                    roundStyle,
                    Radius,
                    true,
                    true,
                    gradientMode);
            }

            RenderImageAndText(g, captionRect);

            RenderBorder(g, base.ClientRectangle);
        }
        protected internal virtual void OnPaintScrollBarArrow(
           PaintScrollBarArrowEventArgs e)
        {
            System.Drawing.Graphics g = e.Graphics;
            Rectangle rect = e.ArrowRectangle;
            ControlState controlState = e.ControlState;
            ArrowDirection direction = e.ArrowDirection;
            bool bHorizontal = e.Orientation == Orientation.Horizontal;
            bool bEnabled = e.Enabled;

            Color backColor = ColorTable.BackNormal;
            Color baseColor = ColorTable.Base;
            Color borderColor = ColorTable.Border;
            Color innerBorderColor = ColorTable.InnerBorder;
            Color foreColor = ColorTable.Fore;

            bool changeColor = false;

            if (bEnabled)
            {
                switch (controlState)
                {
                    case ControlState.Hover:
                        baseColor = ColorTable.BackHover;
                        break;
                    case ControlState.Pressed:
                        baseColor = ColorTable.BackPressed;
                        changeColor = true;
                        break;
                    default:
                        baseColor = ColorTable.Base;
                        break;
                }
            }
            else
            {
                backColor = GetGray(backColor);
                baseColor = GetGray(ColorTable.Base);
                borderColor = GetGray(borderColor);
                foreColor = GetGray(foreColor);
            }

            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
            {
                ControlPaintEx.DrawScrollBarArraw(
                    g,
                    rect,
                    baseColor,
                    backColor,
                    borderColor,
                    innerBorderColor,
                    foreColor,
                    e.Orientation,
                    direction,
                    changeColor);
            }
        }
Beispiel #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);

            Graphics g = e.Graphics;


            #region 画客户区


            using (GraphicsPath path =
                       GraphicsPathHelper.CreatePath(ClientRectangle, Radius, RoundStyle, false))
            {
                g.SetClip(path);

                if (controlSchema.BackNormalStyle.Color2 != Color.Empty &&
                    controlSchema.BackNormalStyle.Color1 != controlSchema.BackNormalStyle.Color2)
                {
                    if (DisplayRectangle.Width > 0 && DisplayRectangle.Height > 0)
                    {
                        using (LinearGradientBrush br = new LinearGradientBrush(DisplayRectangle, controlSchema.BackNormalStyle.Color1, controlSchema.BackNormalStyle.Color2, controlSchema.BackNormalStyle.Mode))
                        {
                            g.FillPath(br, path);
                            //g.FillRectangle(br, DisplayRectangle);
                        }
                    }
                }
                else
                {
                    using (SolidBrush br = new SolidBrush(controlSchema.BackNormalStyle.Color1))
                    {
                        g.FillPath(br, path);
                        //g.FillRectangle(br, DisplayRectangle);
                    }
                }
            }



            #region 画背景图片
            if (BackgroundImage != null)
            {
                switch (BackgroundImageLayout)
                {
                case ImageLayout.None:
                    g.DrawImageUnscaled(BackgroundImage,
                                        DisplayRectangle.X,
                                        DisplayRectangle.Y,
                                        BackgroundImage.Width,
                                        BackgroundImage.Height);
                    break;

                case ImageLayout.Tile:
                    using (TextureBrush Txbrus = new TextureBrush(BackgroundImage))
                    {
                        Txbrus.WrapMode = WrapMode.Tile;

                        g.FillRectangle(Txbrus, new Rectangle(0, 0, DisplayRectangle.Width - 1, DisplayRectangle.Height - 1));
                    }
                    break;

                case ImageLayout.Center:

                    int xx = (DisplayRectangle.Width - BackgroundImage.Width) / 2;
                    int yy = (DisplayRectangle.Height - BackgroundImage.Height) / 2;
                    g.DrawImage(BackgroundImage, new Rectangle(xx, yy, BackgroundImage.Width, BackgroundImage.Height), new Rectangle(0, 0, BackgroundImage.Width, BackgroundImage.Height), GraphicsUnit.Pixel);



                    break;

                case ImageLayout.Stretch:

                    g.DrawImage(BackgroundImage, new Rectangle(0, 0, DisplayRectangle.Width, DisplayRectangle.Height), new Rectangle(0, 0, BackgroundImage.Width, BackgroundImage.Height), GraphicsUnit.Pixel);


                    break;

                case ImageLayout.Zoom:
                {
                    double tm = 0.0;
                    int    W  = BackgroundImage.Width;
                    int    H  = BackgroundImage.Height;
                    if (W > DisplayRectangle.Width)
                    {
                        tm = DisplayRectangle.Width / BackgroundImage.Width;
                        W  = (int)(W * tm);
                        H  = (int)(H * tm);
                    }
                    if (H > DisplayRectangle.Height)
                    {
                        tm = DisplayRectangle.Height / H;
                        W  = (int)(W * tm);
                        H  = (int)(H * tm);
                    }
                    using (Bitmap tmpBP = new Bitmap(W, H))
                    {
                        using (Graphics G2 = Graphics.FromImage(tmpBP))
                        {
                            G2.DrawImage(BackgroundImage, new Rectangle(0, 0, W, H), new Rectangle(0, 0, BackgroundImage.Width, BackgroundImage.Height), GraphicsUnit.Pixel);

                            int xxx = (DisplayRectangle.Width - W) / 2;
                            int yyy = (DisplayRectangle.Height - H) / 2;
                            g.DrawImage(tmpBP, new Rectangle(xxx, yyy, W, H), new Rectangle(0, 0, W, H), GraphicsUnit.Pixel);
                        }
                    }
                }
                break;
                }
            }

            #endregion


            #endregion

            #region 画标题
            OnPaintCaption(e);
            #endregion


            #region 画border
            using (SmoothingModeGraphics sgr = new SmoothingModeGraphics(g))
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;

                Rectangle r = ClientRectangle;
                //r.Width -= 1;
                //r.Height -= 1;
                using (GraphicsPath path =
                           GraphicsPathHelper.CreatePath(r, Radius, RoundStyle, true))
                {
                    using (Pen p = new Pen(controlSchema.BorderNormalStyle.Color1))
                    {
                        g.DrawPath(p, path);
                    }
                }

                if (controlSchema.BorderNormalStyle.Color2 != Color.Empty &&
                    controlSchema.BorderNormalStyle.Color2 != controlSchema.BorderNormalStyle.Color1)
                {
                    r.Inflate(-1, -1);
                    using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                               r, radius, roundStyle, true))
                    {
                        using (Pen pen = new Pen(controlSchema.BorderNormalStyle.Color2))
                        {
                            g.DrawPath(pen, path);
                        }
                    }
                }
            }
            #endregion
        }
        protected internal virtual void OnPaintScrollBarThumb(
           PaintScrollBarThumbEventArgs e)
        {
            bool bEnabled = e.Enabled;
            if (!bEnabled)
            {
                return;
            }

            System.Drawing.Graphics g = e.Graphics;
            Rectangle rect = e.ThumbRectangle;
            ControlState controlState = e.ControlState;

            Color backColor = ColorTable.BackNormal;
            Color baseColor = ColorTable.Base;
            Color borderColor = ColorTable.Border;
            Color innerBorderColor = ColorTable.InnerBorder;

            bool changeColor = false;

            switch (controlState)
            {
                case ControlState.Hover:
                    baseColor = ColorTable.BackHover;
                    break;
                case ControlState.Pressed:
                    baseColor = ColorTable.BackPressed;
                    changeColor = true;
                    break;
                default:
                    baseColor = ColorTable.Base;
                    break;
            }

            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
            {
                ControlPaintEx.DrawScrollBarThumb(
                    g,
                    rect,
                    baseColor,
                    backColor,
                    borderColor,
                    innerBorderColor,
                    e.Orientation,
                    changeColor);
            }
        }
        protected virtual void OnPaintCaption(PaintEventArgs e)
        {
            System.Drawing.Graphics g = e.Graphics;
            Rectangle captionRect = CaptionRect;
            LinearGradientMode gradientMode = LinearGradientMode.Vertical;
            RoundStyle roundStyle = RoundStyle.None;

            switch (_captionStyle)
            {
                case CaptionStyle.Top:
                    roundStyle = RoundStyle & RoundStyle.Top;
                    break;
                case CaptionStyle.Left:
                    gradientMode = LinearGradientMode.Horizontal;
                    roundStyle = RoundStyle & RoundStyle.Left;
                    break;
                case CaptionStyle.Bottom:
                    roundStyle = RoundStyle & RoundStyle.Bottom;
                    break;
                case CaptionStyle.Right:
                    gradientMode = LinearGradientMode.Horizontal;
                    roundStyle = RoundStyle & RoundStyle.Right;
                    break;
            }

            if (!_showBorder)
            {
                roundStyle = RoundStyle.All;
            }

            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
            {
                RenderHelper.RenderBackgroundInternal(
                    g,
                    captionRect,
                    ColorTable.CaptionBackNormal,
                    ColorTable.Border,
                    Color.White,
                    roundStyle,
                    Radius,
                    true,
                    true,
                    gradientMode);
            }

            RenderImageAndText(g, captionRect);

            RenderBorder(g, base.ClientRectangle);
        }
        private void DrawProgressBar(IntPtr hWnd)
        {
            System.Drawing.Graphics g = _bufferedGraphics.Graphics;
            Rectangle rect = new Rectangle(Point.Empty, Size);
            ProgressBarColorTable colorTable = ColorTable;

            bool bBlock = Style != ProgressBarStyle.Marquee || base.DesignMode;
            float basePosition = bBlock ? .30f : .45f;

            SmoothingModeGraphics sg = new SmoothingModeGraphics(g);

            RenderHelper.RenderBackgroundInternal(
                g,
                rect,
                colorTable.TrackBack,
                colorTable.Border,
                colorTable.InnerBorder,
                RoundStyle.All,
                8,
                basePosition,
                true,
                true,
                LinearGradientMode.Vertical);

            Rectangle trackRect = rect;
            trackRect.Inflate(-2, -2);

            if (bBlock)
            {
                trackRect.Width = (int)(((double)Value / (Maximum - Minimum)) * trackRect.Width);

                RenderHelper.RenderBackgroundInternal(
                    g,
                    trackRect,
                    colorTable.TrackFore,
                    colorTable.Border,
                    colorTable.InnerBorder,
                    RoundStyle.All,
                    8,
                    basePosition,
                    false,
                    true,
                    LinearGradientMode.Vertical);

                if (!string.IsNullOrEmpty(_formatString))
                {
                    TextRenderer.DrawText(
                        g,
                        string.Format(_formatString, (double)Value / (Maximum - Minimum)),
                        base.Font,
                        rect,
                        base.ForeColor,
                        TextFormatFlags.VerticalCenter |
                        TextFormatFlags.HorizontalCenter |
                        TextFormatFlags.SingleLine |
                        TextFormatFlags.WordEllipsis);
                }
            }
            else
            {
                GraphicsState state = g.Save();

                g.SetClip(trackRect);

                trackRect.X = _trackX;
                trackRect.Width = MarqueeWidth;

                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddEllipse(trackRect);
                    g.SetClip(path, CombineMode.Intersect);
                }

                RenderHelper.RenderBackgroundInternal(
                    g,
                    trackRect,
                    colorTable.TrackFore,
                    colorTable.Border,
                    colorTable.InnerBorder,
                    RoundStyle.None,
                    8,
                    basePosition,
                    false,
                    false,
                    LinearGradientMode.Vertical);

                using (LinearGradientBrush brush = new LinearGradientBrush(
                    trackRect, colorTable.InnerBorder, Color.Transparent, 0f))
                {
                    Blend blend = new Blend();
                    blend.Factors = new float[] { 0f, 1f, 0f };
                    blend.Positions = new float[] { 0f, .5f, 1f };
                    brush.Blend = blend;

                    g.FillRectangle(brush, trackRect);
                }

                g.Restore(state);
            }

            sg.Dispose();

            IntPtr hDC = NativeMethods.GetDC(hWnd);
            _bufferedGraphics.Render(hDC);
            NativeMethods.ReleaseDC(hWnd, hDC);
        }
        internal void RenderBorder(System.Drawing.Graphics g, Rectangle bounds)
        {
            switch (_captionStyle)
            {
                case CaptionStyle.Top:
                case CaptionStyle.Bottom:
                    if (base.Height <= _captionHeight)
                    {
                        return;
                    }
                    break;
                case CaptionStyle.Left:
                case CaptionStyle.Right:
                    if (base.Width <= _captionHeight)
                    {
                        return;
                    }
                    break;
            }

            if (_showBorder)
            {
                if (RoundStyle == RoundStyle.None)
                {
                    ControlPaint.DrawBorder(
                        g,
                        bounds,
                        ColorTable.Border,
                        ButtonBorderStyle.Solid);
                }
                else
                {
                    using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
                    {
                        using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                            bounds, Radius, RoundStyle, true))
                        {
                            using (Pen pen = new Pen(ColorTable.Border))
                            {
                                g.DrawPath(pen, path);
                            }
                        }
                    }
                }
            }
        }
Beispiel #9
0
        protected virtual void OnRenderThumb(PaintThumbEventArgs e)
        {
            System.Drawing.Graphics g = e.Graphics;
            Rectangle rect = e.ClipRectangle;
            ControlState state = e.ControlState;
            ThumbArrowDirection direction = ThumbArrowDirection.None;
            Color begin = ColorTable.ThumbBackNormal;
            Color end = ColorTable.TrackInnerBorder;
            Color border = ColorTable.ThumbBorderNormal;
            float mode =
               base.Orientation == Orientation.Horizontal ?
               90f : 0f;

            switch (base.Orientation)
            {
                case Orientation.Horizontal:
                    switch (base.TickStyle)
                    {
                        case TickStyle.None:
                        case TickStyle.BottomRight:
                            direction = ThumbArrowDirection.Down;
                            break;
                        case TickStyle.TopLeft:
                            direction = ThumbArrowDirection.Up;
                            break;
                        case TickStyle.Both:
                            direction = ThumbArrowDirection.None;
                            break;
                    }
                    break;
                case Orientation.Vertical:
                    switch (base.TickStyle)
                    {
                        case TickStyle.TopLeft:
                            direction = ThumbArrowDirection.Left;
                            break;
                        case TickStyle.None:
                        case TickStyle.BottomRight:
                            direction = ThumbArrowDirection.Right;
                            break;
                        case TickStyle.Both:
                            direction = ThumbArrowDirection.None;
                            break;
                    }
                    break;
            }

            switch (state)
            {
                case ControlState.Hover:
                    begin = ColorTable.ThumbBackHover;
                    border = ColorTable.ThumbBorderHover;
                    break;
            }

            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
            {
                using (GraphicsPath path =
                    GraphicsPathHelper.CreateTrackBarThumbPath(
                    rect, direction))
                {
                    using (LinearGradientBrush brush = new LinearGradientBrush(
                        rect, begin, end, mode))
                    {
                        Blend blend = new Blend();
                        blend.Positions = new float[] { 0, .2f, .5f, .8f, 1f };
                        blend.Factors = new float[] { 1f, .7f, 0, .7f, 1f };
                        brush.Blend = blend;

                        g.FillPath(brush, path);
                    }
                    using (Pen pen = new Pen(border))
                    {
                        g.DrawPath(pen, path);
                    }
                }

                rect.Inflate(-1, -1);
                using (GraphicsPath path =
                   GraphicsPathHelper.CreateTrackBarThumbPath(
                   rect, direction))
                {
                    using (Pen pen = new Pen(ColorTable.TrackInnerBorder))
                    {
                        g.DrawPath(pen, path);
                    }
                }
            }
        }
Beispiel #10
0
        protected virtual void OnRenderTrack(PaintEventArgs e)
        {
            System.Drawing.Graphics g = e.Graphics;
            Rectangle rect = e.ClipRectangle;
            bool horizontal = base.Orientation == Orientation.Horizontal;
            float mode = horizontal ? 0f : 270f;

            if (horizontal)
            {
                rect.Inflate(0, 1);
            }
            else
            {
                 rect.Inflate(1, 0);
            }

            SmoothingModeGraphics sg = new SmoothingModeGraphics(g);

            using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                rect, 4, RoundStyle.All, true))
            {
                using (LinearGradientBrush brush = new LinearGradientBrush(
                    rect, ColorTable.TrackBegin, ColorTable.TrackEnd, mode))
                {
                    g.FillPath(brush, path);
                }

                using (Pen pen = new Pen(ColorTable.TrackBorder))
                {
                    g.DrawPath(pen, path);
                }
            }

            rect.Inflate(-1, -1);
            using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                rect, 4, RoundStyle.All, true))
            {
                using (Pen pen = new Pen(ColorTable.TrackInnerBorder))
                {
                    g.DrawPath(pen, path);
                }
            }

            sg.Dispose();
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (base.Panel1Collapsed || base.Panel2Collapsed)
            {
                return;
            }

            Graphics g = e.Graphics;
            Rectangle rect = base.SplitterRectangle;
            bool bHorizontal = base.Orientation == Orientation.Horizontal;

            LinearGradientMode gradientMode = bHorizontal ?
                LinearGradientMode.Vertical : LinearGradientMode.Horizontal;

            if (SpliterPanelState == SpliterPanelState.Expanded)
            {
                if (rect.Width > 0 && rect.Height > 0)
                {
                    using (LinearGradientBrush brush = new LinearGradientBrush(
                        rect, Color.FromArgb(213, 213, 213),
                        Color.FromArgb(213, 213, 213), gradientMode))
                    {
                        Blend blend = new Blend();
                        blend.Positions = new float[] { 0f, .5f, 1f };
                        blend.Factors = new float[] { .5F, 1F, .5F };

                        brush.Blend = blend;
                        g.FillRectangle(brush, rect);
                    }
                }
            }
            else
            {
                if (rect.Width > 0 && rect.Height > 0)
                {

                    using (LinearGradientBrush brush = new LinearGradientBrush(
                        rect, Color.FromArgb(255, 187, 50),
                        Color.FromArgb(255, 187, 50), gradientMode))
                    {
                        Blend blend = new Blend();
                        blend.Positions = new float[] { 0f, .5f, 1f };
                        blend.Factors = new float[] { .5F, 1F, .5F };

                        brush.Blend = blend;
                        g.FillRectangle(brush, rect);
                    }
                }
            }
            if (_collapsePanel == CollapsePanel.None)
            {
                return;
            }

            Rectangle arrowRect;
            Rectangle topLeftRect;
            Rectangle bottomRightRect;

            CalculateRect(
                CollapseRect,
                out arrowRect,
                out topLeftRect,
                out bottomRightRect);

            ArrowDirection direction = ArrowDirection.Left;

            switch (_collapsePanel)
            {
                case CollapsePanel.Panel1:
                    if (bHorizontal)
                    {
                        direction =
                            _spliterPanelState == SpliterPanelState.Collapsed ?
                            ArrowDirection.Down : ArrowDirection.Up;
                    }
                    else
                    {
                        direction =
                            _spliterPanelState == SpliterPanelState.Collapsed ?
                            ArrowDirection.Right : ArrowDirection.Left;
                    }
                    break;
                case CollapsePanel.Panel2:
                    if (bHorizontal)
                    {
                        direction =
                            _spliterPanelState == SpliterPanelState.Collapsed ?
                            ArrowDirection.Up : ArrowDirection.Down;
                    }
                    else
                    {
                        direction =
                            _spliterPanelState == SpliterPanelState.Collapsed ?
                            ArrowDirection.Left : ArrowDirection.Right;
                    }
                    break;
            }

            Color foreColor = _mouseState == ControlState.Hover ?
                Color.FromArgb(21, 66, 139) : Color.FromArgb(80, 136, 228);
            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
            {
                RenderHelper.RenderGrid(g, topLeftRect, new Size(3, 3), foreColor);
                RenderHelper.RenderGrid(g, bottomRightRect, new Size(3, 3), foreColor);

                using (Brush brush = new SolidBrush(foreColor))
                {
                    RenderHelper.RenderArrowInternal(
                        g,
                        arrowRect,
                        direction,
                        brush);
                }
            }
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);

            Graphics g = e.Graphics;


            #region 画客户区


            using (GraphicsPath path =
                        GraphicsPathHelper.CreatePath(ClientRectangle, Radius, RoundStyle, false))
            {
                g.SetClip(path);

                if (controlSchema.BackNormalStyle.Color2 != Color.Empty
                    && controlSchema.BackNormalStyle.Color1 != controlSchema.BackNormalStyle.Color2)
                {
                    if (DisplayRectangle.Width > 0 && DisplayRectangle.Height > 0)
                    {
                        using (LinearGradientBrush br = new LinearGradientBrush(DisplayRectangle, controlSchema.BackNormalStyle.Color1, controlSchema.BackNormalStyle.Color2, controlSchema.BackNormalStyle.Mode))
                        {
                            g.FillPath(br, path);
                            //g.FillRectangle(br, DisplayRectangle);

                        }
                    }
                }
                else
                {
                    using (SolidBrush br = new SolidBrush(controlSchema.BackNormalStyle.Color1))
                    {
                        g.FillPath(br, path);
                        //g.FillRectangle(br, DisplayRectangle);

                    }

                }

            }




            #region 画背景图片
            if (BackgroundImage != null)
            {
                switch (BackgroundImageLayout)
                {
                    case ImageLayout.None:
                        g.DrawImageUnscaled(BackgroundImage,
                            DisplayRectangle.X,
                            DisplayRectangle.Y,
                            BackgroundImage.Width,
                            BackgroundImage.Height);
                        break;
                    case ImageLayout.Tile:
                        using (TextureBrush Txbrus = new TextureBrush(BackgroundImage))
                        {
                            Txbrus.WrapMode = WrapMode.Tile;

                            g.FillRectangle(Txbrus, new Rectangle(0, 0, DisplayRectangle.Width - 1, DisplayRectangle.Height - 1));

                        }
                        break;
                    case ImageLayout.Center:

                        int xx = (DisplayRectangle.Width - BackgroundImage.Width) / 2;
                        int yy = (DisplayRectangle.Height - BackgroundImage.Height) / 2;
                        g.DrawImage(BackgroundImage, new Rectangle(xx, yy, BackgroundImage.Width, BackgroundImage.Height), new Rectangle(0, 0, BackgroundImage.Width, BackgroundImage.Height), GraphicsUnit.Pixel);



                        break;
                    case ImageLayout.Stretch:

                        g.DrawImage(BackgroundImage, new Rectangle(0, 0, DisplayRectangle.Width, DisplayRectangle.Height), new Rectangle(0, 0, BackgroundImage.Width, BackgroundImage.Height), GraphicsUnit.Pixel);


                        break;

                    case ImageLayout.Zoom:
                        {
                            double tm = 0.0;
                            int W = BackgroundImage.Width;
                            int H = BackgroundImage.Height;
                            if (W > DisplayRectangle.Width)
                            {
                                tm = DisplayRectangle.Width / BackgroundImage.Width;
                                W = (int)(W * tm);
                                H = (int)(H * tm);
                            }
                            if (H > DisplayRectangle.Height)
                            {
                                tm = DisplayRectangle.Height / H;
                                W = (int)(W * tm);
                                H = (int)(H * tm);
                            }
                            using (Bitmap tmpBP = new Bitmap(W, H))
                            {
                                using (Graphics G2 = Graphics.FromImage(tmpBP))
                                {
                                    G2.DrawImage(BackgroundImage, new Rectangle(0, 0, W, H), new Rectangle(0, 0, BackgroundImage.Width, BackgroundImage.Height), GraphicsUnit.Pixel);

                                    int xxx = (DisplayRectangle.Width - W) / 2;
                                    int yyy = (DisplayRectangle.Height - H) / 2;
                                    g.DrawImage(tmpBP, new Rectangle(xxx, yyy, W, H), new Rectangle(0, 0, W, H), GraphicsUnit.Pixel);

                                }
                            }
                        }
                        break;

                }

            }

            #endregion


            #endregion

            #region 画标题
            OnPaintCaption(e);
            #endregion

            
            #region 画border
            using (SmoothingModeGraphics sgr = new SmoothingModeGraphics(g))
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;

                Rectangle r = ClientRectangle;
                //r.Width -= 1;
                //r.Height -= 1;
                using (GraphicsPath path =
                GraphicsPathHelper.CreatePath(r, Radius, RoundStyle, true))
                {
                    using (Pen p = new Pen(controlSchema.BorderNormalStyle.Color1))
                    {

                        g.DrawPath(p, path);
                    }
                }

                if (controlSchema.BorderNormalStyle.Color2 != Color.Empty
                    && controlSchema.BorderNormalStyle.Color2 != controlSchema.BorderNormalStyle.Color1)
                {
                    r.Inflate(-1, -1);
                    using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                    r, radius, roundStyle, true))
                    {
                        using (Pen pen = new Pen(controlSchema.BorderNormalStyle.Color2))
                        {
                            g.DrawPath(pen, path);
                        }
                    }
                }
            }
            #endregion



        }