Winform制作圆弧panel

原理就是手动去画边框留出四个角 然后绘制四张圆弧的图片到panel上

 public class ArcPanel : Panel
    {
        protected override void OnPaint(PaintEventArgs e)
        {
            Pen pen = new Pen(_borderColor, 1);
            int wdh = 7;
            e.Graphics.DrawLine(pen, new Point(wdh, 0), new Point(this.Width - wdh, 0));//
            e.Graphics.DrawLine(pen, new Point(0, wdh), new Point(0, this.Height - wdh));  //
            e.Graphics.DrawLine(pen, new Point(this.Width-1 , wdh), new Point(this.Width-1 , this.Height - wdh));//
            e.Graphics.DrawLine(pen, new Point(wdh, this.Height-1), new Point(this.Width - wdh, this.Height-1));//

            Image imgLeftTop = global::WinGPChat.Properties.Resources.jiao01;
            Image imgRightTop = global::WinGPChat.Properties.Resources.jiao03;
            Image imgRightBottom = global::WinGPChat.Properties.Resources.jiao03_04;
            Image imgLeftBottom = global::WinGPChat.Properties.Resources.jiao04;
            
            e.Graphics.DrawImage(imgLeftTop, new Point(0, 0));
            e.Graphics.DrawImage(imgRightTop, new Point(this.Width - imgRightTop.Width, 0));
            e.Graphics.DrawImage(imgRightBottom, new Point(this.Width - imgRightBottom.Width, this.Height - imgRightBottom.Height));
            e.Graphics.DrawImage(imgLeftBottom, new Point(0, this.Height - imgLeftBottom.Height));
            base.OnPaint(e);
        }

        Color _borderColor = Color.FromArgb(207, 207, 207);
        public Color BorderColor
        {
            get
            {
                return _borderColor;
            }
            set
            {
                _borderColor = value;
                this.Invalidate();
            }
        }
    }
原文地址:https://www.cnblogs.com/jieliu726/p/4718311.html