Ejemplo n.º 1
0
        private void Kuratowski_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button.Equals(MouseButtons.Left))
            {
                switch (this.opcion)
                {
                case 1:
                    #region Añade Nodo Puente
                    p1   = e.Location;
                    pe.X = p1.X - (tamNodo / 2);
                    pe.Y = p1.Y - (tamNodo / 2);
                    nodo = new Nodo(nombre, pe, p1, penNodo.Color, brushRelleno.Color, brushName.Color, tamNodo, altoName, anchoLineaN, fuente);
                    if (numNodos == 27)
                    {
                        bandNombre = true;
                        grafo.Tipo = true;
                    }
                    this.bandChingSu = bandFinal = grafo.AddKuratoswki(nodo, p1);
                    #endregion
                    break;

                case 2:
                    #region Borra Arista
                    if (grafo.BorraArista(e.Location) == 1)
                    {
                        this.bandChingSu = true;
                    }
                    bandFinal = false;
                    #endregion
                    break;

                case 3:
                    #region BorraNodo
                    p1 = e.Location;
                    if (grafo.BuscaNodo(ref nodo, p1))
                    {
                        grafo.borraNodo(nodo);
                        this.bandChingSu = true;
                        this.Kuratowski_Paint(this, null);
                    }
                    #endregion
                    break;
                }
                this.Kuratowski_Paint(this, null);
            }
        }
Ejemplo n.º 2
0
        private void GrafoSecundario_MouseDown(object sender, MouseEventArgs e)
        {
            switch (opcion)
            {
            case 1:    //Insertar Nodo
                p1   = e.Location;
                pe.X = p1.X - (tamNodo / 2);
                pe.Y = p1.Y - (tamNodo / 2);
                nodo = new Nodo(nombre, pe, p1, penNodo.Color, brushRelleno.Color, brushName.Color, tamNodo, altoName, anchoLineaN, fuente);
                if (numNodos == 27)
                {
                    bandNombre = true;
                    grafo.Tipo = true;
                }
                grafo.Add(nodo);
                band      = false;
                bandFinal = true;
                if (grafo.Count == 1)
                {
                    if (typeof(GrafoDirigido).IsInstanceOfType(grafito))
                    {
                        this.deshabititaOpciones();
                        this.habilitaOpcionesGrafo();
                        this.habilitaOpcionesGrafoDirigido();
                    }
                    else if (typeof(GrafoNoDirigido).IsInstanceOfType(grafito))
                    {
                        this.deshabititaOpciones();
                        this.habilitaOpcionesGrafo();
                        this.habilitaOpcionesGrafoNoDirigido();
                    }
                }
                this.GrafoSecundario_Paint(this, null);
                break;

            case 2:    //AristaNoDirigida
                p1 = e.Location;
                if (grafo.BuscaNodo(ref p1))
                {
                    band       = true;
                    bandArista = true;
                }
                else
                {
                    band       = false;
                    bandArista = false;
                }
                break;

            case 3:
                p1 = e.Location;
                if (grafo.BuscaNodo(ref nodo, p1))
                {
                    grafo.borraNodo(nodo);
                    if (grafo.Count == 0)
                    {
                        this.grafo = new Grafo(this.grafo);
                        this.deshabititaOpciones();
                    }
                    this.GrafoSecundario_Paint(this, null);
                }
                break;

            case 4:    //Mover Nodo
                p1        = e.Location;
                bandFinal = grafo.BuscaNodo(ref nodo, p1);
                break;

            case 5:    //Mover Grafo
                p1        = e.Location;
                bandFinal = grafo.BuscaNodo(ref nodo, p1);
                break;

            case 6:    //EliminaArista
                grafo.BorraArista(e.Location);
                if (grafo.Aristas == 0)
                {
                    this.numAristas = 0;
                    if (typeof(GrafoDirigido).IsInstanceOfType(grafito))
                    {
                        this.deshabititaOpciones();
                        this.habilitaOpcionesGrafo();
                        this.habilitaOpcionesGrafoDirigido();
                    }
                    else if (typeof(GrafoNoDirigido).IsInstanceOfType(grafito))
                    {
                        this.deshabititaOpciones();
                        this.habilitaOpcionesGrafo();
                        this.habilitaOpcionesGrafoNoDirigido();
                    }
                }
                bandFinal = false;
                this.GrafoSecundario_Paint(this, null);
                break;

            case 7:    //AristaDirigida
                p1 = e.Location;
                if (grafo.BuscaNodo(ref p1))
                {
                    band       = true;
                    bandArista = true;
                }
                else
                {
                    band       = false;
                    bandArista = false;
                }
                break;
            }
        }