private void tr_Click(object sender, EventArgs e) { listBox1.Visible = false; TrainControl poezd = (TrainControl)sender; // poezd.Location = new Point(20, 20); // poezd.ctrl_x = 20; for (int i = 0; i < dataGridView1.RowCount; i++) { dataGridView1.Rows.RemoveAt(i); i--; } //dataGridView1.Rows.Add(); listBox1.Items.Clear(); for (int i = 0; i < poezd.coll_train.Count; i++) { dataGridView1.Rows.Add(); if (poezd.coll_train[i].motion) { dataGridView1.Visible = true; // listBox1.Items.Add("Поезд № " + poezd.coll_train[i].Nomer + ' ' + "В пути"); // dataGridView1.Size = new Size(319, 58 * i); dataGridView1.Rows[i].Cells[0].Value = poezd.coll_train[i].Nomer; dataGridView1.Rows[i].Cells[1].Value = "В пути"; dataGridView1.Rows[i].Cells[2].Value = poezd.coll_train[i].last_stops; // dataGridView1.AllowUserToAddRows = false; } else { dataGridView1.Visible = true; // dataGridView1.Size = new Size(319, 58 * i); //listBox1.Items.Add("Поезд № " + poezd.coll_train[i].Nomer + ' ' + "Стоит"); dataGridView1.Rows[i].Cells[0].Value = poezd.coll_train[i].Nomer; dataGridView1.Rows[i].Cells[1].Value = "Cтоит"; dataGridView1.Rows[i].Cells[2].Value = poezd.coll_train[i].last_stops; // dataGridView1.AllowUserToAddRows = false; } } dataGridView1.Location = new Point(poezd.ctrl_x, 40 + poezd.ctrl_y); // dataGridView1.AllowUserToAddRows = false; // dataGridView1.Rows.RemoveAt(dataGridView1.Rows.Count-1); // listBox1.Size = new Size(115, 75); // listBox1.Visible = true; // listBox1.Location = new Point(poezd.ctrl_x, 40 + poezd.ctrl_y); }
///////////////////////////////////////////////// public void create_ctrl() { bool flag1 = true; bool flag2 = true; bool flag3 = true; List<Stops> list_ostanovok=null; int count = 0; int i = 0, q = 0; while (flag1) { while (flag2) { while (flag3) { if (current_trains[i].ID == marshruti[q].ID) { list_ostanovok = marshruti[q].Ostanovki; flag3 = false; q = 0; } else { q++; } } if (current_trains[i].last_stops == list_ostanovok[count].Name) { if (list_ctrl_train.Count == 0) { TrainControl tr = new TrainControl(list_ostanovok[count].X - 10 + current_trains[i].X_din, list_ostanovok[count].Y - 22 + current_trains[i].Y_din); // pictureBox1.Controls.Add(tr); tr.coll_train.Add(current_trains[i]); i++; flag2 = false; list_ctrl_train.Add(tr); // tr.Click += new System.EventHandler(tr_Click); // tr.MouseEnter += new System.EventHandler(tr_MouseEnter); // tr.MouseLeave += new System.EventHandler(tr_MouseLeave); } else { for (int k = 0; k < list_ctrl_train.Count; k++) { TrainControl test_tr; test_tr = list_ctrl_train[k]; if (i < current_trains.Count) { if ((test_tr.ctrl_x == (list_ostanovok[count].X - 10 + current_trains[i].X_din)) & (test_tr.ctrl_y == (list_ostanovok[count].Y - 22 + current_trains[i].Y_din))) { test_tr.coll_train.Add(current_trains[i]); i++; flag2 = false; } } } if (flag2 == true) { TrainControl tr = new TrainControl(list_ostanovok[count].X - 10 + current_trains[i].X_din, list_ostanovok[count].Y - 22 + current_trains[i].Y_din); // tr.Click += new System.EventHandler(tr_Click); // tr.MouseEnter += new System.EventHandler(tr_MouseEnter); // tr.MouseLeave += new System.EventHandler(tr_MouseLeave); // pictureBox1.Controls.Add(tr); tr.coll_train.Add(current_trains[i]); i++; flag2 = false; list_ctrl_train.Add(tr); } } } else { count++; } } if (i == current_trains.Count) { flag1 = false; flag2 = false; flag3 = false; } else { flag2 = true; flag3 = true; count = 0; } } }
public void create_ctrl() { bool flag1 = true; bool flag2 = true; bool flag3 = true; int count = 0; int i = 0, q = 0; while (flag1) { //count = 0; // for (int count = 0; count < list_ostanovok.Count; count++) while (flag2) { while (flag3) { if (list_poezdov[i].ID == marshruts[q].ID) { list_ostanovok = marshruts[q].Ostanovki; flag3 = false; q = 0; } else { q++; } } // if (count>) if (list_poezdov[i].last_stops == list_ostanovok[count].Name) { if (list_ctrl_train.Count == 0) { TrainControl tr = new TrainControl(list_ostanovok[count].X - 10, list_ostanovok[count].Y - 22); pictureBox1.Controls.Add(tr); tr.coll_train.Add(list_poezdov[i]); i++; flag2 = false; list_ctrl_train.Add(tr); tr.Click += new System.EventHandler(tr_Click); tr.MouseEnter += new System.EventHandler(tr_MouseEnter); tr.MouseLeave += new System.EventHandler(tr_MouseLeave); } else { for (int k = 0; k < list_ctrl_train.Count; k++) { TrainControl test_tr; test_tr = list_ctrl_train[k]; if ((test_tr.ctrl_x == (list_ostanovok[count].X - 10)) & (test_tr.ctrl_y == (list_ostanovok[count].Y - 22))) { test_tr.coll_train.Add(list_poezdov[i]); i++; flag2 = false; } } if (flag2 == true) { TrainControl tr = new TrainControl(list_ostanovok[count].X - 10, list_ostanovok[count].Y - 22); tr.Click += new System.EventHandler(tr_Click); tr.MouseEnter += new System.EventHandler(tr_MouseEnter); tr.MouseLeave += new System.EventHandler(tr_MouseLeave); pictureBox1.Controls.Add(tr); tr.coll_train.Add(list_poezdov[i]); i++; flag2 = false; list_ctrl_train.Add(tr); } } } else { count++; } } //count++; if (i == list_poezdov.Count) { flag1 = false; flag2 = false; flag3 = false; } else { flag2 = true; flag3 = true; count = 0; } } }
private void tr_MouseLeave(object sender, EventArgs e) { TrainControl poezd = (TrainControl)sender; poezd.Size = new Size(21, 23); }
private void tr_MouseEnter(object sender, EventArgs e) { TrainControl poezd = (TrainControl)sender; poezd.Size = new Size(30, 30); }