66 lines
2.4 KiB
C#
66 lines
2.4 KiB
C#
|
using WarmlyLocomotive.DrawningObjects;
|
|||
|
using WarmlyLocomotive.Generics;
|
|||
|
using WarmlyLocomotive.MovementStrategy;
|
|||
|
|
|||
|
namespace WarmlyLocomotive
|
|||
|
{
|
|||
|
public partial class FormWarmlyLocomotiveCollection : Form
|
|||
|
{
|
|||
|
private readonly CarsGenericCollection<DrawningWarmlyLocomotive,
|
|||
|
DrawningObjectCar> _warmlylocomotives;
|
|||
|
public FormWarmlyLocomotiveCollection()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
_warmlylocomotives = new CarsGenericCollection<DrawningWarmlyLocomotive, DrawningObjectCar>(pictureBoxCollectionWarmlyLocomotive.Width, pictureBoxCollectionWarmlyLocomotive.Height);
|
|||
|
}
|
|||
|
|
|||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
WarmlyLocomotiveForm form = new();
|
|||
|
if (form.ShowDialog() == DialogResult.OK)
|
|||
|
{
|
|||
|
if (_warmlylocomotives + form.SelectedCar != null)
|
|||
|
{
|
|||
|
MessageBox.Show("Объект добавлен");
|
|||
|
pictureBoxCollectionWarmlyLocomotive.Image = _warmlylocomotives.ShowCars();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
MessageBox.Show("Не удалось добавить объект");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void buttonreFreshCollection_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
pictureBoxCollectionWarmlyLocomotive.Image = _warmlylocomotives.ShowCars();
|
|||
|
}
|
|||
|
|
|||
|
private void buttonRemove_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (MessageBox.Show("Удалить объект?", "Удаление",
|
|||
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
int pos;
|
|||
|
if (textBoxCollectionWarmlyLocomotive.Text == null || !int.TryParse(textBoxCollectionWarmlyLocomotive.Text, out pos))
|
|||
|
{
|
|||
|
MessageBox.Show("Введите номер парковочного места");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (_warmlylocomotives - pos != null)
|
|||
|
{
|
|||
|
MessageBox.Show("Объект удален");
|
|||
|
pictureBoxCollectionWarmlyLocomotive.Image = _warmlylocomotives.ShowCars();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
MessageBox.Show("Не удалось удалить объект");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|