日期:2014-05-17  浏览次数:20976 次

GDI+画图问题,请高手指点
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;
            
        }

     

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            
            Graphics g = e.Graphics;
            Rectangle rect1=new Rectangle(50, 50, 200, 100);
            Draw(g, rect1);
        }

        private void Draw(Graphics g, Rectangle rect)
        {
            GraphicsPath roundedRect = new GraphicsPath();
            roundedRect.AddArc(rect.X, rect.Y, rect.Width, rect.Height, 0, 360);
            roundedRect.CloseFigure();
            Region pathRegion = new Region(roundedRect);
        }

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            if (isMouseDown == false)
            {
                isMouseDown = true;

                P1.X = e.X;
                P1.Y = e.Y;
            }
        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
          &