using Hydroplane.DrawningObjects; using Hydroplane.Generics; using Hydroplane.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 Hydroplane { public partial class FormHydroplaneCollection : Form { private readonly PlanesGenericCollection _planes; public FormHydroplaneCollection() { InitializeComponent(); _planes = new PlanesGenericCollection(DrawPlane.Width, DrawPlane.Height); } private void ButtonAddTank_Click(object sender, EventArgs e) { FormHydroplane form = new FormHydroplane(); if (form.ShowDialog() == DialogResult.OK) { if (_planes + form.SelectedPlane != -1) { MessageBox.Show("Объект добавлен"); DrawPlane.Image = _planes.ShowPlanes(); } 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 (_planes - pos) { MessageBox.Show("Объект удален"); DrawPlane.Image = _planes.ShowPlanes(); } else { MessageBox.Show("Не удалось удалить объект"); } } private void ButtonRefreshCollection_Click(object sender, EventArgs e) { DrawPlane.Image = _planes.ShowPlanes(); } } }