private void controlarLab(Labirinto maze) { for (int i = 0; i < tam; i++) { for (int j = 0; j < tam; j++) { maze.acessar(i, j).pB.MouseClick += ControlsMouseDown; Controls.Add(maze.acessar(i, j).pB); } } }
private void ControlsMouseDown(object sender, MouseEventArgs e) { if (sender.GetType() == typeof(PictureBox)) { PictureBox aux = (PictureBox)sender; for (int i = 0; i < tam; i++) { for (int j = 0; j < tam; j++) { if (aux.Image.Equals(maze.acessar(i, j).btm) && maze.acessar(i, j).cor == Color.Blue) { Correr c = new Correr(maze); if (MessageBox.Show(c.resolver(i, j), "Sair", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK) { this.Close(); } } } } } }
public String resolver(int x, int y) { pilha = new Stack <Stack <Bloco> >(); pilha.Push(new Stack <Bloco>()); pilha.Peek().Push(maze.acessar(x, y)); percorrer(x, y); return("Labirinto Resolvido com Sucesso"); }