Beispiel #1
0
        private void Form_Editor_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                foreach (Vertice v in vertices)
                {
                    if (v.Adentro(e.Location))
                    {
                        selVertice = v;
                        seleccion  = true;

                        foreach (Arista ar in aristas)
                        {
                            if (selVertice.getNum() == ar.getNumA())
                            {
                                arisCopia = ar;
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void Form_Editor_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            bool band = false;

            aristaSel = null;

            if (e.Button == MouseButtons.Left) // si es el click izquierdo, se ve los datos del nodo
            {
                if (vertices.Count != 0)
                {
                    foreach (Vertice v in vertices)
                    {
                        if (v.Adentro(e.Location))
                        {
                            band = true;
                            lb_config.Items.Clear();
                            lb_config.Items.Add("Numero de Nodo: " + v.getNum());
                            if (v.getDirig() == true)
                            {
                                lb_config.Items.Add("Grafo dirigido");
                            }
                            else
                            {
                                lb_config.Items.Add("Grafo no dirigido");
                            }

                            foreach (Arista a in aristas)
                            {
                                if (v.getNum() == a.getNumA())
                                {
                                    lb_config.Items.Add("Peso de la arista:" + a.getPeso().Text);
                                }
                            }
                            break;
                        }
                    }

                    if (!band)
                    {
                        band = false;
                        vertices.Add(new Vertice(e.X, e.Y, radio, check_nodoDir.Checked)); //Se agrega un nuevo nodo
                        Refresh();
                    }
                }
                else
                {
                    vertices.Add(new Vertice(e.X, e.Y, radio, check_nodoDir.Checked));
                    Refresh();
                }
            }
            else if (e.Button == MouseButtons.Right) //si es el derecho se agregara una nueva arista
            {
                foreach (Vertice v in vertices)
                {
                    if (v.Adentro(e.Location))
                    {
                        //Creacion del nuevo label numero de peso
                        Label lab = new Label();
                        lab.Name   = "numPeso" + v.getNum();
                        lab.Width  = 20;
                        lab.Height = 20;
                        Controls.Add(lab); //Controls para agregar el Label a la forma

                        aristaSel = new Arista(v, radio, lab);

                        aristas.Add(aristaSel);
                        if (arisOri == null) //primer nodo seleccionado
                        {
                            arisOri = aristaSel;
                        }
                        else
                        {
                            if (aristaSel != null) //segundo nodo
                            {
                                arisOri.ConectarA(aristaSel);
                            }
                            arisOri = null;
                            Refresh();
                        }
                    }
                }
            }
        }
Beispiel #3
0
 public void Desconectar(Arista a)
 {
     conec.Remove(a);
 }
Beispiel #4
0
 public void ConectarA(Arista a)
 {
     conec.Add(a);
 }