//Loading grid from the list private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { foreach (string map in maps) { string[] dataNew = map.Split(';'); if (comboBox1.Text == dataNew[0]) { rozmiar = Int32.Parse(dataNew[1]); int start = Int32.Parse(dataNew[2]); int end = Int32.Parse(dataNew[3]);; lista_cell = Map.lista(rozmiar); string[] obstaclesNew = dataNew[4].Split(','); Map.SetParametsForLoadedList(lista_cell, start, end, obstaclesNew, this); Controls.Clear(); InitializeComponent(); label1.Text = (lista_cell[start].x).ToString(); label2.Text = (lista_cell[start].y).ToString(); label4.Text = (lista_cell[end].x).ToString(); label5.Text = (lista_cell[end].y).ToString(); Map.PaintMap(this, rozmiar); Map.Repaint(lista_cell, this); Map.DisplayLoadedMap(maps, this); ElementsManagment.ChangeList(this); } } }
//reset private void reset_Click(object sender, EventArgs e) { Controls.Clear(); InitializeComponent(); Map.DisplayLoadedMap(maps, this); ElementsManagment.ChangeReset(this); }
//Creating the grid private void button2_Click(object sender, EventArgs e) { if (textBox1.Text.Trim() != string.Empty) { if (Int32.Parse(textBox1.Text) > 1 && Int32.Parse(textBox1.Text) < 100) { rozmiar = Int32.Parse(textBox1.Text); lista_cell = Map.lista(rozmiar); Map.PaintMap(this, rozmiar); ElementsManagment.ChangeGrid(this); } else { MessageBox.Show("Please enter the correct grid size (2-99)"); } } else { MessageBox.Show("Please enter the grid size"); } }
//Program starts public Form1() { InitializeComponent(); Map.DisplayLoadedMap(maps, this); ElementsManagment.ChangeStart(this); }