コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }