예제 #1
0
        public void SetVertexPosition(Vertex p, int x, int y)
        {
            if (x <= 0)
            {
                x = 0;
            }
            if (y <= 0)
            {
                y = 0;
            }

            p.IsLocked = true;

            int backupX = p.X;
            int backupY = p.Y;

            p.X = x;
            p.Y = y;

            foreach (var constraint in constraints)
            {
                if (constraint.IsVertexInvolved(p) && !constraint.IsContraintValid())
                {
                    if (!constraint.TryRepairConstraint(this))
                    {
                        p.X = backupX;
                        p.Y = backupY;
                    }
                }
            }

            if (p.X != backupX || p.Y != backupY)
            {
                VertexMoved?.Invoke(p);
            }

            p.IsLocked = false;
        }
 protected virtual void OnVertexMoved(EventArgs e)
 {
     VertexMoved?.Invoke(this, e);
 }