using RoadTrain.DrawningObjects; using RoadTrain.Generics; using RoadTrain.MovementStrategy; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace RoadTrain { public partial class FormTrainCollection : Form { private readonly RoadTrainGenericCollection _trains; public FormTrainCollection() { InitializeComponent(); _trains = new RoadTrainGenericCollection(pictureBoxCollection.Width, pictureBoxCollection.Height); } private void ButtonAddTrain_Click(object sender, EventArgs e) { FormRoadTrain form = new(); if (form.ShowDialog() == DialogResult.OK) { if (_trains + form.SelectedTrain != -1) { MessageBox.Show("Объект добавлен"); pictureBoxCollection.Image = _trains.ShowTrains(); } else { MessageBox.Show("Не удалось добавить объект"); } } } private void ButtonRemoveTrain_Click(object sender, EventArgs e) { if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } int pos = Convert.ToInt32(InputTextBox.Text); if (_trains - pos != null) { MessageBox.Show("Объект удален"); pictureBoxCollection.Image = _trains.ShowTrains(); } else { MessageBox.Show("Не удалось удалить объект"); } } private void ButtonRefreshCollection_Click(object sender, EventArgs e) { pictureBoxCollection.Image = _trains.ShowTrains(); } } }