Esempio n. 1
0
        /// <summary>
        /// Set position of given vertex. Position can't be out of range of this canvas (it's modified, when this situation occurs).
        /// Left property has to be between 0 and width of this canvas and top property has to be between 0 and height of this canvas.
        /// </summary>
        /// <param name="v">Target vertex</param>
        /// <param name="p">Specified point</param>
        /// <returns>true if vertex has been moved exactly to given point  </returns>
        public bool setPosition(Vertex v, VPoint p)
        {
            //Check whether the new point is equal to old point
            if (v == null || !_graph.Vertices.Contains(v) || p == null)
            {
                return(false);
            }

            VPoint point = new VPoint();
            bool   okay  = true;

            if (p.X < 0)
            {
                point.X = 0; okay = false;
            }
            else
            {
                if (p.X > _width)
                {
                    point.X = _width; okay = false;
                }
                else
                {
                    point.X = p.X;
                }
            }

            if (p.Top < 0)
            {
                point.Y = 0; okay = false;
            }
            else
            {
                if (p.Top > _height)
                {
                    point.Y = _height; okay = false;
                }
                else
                {
                    point.Y = p.Y;
                }
            }

            _vertices[v] = point;



            return(okay);
        }
Esempio n. 2
0
        public void update(Vertex changedObject, ChangeType typeOfChange)
        {
            switch (typeOfChange)
            {
            case ChangeType.Added:
            {
                int    w = _random.Next(_width);
                int    h = _random.Next(_height);
                VPoint v = new VPoint(w, h);

                _vertices[changedObject] = v;
                break;
            }

            case ChangeType.Removed:
            {
                _vertices.Remove(changedObject);
                break;
            }
            }
        }
Esempio n. 3
0
        public bool setPosition(Vertex v, Point p)
        {
            VPoint vp = new VPoint(p.X, p.Y);

            return(setPosition(v, vp));
        }
Esempio n. 4
0
 public PartialMemento(Positions pos, Vertex v)
 {
     _position = pos;
     _vertex   = v;
     _point    = _position._vertices[v];
 }