如何用C#语言实现用鼠标画曲线的程序??
1个回答
展开全部
private
Point
point;
private
Graphics
g;
private
void
Form1_MouseMove(object
sender,
MouseEventArgs
e)
{
this.g
=
this.CreateGraphics();
if
(e.Button
!=
MouseButtons.Left)
{
this.point
=
new
Point(e.X,
e.Y);
return;
}
Pen
Redpen
=
new
Pen(Color.Red);
Point
currentPoint=new
Point(e.X,e.Y);
g.DrawLine(Redpen,
this.point,
currentPoint);
this.point
=
currentPoint;
}
最重要的代码就是这些了,在单机鼠标移动的过程中不断的绘制短直线!最后达到绘制曲线的目的
Point
point;
private
Graphics
g;
private
void
Form1_MouseMove(object
sender,
MouseEventArgs
e)
{
this.g
=
this.CreateGraphics();
if
(e.Button
!=
MouseButtons.Left)
{
this.point
=
new
Point(e.X,
e.Y);
return;
}
Pen
Redpen
=
new
Pen(Color.Red);
Point
currentPoint=new
Point(e.X,e.Y);
g.DrawLine(Redpen,
this.point,
currentPoint);
this.point
=
currentPoint;
}
最重要的代码就是这些了,在单机鼠标移动的过程中不断的绘制短直线!最后达到绘制曲线的目的
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询