public void AddShape(byte intShapeID) { switch (intShapeID) { case 0: //Rectangle ShapeRectangle rect = new ShapeRectangle(); rect.Location = new Point(50, 50); AddShape(rect); break; case 1: //Triangle ShapeTriangle triangle = new ShapeTriangle(); triangle.Location = new Point(50, 50); AddShape(triangle); break; case 2: ShapeCircle circle = new ShapeCircle(); circle.Location = new Point(50, 50); AddShape(circle); break; case 3: ShapePolygon poly = new ShapePolygon(); poly.Location = new Point(50, 50); AddShape(poly); break; case 4: ShapeLine line = new ShapeLine(); line.Location = new Point(50, 50); AddShape(line); break; case 5: ShapeText text = new ShapeText(); text.Location = new Point(50, 50); AddShape(text); break; default: throw new Exception("Could not find the associated shape type!"); } }
public override Shape Clone() { ShapePolygon newShape = new ShapePolygon(); //copy the properties newShape.points.AddRange(this.points.ToArray()); newShape.types.AddRange(this.types.ToArray()); newShape.isAnchor.AddRange(this.isAnchor.ToArray()); newShape.isInitializing = false; newShape.painter.CopyProperties(ref this.painter); //offset the new polygon int intCount = points.Count; for (int i = 0; i < intCount; i++) { newShape.points[i] = new PointF(points[i].X + 15f, points[i].Y + 15f); } newShape.EditingOn = false; return(newShape); }
public override Shape Clone() { ShapePolygon newShape = new ShapePolygon(); //copy the properties newShape.points.AddRange(this.points.ToArray()); newShape.types.AddRange(this.types.ToArray()); newShape.isAnchor.AddRange(this.isAnchor.ToArray()); newShape.isInitializing = false; newShape.painter.CopyProperties(ref this.painter); //offset the new polygon int intCount = points.Count; for (int i =0;i<intCount;i++) { newShape.points[i] = new PointF(points[i].X + 15f, points[i].Y + 15f); } newShape.EditingOn = false; return newShape; }