public void FinishPolygonBuilding(double x, double y) { RollbackDoubleClickEffect(); if (cachedVertices.Count <= 2) { DeleteCurrentlyBuildedPolygon(); return; } // last edge var lastEdge = new Line(cachedVertices.Last(), cachedVertices.First()); cachedEdges.Add(lastEdge); drawingModule.BeginDrawingTransaction(); drawingModule.DrawPolygonEdges(cachedEdges.Last()); // finally create the polygon var newPolygon = new Polygon(cachedVertices.ConvertAll(v => v), cachedEdges.ConvertAll(edge => edge)); Polygons.Add(newPolygon); drawingModule.FillPolygon(newPolygon); drawingModule.FinishDrawingTransaction(); // clear cache cachedVertices.Clear(); cachedEdges.Clear(); movingVerticeState.Clear(); }
public void DeletePolygon(Polygon p) { #region checkArgs if (p == null) { return; } #endregion if (Polygons.Remove(p)) { drawingModule.BeginDrawingTransaction(); drawingModule.ClearPolygonVertices(p.GetVerticesList().ToArray()); drawingModule.ClearPolygonEdges(p.GetEdgesList().ToArray()); drawingModule.ClearPolygonFilling(p); Redraw(); drawingModule.FinishDrawingTransaction(); } deletingPolygonState.Clear(); }