예제 #1
0
파일: Form1.cs 프로젝트: tiffcortez/pv
        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            int i;

            switch (tipo)
            {
            case 0:
                grafo.AgregaVertice(lienzo, e.X, e.Y);
                break;

            case 4:
                for (i = 0; i < auxVert.Count; i++)
                {
                    if (auxVert[i].Seleccion(e.X, e.Y) && toque == 0)
                    {
                        v1    = auxVert[i];
                        toque = 1;
                    }
                    else if (auxVert[i].Seleccion(e.X, e.Y) && toque == 1)
                    {
                        v2 = auxVert[i];
                        if (!v1.Equals(v2))
                        {
                            lienzo.DrawLine(new Pen(Color.Black), v1.X, v1.Y, v2.X, v2.Y);
                            toque = 0;
                        }
                    }
                }
                Console.WriteLine(toque);
                break;
            }
        }
예제 #2
0
        //CLICK
        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            switch (tipo)
            {
            case 0:     // Agregar vértices
                grafo.AgregaVertice(lienzo, e.X, e.Y, pictureBox1.Width, pictureBox1.Height);
                up2Date = false;
                break;

            case 82:     // eliminar vertice
                for (int i = 0; i < grafo.Vertices.Count; i++)
                {
                    Vertice v = grafo.Vertices[i];
                    if (v.Seleccion(e.X, e.Y))
                    {
                        grafo.elimAr(v.ID);
                        grafo.Vertices.RemoveAt(i);
                        break;
                    }
                }
                DibujarG();
                break;

            case 4:     //Agregar aristas
                foreach (Vertice v in grafo.Vertices)
                {
                    if (v.Seleccion(e.X, e.Y) && toque == 0)
                    {
                        v1    = v;
                        toque = 1;
                        v1.Seleccionar(lienzo);
                    }
                    else if (v.Seleccion(e.X, e.Y) && toque == 1)
                    {
                        v2 = v;
                        v2.Seleccionar(lienzo);
                        if (!v1.Equals(v2))
                        {
                            grafo.AgregaArista(lienzo, v1, v2);
                            up2Date = false;
                            toque   = 0;
                        }
                    }
                }
                break;
            }
        }