public void DibujarCamino() { int px = fin.First; int py = fin.Second; int Px = Matriz[py][px].getPadre().First; int Py = Matriz[py][px].getPadre().Second; px = Px; py = Py; int ix = ListaCerrada[0].First; int iy = ListaCerrada[0].Second; while (px != ix || py != iy) { if (px != ix || py != iy) { Boton_panel b = Matriz[py][px].getButton(); b.panel.BackColor = Color.Red; MessageBox.Show("SIGUIENTE: " + Matriz[py][px].getPadre().First + " " + Matriz[py][px].getPadre().Second); Px = Matriz[py][px].getPadre().First; Py = Matriz[py][px].getPadre().Second; px = Px; py = Py; } } Boton_panel b2 = Matriz[iy][ix].getButton(); b2.panel.BackColor = Color.Red; }
public Nodo(int id, Pair <int, int> padre, Boton_panel button, string nombre, int f, int g, int h, Pair <int, int> coords) { this.id = id; this.padre = padre; this.button = button; this.nombre = nombre; this.F = f; this.G = g; this.H = h; this.tipo = 1; this.coords = coords; this.visitado = false; }
public void crearMapa(Control control) { int ch = 65; string Ch; for (int i = 0; i < Alto; i++) { List <Nodo> fila = new List <Nodo>(); for (int j = 0; j < Ancho; j++) { Ch = Convert.ToChar(ch) + Convert.ToString(j + 1); Boton_panel button = new Boton_panel(50 * (j + 1), 50 * (i + 1), Ch); button.setName(Ch); button.panel.Click += new EventHandler(btn_marcar); control.Controls.Add(button.panel); Pair <int, int> coords = new Pair <int, int>(j, i); Nodo nodo = new Nodo((i * Ancho) + j + 1, null, button, "" + Ch, 0, 0, 0, coords); fila.Add(nodo); } this.Matriz.Add(fila); ch++; } Button Empezar = new Button(); Empezar.Text = "Empezar"; Empezar.Width = 70; Empezar.Height = 40; Empezar.Left = 50 * (Ancho + 2); Empezar.Top = 50; Empezar.Click += new EventHandler(clickButton); control.Controls.Add(Empezar); Label listaAbierta = new Label(); listaAbierta.Text = "LISTA ABIERTA:"; listaAbierta.Top = 52 * (Alto + 1); listaAbierta.Left = 100; Label listaCerrada = new Label(); listaCerrada.Text = "LISTA CERRADA:"; listaCerrada.Top = 52 * (Alto + 2); listaCerrada.Left = 100; Label listaAbiertaL = new Label(); listaAbiertaL.Text = ""; listaAbiertaL.Top = 52 * (Alto + 1); listaAbiertaL.Left = 200; listaAbiertaL.Name = "LA"; Label listaCerradaL = new Label(); listaCerradaL.Text = ""; listaCerradaL.Top = 52 * (Alto + 2); listaCerradaL.Left = 200; listaCerradaL.Name = "LC"; control.Controls.Add(listaAbierta); control.Controls.Add(listaCerrada); control.Controls.Add(listaAbiertaL); control.Controls.Add(listaCerradaL); control.Height = 52 * (Alto + 4); control.Width = 50 * (Ancho + 5); this.control = control; //control.Controls.Add(panel); }
public void setButton(Boton_panel button) { this.button = button; }