【发布时间】:2011-04-28 15:15:43
【问题描述】:
我需要能够使用鼠标单击位置绘制多边形。 这是我当前的代码:
//the drawshape varible is called when a button is pressed to select use of this tool
if (DrawShape == 4)
{
Point[] pp = new Point[3];
pp[0] = new Point(e.Location.X, e.Location.Y);
pp[1] = new Point(e.Location.X, e.Location.Y);
pp[2] = new Point(e.Location.X, e.Location.Y);
Graphics G = this.CreateGraphics();
G.DrawPolygon(Pens.Black, pp);
}
谢谢
【问题讨论】:
-
我假设您使用的是 winforms。您提供了代码,但它有效吗?你的问题是什么?
-
是的,我是,是的,它不起作用,我不知道如何将鼠标点击存储在数组中,以便它们通过一条线连接起来,就像在 MS Paint 中一样跨度>
-
用户应该如何绘制多边形?一行一行,还是一次整个多边形?您希望用户左键单击 x 次,然后右键单击以绘制(否则您如何知道用户何时完成)?
-
理想情况下,一行一行的点数不限,直到用户右键单击停止绘制多边形形状
标签: c# polygon mouseclick-event