Example #1
0
        /// <summary>
        /// Draws a point from the center.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="brush"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="r"></param>
        public static void DrawPoint(this Graphics g, VerticePoint p)
        {
            int drawingStartX = (int)(p.X - p.R);
            int drawingStartY = (int)(p.Y - p.R);

            g.FillEllipse(p.Brush, drawingStartX, drawingStartY, (int)(2 * p.R), (int)(2 * p.R));
        }
        public void BuildNextPolygonPart(double x, double y)
        {
            // frist vertice
            if (cachedVertices.Count == 0)
            {
                var v = new VerticePoint(x, y);
                cachedVertices.Add(v);
            }

            // drawing last cached vertice
            drawingModule.DrawPolygonVertices(cachedVertices.Last());

            // subsequent vertice
            var nextV = new VerticePoint(x, y);

            cachedVertices.Add(nextV);

            // new edge between last cached and newly created
            var e = new Line(cachedVertices[cachedVertices.Count - 2], cachedVertices.Last());

            cachedEdges.Add(e);

            // draw edge (for now the edge has only one visible vertice)
            drawingModule.DrawPolygonEdges(e);

            // start moving last vertice
            movingVerticeState.Clear();
            movingVerticeState.selectedVertice = cachedVertices.Last();
            movingVerticeState.GetMoveVectorAndUpdateHitPoint(x, y);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="v"></param>
 /// <param name="vector"></param>
 /// <returns>If whole poygon needs to be moved.</returns>
 public static bool ApplyPolygonConstraitnsAfterVerticeMove(VerticePoint v, (double x, double y) vector)