public PointHandle(Element e, RedimStatus o, PointWr p)
 {
     Operation   = o;
     FillColor   = Color.BlueViolet;
     linkedPoint = p;
     el          = e;
     rePosition(e);
 }
 public NewPointHandle(Element e, RedimStatus o, PointWr p, int i)
 {
     Index       = i;
     Operation   = o;
     FillColor   = Color.YellowGreen;
     linkedPoint = p;
     el          = e;
     rePosition(e);
 }
        /// <summary>
        ///set ups handles
        /// </summary>
        public void setup(PointSet el)
        {
            if (CanRotate)
            {
                //ROT
                handles.Add(new RotHandle(this, RedimStatus.Rotate));
            }

            PointWr prec = null;
            int     c    = 0;
            int     minx;
            int     miny;
            int     maxx;
            int     maxy;

            foreach (var p in  el.points)
            {
                c++;
                handles.Add(new PointHandle(this, RedimStatus.Poly, p));
                if (prec != null)
                {
                    minx = Math.Min(p.X, prec.X);
                    miny = Math.Min(p.Y, prec.Y);
                    maxx = Math.Max(p.X, prec.X);
                    maxy = Math.Max(p.Y, prec.Y);
                    var newP = new PointWr(minx + ((maxx - minx) / 2), miny + ((maxy - miny) / 2));
                    handles.Add(new NewPointHandle(this, RedimStatus.NewPoint, newP, c));
                }
                prec = p;
            }

            if (c > 0)
            {
                var newP = new PointWr(prec.X + 7, prec.Y + 7);
                handles.Add(new NewPointHandle(this, RedimStatus.NewPoint, newP, c + 1));
            }

            //SE
            handles.Add(new RedimHandle(this, RedimStatus.SE));
            //S
            handles.Add(new RedimHandle(this, RedimStatus.S));
            //E
            handles.Add(new RedimHandle(this, RedimStatus.E));
            //W
            handles.Add(new RedimHandle(this, RedimStatus.W));
            //SW
            handles.Add(new RedimHandle(this, RedimStatus.SW));
            //NW
            handles.Add(new RedimHandle(this, RedimStatus.NW));
            //N
            handles.Add(new RedimHandle(this, RedimStatus.N));
            //NE
            handles.Add(new RedimHandle(this, RedimStatus.NE));
        }
        /// <summary>
        ///set ups handles
        /// </summary>
        public void reCreateCreationHandles(PointSet el)
        {
            // TODO: rewrite this back-to-front, instead of with a clumsy temp list
            var tmp = new List <Handle>();

            foreach (var h in handles)
            {
                if (h is NewPointHandle)
                {
                    tmp.Add(h);
                }
            }
            foreach (var h in tmp)
            {
                handles.Remove(h);
            }


            PointWr prec = null;
            int     c    = 0;
            int     minx = 0;
            int     miny = 0;
            int     maxx = 0;
            int     maxy = 0;

            foreach (var p in el.points)
            {
                c++;
                if (prec != null)
                {
                    minx = Math.Min(p.X, prec.X);
                    miny = Math.Min(p.Y, prec.Y);
                    maxx = Math.Max(p.X, prec.X);
                    maxy = Math.Max(p.Y, prec.Y);
                    var newP = new PointWr(minx + ((maxx - minx) / 2), miny + ((maxy - miny) / 2));
                    handles.Add(new NewPointHandle(this, RedimStatus.NewPoint, newP, c));
                }
                prec = p;
            }

            if (c > 0)
            {
                var newP = new PointWr(prec.X + 7, prec.Y + 7);
                handles.Add(new NewPointHandle(this, RedimStatus.NewPoint, newP, c + 1));
            }
        }