public void DuplicateCurrentHole() { if (MostRecentlySelectedHole == null) { return; } LayoutHole oHole = LayoutHole.CopyFrom(MostRecentlySelectedHole); // Add at an offset so it will be easy to see oHole.OffsetX += 10; oHole.OffsetY += 10; // Create a new version of the instance of the hole int ndx = MostRecentlySelectedHole.HoleTypeIndex; switch (MostRecentlySelectedHole.HoleType) { case "ell": oHole.HoleTypeIndex = BoundaryEllipseList.Count; BoundaryEllipse e = BoundaryEllipseList.GetFrom(ndx); BoundaryEllipseList.Add(BoundaryEllipse.CopyFrom(e)); break; case "rect": oHole.HoleTypeIndex = BoundaryRectangleList.Count; BoundaryRectangle r = BoundaryRectangleList.GetFrom(ndx); BoundaryRectangleList.Add(BoundaryRectangle.CopyFrom(r)); break; case "poly": oHole.HoleTypeIndex = BoundaryPolygonList.Count; BoundaryPolygon p = BoundaryPolygonList.GetFrom(ndx); BoundaryPolygonList.Add(BoundaryPolygon.CopyFrom(p)); break; } // Add the new hole to the hole group AddHoleToHoleGroup(MostRecentlySelectedHoleGroup, oHole); // trigger a repaint DrawShapes(); }
public void AddEllipse(int ScreenOffsetX, int ScreenOffsetY, int Width, int Height) { if (MostRecentlySelectedHoleGroup == null) { return; } PointF WorldOffset = this.S2W(ScreenOffsetX, ScreenOffsetY); LayoutHole oHole = new LayoutHole(); oHole.HoleType = "ell"; oHole.OffsetX = WorldOffset.X; oHole.OffsetY = WorldOffset.Y; /* * Save this as the current and most recently selected * The most recently selected is used for commands after the mouse is up */ CurrentlySelectedHole = oHole; MostRecentlySelectedHole = oHole; /* * The index is the at the end of the current list. This means we will have to manage the index values * when they are deleted */ oHole.HoleTypeIndex = BoundaryEllipseList.Count; AddHoleToHoleGroup(MostRecentlySelectedHoleGroup, oHole); /* * Now create and add the ellipse */ BoundaryEllipse ell = new BoundaryEllipse(); ell.Width = Width; ell.Height = Height; BoundaryEllipseList.Add(ell); // trigger redraw DrawShapes(); }