예제 #1
0
        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            activa = true;

            //asignaPesos(e.Location);
            if (bandA && band && (opcion == 2 || opcion == 9))
            {
                p2      = e.Location;
                nodoAux = grafo.BuscaNodo(p2);

                if (nodoAux != null)
                {
                    if (opcion == 2)
                    {
                        //  grafo = new GrafoNoDirigido(grafo);
                        nodoR         = new Arista(0);
                        nodoR.destino = nodoAux;
                        nodoR.origen  = nodoP;
                        nodoP.aristas.Add(nodoR);


                        nodoR = new Arista(0);//(rnd.Next(100));

                        nodoR.destino = nodoP;
                        nodoR.origen  = nodoAux;

                        nodoAux.aristas.Add(nodoR);
                    }

                    else if (opcion == 9)
                    {
                        //    grafo = new GrafoDirigido(grafo);
                        grafo.penA.CustomEndCap = arrow;

                        nodoR         = new Arista(0);
                        nodoR.destino = nodoAux;
                        nodoR.origen  = nodoP;

                        nodoP.aristas.Add(nodoR);
                    }

                    bandF = true;
                    bandA = false;
                }
                else
                {
                    bandF = false;
                }
            }

            if (opcion == 4)
            {
                grafo.BorrarNodo(e.Location);
                bandF = false;
            }

            if (opcion == 5)
            {
                grafo.BorrarArista(e.Location);
                quitaNumeric();
                quitaTexaux();//cambios
                quitaPesos();

                bandF = false;
            }
            if (opcion == 41 || intercambiaColor == true) // agregar Peso a Arista
            {
                quitaPesos();
                quitaNumeric();//
                quitaTexaux();
                // asignaPesos(e.Location);
                asignaPesos2(e.Location);
                muestraPeso();
                bandF = false;
            }


            band  = false;
            bandA = false;
            Form1_Paint(this, null);
        }