C#窗体应用程序画曲线

怎么用C#窗体应用程序画一条曲线,用鼠标画,点击左键开始,记录鼠标经过的位置,松开左键结束,并能以虚线形式复制

c++

1个回答

用GDI+

    Graphics gra;
    Point firstpoint;
    Point secondpoint;
    private void Form1_Load(object sender, EventArgs e)
    {
        gra = this.CreateGraphics();
        firstpoint = new Point(0, 0);
        secondpoint = new Point(0, 0);
    }

    private void Form1_MouseDown(object sender, MouseEventArgs e)
    {
        firstpoint.X = e.X;
        firstpoint.Y = e.Y;
    }

    private void Form1_MouseUp(object sender, MouseEventArgs e)
    {
        secondpoint.X = e.X;
        secondpoint.Y = e.Y;
        gra.DrawLine(Pens.Black, firstpoint, secondpoint);
    }
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!