我需要能夠使用鼠標點擊位置繪製多邊形。 這裏是我當前的代碼:在C中使用鼠標點繪製多邊形#
//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上。你提供的代碼,但它的工作?你的問題是什麼? – 2010-10-21 14:00:19
是的,是的,它是行不通的,我可以;噸工作了如何存儲鼠標點擊陣列中,他們被加入一條線,就像在MS漆 – 2010-10-21 14:02:11
用戶應該如何繪製一個多邊形?一行一行,或整個多邊形一次?您希望用戶左鍵單擊點數x次,然後右鍵單擊繪製(否則,您如何知道用戶何時完成)? – 2010-10-21 14:18:27