111,097
社区成员




public partial class Ring : UserControl
{
public Ring()
{
InitializeComponent();
}
private void Ring_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias; //抗锯齿
using(Pen pn = new Pen(Color.Blue, 5f))
{
g.Clear(Color.White);
Rectangle rect = new Rectangle(5, 5, Width - 10, Height - 10);
g.DrawArc(pn, rect, 0, 360);
GraphicsPath p = new GraphicsPath();
p.AddEllipse(0, 0, this.Width, this.Height);
p.AddEllipse(10, 10, this.Width - 20, this.Height - 20);
this.Region = new Region(p);//这句就是设置圆形的规格区域的
}
}
private static int ox, oy;
private void Ring_MouseDown(object sender, MouseEventArgs e)
{
ox = e.X;
oy = e.Y;
}
private void Ring_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Left += e.X - ox;
Top += e.Y - oy;
}
}
}