bool G_MouseFlag;
        Pen pen = new Pen(Color.Black);
        Point lastPoint;
        private void _018_MouseMove(object sender, MouseEventArgs e)
        {
            Graphics graphics = this.CreateGraphics();
            if (lastPoint.Equals(Point.Empty))//判断绘图开始点是否为空
            {
                lastPoint = new Point(e.X, e.Y);//记录鼠标当前位置
            }
            if (G_MouseFlag)//开始绘图
            {
                Point currentPoint = new Point(e.X, e.Y);//获取鼠标当前位置
                graphics.DrawLine(pen, currentPoint, lastPoint);//绘图
            }
            lastPoint = new Point(e.X,e.Y);//记录鼠标当前位置
        }

        private void _018_MouseDown(object sender, MouseEventArgs e)
        {
            G_MouseFlag = true;//开始绘图标识设置为true
        }

        private void _018_MouseUp(object sender, MouseEventArgs e)
        {
            G_MouseFlag = false;//开始绘图标识设置为false
        }
        //画圆
        private void button1_Click(object sender, EventArgs e)
        {
            Graphics graphics = this.CreateGraphics();
            Rectangle gle=new Rectangle(20,20,200,200);
            graphics.DrawEllipse(pen,gle);
        }

 

相关文章:

  • 2022-12-23
  • 2021-11-26
  • 2022-01-19
  • 2022-12-23
  • 2021-10-01
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-31
  • 2021-04-16
  • 2021-11-14
  • 2021-10-18
  • 2021-11-29
相关资源
相似解决方案