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; using ProjectGasolineTanker.Drawings; using ProjectGasolineTanker.Generic; using ProjectGasolineTanker.MovementStratg; namespace ProjectGasolineTanker { public partial class FormTruckCollection : Form { private readonly TruckGenericCollection _truck; public FormTruckCollection() { InitializeComponent(); _truck = new TruckGenericCollection(pictureBoxCollection.Width, pictureBoxCollection.Height); } private void ButtonAddTruck_Click(object sender, EventArgs e) { FormGasolineTanker form = new(); if (form.ShowDialog() == DialogResult.OK) { if (_truck + form.SelectedTruck != -1) { MessageBox.Show("Объект добавлен"); pictureBoxCollection.Image = _truck.ShowTruck(); } else { MessageBox.Show("Не удалось добавить объект"); } } } private void ButtonRemoveTruck_Click(object sender, EventArgs e) { if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } int pos = 0; try { pos = Convert.ToInt32(maskedTextBoxNumber.Text) ; } catch { MessageBox.Show("Ошибка ввода данных"); return; } if (_truck - (_truck.ReturnLength() - pos)) { MessageBox.Show("Объект удален"); pictureBoxCollection.Image = _truck.ShowTruck(); } else { MessageBox.Show("Не удалось удалить объект"); } } private void ButtonRefreshCollection_Click(object sender, EventArgs e) { pictureBoxCollection.Image = _truck.ShowTruck(); } } }