Пример #1
0
        //MOVER VERTICE
        public void MoverVertice(Graphics g, int xmouse, int ymouse, int width, int height)
        {
            bool inicio;

            if (vselec != null && vselec.ChecarLimites(xmouse, ymouse, width, height))
            {
                vselec.X = xmouse;
                vselec.Y = ymouse;

                foreach (Arista a in aristas)
                {
                    if (a.ChecarVertice(vselec))
                    {
                        inicio = vselec.ID == a.IDV1;
                        if (inicio)
                        {
                            a.X1 = vselec.X;
                            a.Y1 = vselec.Y;
                        }
                        else
                        {
                            a.X2 = vselec.X;
                            a.Y2 = vselec.Y;
                        }
                    }
                }

                Dibujar(g);
            }
        }
Пример #2
0
        public void AgregaVertice(Graphics g, int x, int y, int width, int height)
        {
            bool    banColision = false;
            Vertice v           = new Vertice(idv, x, y);

            foreach (Vertice ver in vertices)
            {
                banColision = x - v.Radio <= ver.X + ver.Radio && x + v.Radio >= ver.X - ver.Radio && y - v.Radio <= ver.Y + ver.Radio && y + v.Radio >= ver.Y - ver.Radio;
                if (banColision)
                {
                    return;
                }
            }



            if (!banColision && v.ChecarLimites(x, y, width, height))
            {
                idv++;
                vertices.Add(v);
                v.Dibujar(g);
            }
        }