using Lab.DrawningObjects; using Lab.Generics; using Lab.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 Lab { public partial class CollectionsFrame : Form { private readonly CarsGenericCollection _cars; public CollectionsFrame() { InitializeComponent(); _cars = new CarsGenericCollection(DrawTank.Width, DrawTank.Height); } private void ButtonAddTank_Click(object sender, EventArgs e) { Frame form = new Frame(); if (form.ShowDialog() == DialogResult.OK) { if (_cars + form.SelectedCar != -1) { MessageBox.Show("Объект добавлен"); DrawTank.Image = _cars.ShowCars(); } else { MessageBox.Show("Не удалось добавить объект"); } } } private void ButtonRemoveCar_Click(object sender, EventArgs e) { if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } int pos = -1; try { pos = Convert.ToInt32(InputNum.Text); } catch (Exception ex) { } if (_cars - pos) { MessageBox.Show("Объект удален"); DrawTank.Image = _cars.ShowCars(); } else { MessageBox.Show("Не удалось удалить объект"); } } private void ButtonRefreshCollection_Click(object sender, EventArgs e) { DrawTank.Image = _cars.ShowCars(); } } }