日期:2014-05-17 浏览次数:20977 次
namespace WindowsFormsApplication1
{
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;
DrawTY(this.CreateGraphics(), P1.X, P1.Y, P2.X - P1.X, P2.Y - P1.Y);
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
}
private void DrawTY(Graphics g, int a,int b,int c,int d )
{
GraphicsPath roundedRect = new GraphicsPath();
roundedRect.AddArc(a, b, c, d, 200, 360);
//从路径中创建区域
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)
{
isMouseDown = true;
P1.X = e.X;