回复 2楼 yhlvht
我现在已经运行出来了这个矩形,但是不知道该如何编写移动矩形的点的代码,好像要用到鼠标的MouseDown事件,求指教……
private void Form1_Paint(object sender, PaintEventArgs e) { Graphics graphics = this.CreateGraphics(); graphics.Clear(Color.White); Pen blackpen = new Pen(Color.Black, 3); Point point1 = new Point(100, 100); Point point2 = new Point(100, 200); Point point3 = new Point(100, 300); Point point4 = new Point(100, 400); Point point5 = new Point(300, 100); Point point6 = new Point(500, 100); Point point7 = new Point(700, 100); Point point8 = new Point(900, 100); Point point9 = new Point(300, 200); Point point10 = new Point(500, 200); Point point11 = new Point(700, 200); Point point12 = new Point(900, 200); Point point13 = new Point(300, 300); Point point14 = new Point(500, 300); Point point15 = new Point(700, 300); Point point16 = new Point(900, 300); Point point17 = new Point(300, 400); Point point18 = new Point(500, 400); Point point19 = new Point(700, 400); Point point20 = new Point(900, 400); Point[] p1 = { point1, point2 }; graphics.DrawPolygon(blackpen, p1);//两点之间分别连接直线 Point[] p2 = { point3, point2 }; graphics.DrawPolygon(blackpen, p2); Point[] p3 = { point3, point4 }; graphics.DrawPolygon(blackpen, p3); Point[] p4 = { point4, point17 }; graphics.DrawPolygon(blackpen, p4); Point[] p5 = { point17, point13 }; graphics.DrawPolygon(blackpen, p5); Point[] p6 = { point13, point9 }; graphics.DrawPolygon(blackpen, p6); Point[] p7 = { point9, point5 }; graphics.DrawPolygon(blackpen, p7); Point[] p8 = { point3, point13 }; graphics.DrawPolygon(blackpen, p8); Point[] p9 = { point2, point9 }; graphics.DrawPolygon(blackpen, p9); Point[] p10 = { point1, point5 }; graphics.DrawPolygon(blackpen, p10); Point[] p11 = { point17, point18 }; graphics.DrawPolygon(blackpen, p11); Point[] p12 = { point13, point14 }; graphics.DrawPolygon(blackpen, p12); Point[] p13 = { point9, point10 }; graphics.DrawPolygon(blackpen, p13); Point[] p14 = { point5, point6 }; graphics.DrawPolygon(blackpen, p14); Point[] p15 = { point18, point14 }; graphics.DrawPolygon(blackpen, p15); Point[] p16 = { point10, point14 }; graphics.DrawPolygon(blackpen, p16); Point[] p17 = { point10, point6 }; graphics.DrawPolygon(blackpen, p17); Point[] p18 = { point18, point19 }; graphics.DrawPolygon(blackpen, p18);[local]1[/local][local]1[/local] Point[] p19 = { point15, point14 }; graphics.DrawPolygon(blackpen, p19); Point[] p20 = { point10, point11 }; graphics.DrawPolygon(blackpen, p20); Point[] p21 = { point6, point7 }; graphics.DrawPolygon(blackpen, p21); Point[] p22 = { point19, point20 }; graphics.DrawPolygon(blackpen, p22); Point[] p23 = { point15, point16 }; graphics.DrawPolygon(blackpen, p23); Point[] p24 = { point11, point12 }; graphics.DrawPolygon(blackpen, p24); Point[] p25 = { point7, point8 }; graphics.DrawPolygon(blackpen, p25); Point[] p26 = { point19, point15 }; graphics.DrawPolygon(blackpen, p26); Point[] p27 = { point15, point11 }; graphics.DrawPolygon(blackpen, p27); Point[] p28 = { point11, point7 }; graphics.DrawPolygon(blackpen, p28); Point[] p29 = { point16, point20 }; graphics.DrawPolygon(blackpen, p29); Point[] p30 = { point16, point12 }; graphics.DrawPolygon(blackpen, p30); Point[] p31 = { point8, point12 }; graphics.DrawPolygon(blackpen, p31); SolidBrush redbrush = new SolidBrush(Color.Red);//绘制曲线经过的点 graphics.FillEllipse(redbrush, new Rectangle(100, 100, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(100, 200, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(100, 300, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(100, 400, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(300, 100, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(500, 100, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(700, 100, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(900, 100, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(300, 200, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(300, 300, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(300, 400, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(500, 200, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(500, 300, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(500, 400, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(700, 200, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(700, 300, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(700, 400, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(900, 200, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(900, 300, 5, 5)); graphics.FillEllipse(redbrush, new Rectangle(900, 400, 5, 5)); }