Как сохранить объект треугольника в lsit и нарисовать его снова?
I am trying to save the triangle I drew and draw again while the previous triangle is still there. I did this in rectangle, square, circle and ellipse and it worked. I don't know why it won't in Triangle. IS there something wrong in the code? What I have tried: <pre>>This is how I draw and "save (not working)" **Shape Class** public void DrawTriangle(Color c, int stroke,PointF[] tpoints, float w, Graphics g) { this.width = w; this.strokeThickness = stroke; this.tPoints = tpoints; g.InterpolationMode = InterpolationMode.High; g.SmoothingMode = SmoothingMode.AntiAlias; g.DrawPolygon(new Pen(c, stroke), tpoints); } **Form 1** public void DrawTriangle() { tC = Color.Red; strokeTriangle = trackBar_Stroke.Value; tW = Convert.ToInt32((Convert.ToInt32(tbox_Width.Text) * 96) / 25.4); tH = (Convert.ToInt32((tW * (Math.Sqrt(3))) / 2)); tX = (pictureBox_Canvass.Width - tW) / 2; tY = ((pictureBox_Canvass.Width - (tH)) / 2) + tH; float angle = 0; t_Points[0].X = tX; t_Points[0].Y = tY; t_Points[1].X = (float)(tX + tW * Math.Cos(angle)); t_Points[1].Y = (float)(tY + tW * Math.Sin(angle)); t_Points[2].X = (float)(tX + tW * Math.Cos(angle - Math.PI / 3)); t_Points[2].Y = (float)(tY + tW * Math.Sin(angle - Math.PI / 3)); } public void AcceptTriangle() { Shape shape = new Shape(); tC = Color.Gray; shape.strokeThickness = strokeTriangle; shape.width = tW; shape.x = tX; shape.y = tY; shape.tPoints = t_Points; s._triangle.Add(shape); } >This is how I iterate it. public List<Shape> _triangle = new List<Shape>(); foreach(Shape shapes3 in s._triangle) { shapes3.DrawTriangle(shapes3.color, shapes3.strokeThickness, shapes3.tPoints, shapes3.width, e.Graphics); }
Gerry Schmitz
Почему вы не используете элементы управления WPF "Shape"?
Вы используете "ассемблер" по сравнению со всеми доступными опциями.