日期:2014-05-17 浏览次数:20797 次
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Point P1 = new Point();
Point P2 = new Point();
bool isMouseDown = false;
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
isMouseDown = false;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
// Rectangle rect1 = new Rectangle(P1.X, P1.Y, P2.Y - P1.Y, P2.Y - P1.Y);
// Rectangle rect1 = new Rectangle(1, 1, 100, 100);
DrawTY(g, P1.X, P1.Y, P2.Y - P1.Y, P2.Y - P1.Y);
}
private void DrawTY(Graphics g, int a,int b,int c,int d )
{
GraphicsPath roundedRect = new GraphicsPath();
roundedRect.AddArc(a, b, c, d, 0, 360);
roundedRect.CloseFigure();
//从路径中创建区域
Region pathRegion = new Region(roundedRect);
// g.FillRegion(new SolidBrush(Color.Blue), pathRegion);
g.DrawPath(Pens.Blue, roundedRect);
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (isMouseDown == false)