weixin_34250340
weixin_34250340
2016-04-15 12:57
采纳率: 11.1%
浏览 1.7k

C#窗体应用程序画曲线

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

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • qq_34670821
    qq_34670821 2016-04-15 13: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);
        }
    
    点赞 评论

相关推荐