2 weixin 34250340 weixin_34250340 于 2016.04.15 20:57 提问

C#窗体应用程序画曲线
c++

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

1个回答

qq_34670821
qq_34670821   2016.04.15 21:15

用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
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!