using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using System.Windows.Forms; namespace IOM_cs { class SetRadius : Form { private int _Radius; // 圆角弧度 /// <summary>圆角弧度(0为不要圆角)</summary> //[Browsable(true)] //[Description("圆角弧度(0为不要圆角)")] public int _setRoundRadius//设置圆角弧度 { get { return _Radius; } set { if (value < 0) { _Radius = 0; } else { _Radius = value; } base.Refresh(); } } // 圆角代码 public Region Round(int width, int height) { System.Drawing.Drawing2D.GraphicsPath oPath = new System.Drawing.Drawing2D.GraphicsPath(); int x = 1; int y = 1; int thisWidth = width; int thisHeight = height; int angle = _Radius; if (angle > 0) { System.Drawing.Graphics g = CreateGraphics(); oPath.AddArc(x, y, angle, angle, 180, 90); // 左上角 oPath.AddArc(thisWidth - angle, y, angle, angle, 270, 90); // 右上角 oPath.AddArc(thisWidth - angle-1, thisHeight - angle-1, angle, angle, 0, 90); // 右下角 oPath.AddArc(x, thisHeight - angle, angle, angle, 90, 90); // 左下角 oPath.CloseAllFigures(); return new System.Drawing.Region(oPath); } // ----------------------------------------------------------------------------------------------- else { oPath.AddLine(x + angle, y, thisWidth - angle, y); // 顶端 oPath.AddLine(thisWidth, y + angle, thisWidth, thisHeight - angle); // 右边 oPath.AddLine(thisWidth - angle, thisHeight, x + angle, thisHeight); // 底边 oPath.AddLine(x, y + angle, x, thisHeight - angle); // 左边 oPath.CloseAllFigures(); return new System.Drawing.Region(oPath); } } } }