57 lines
2.1 KiB
C#
57 lines
2.1 KiB
C#
using Bulldozer;
|
||
using ProjectBulldozer.Drawning;
|
||
using ProjectBulldozer.Generics;
|
||
using ProjectBulldozer.MovementStrategy;
|
||
namespace ProjectBulldozer
|
||
{
|
||
public partial class FormTractorCollections : Form
|
||
{
|
||
private readonly TractorGenericCollection<DrawingTractor, DrawingObjectTractor> _Tractors;
|
||
public FormTractorCollections()
|
||
{
|
||
InitializeComponent();
|
||
_Tractors = new TractorGenericCollection<DrawingTractor, DrawingObjectTractor>(pictureBoxCollections.Width,
|
||
pictureBoxCollections.Height);
|
||
}
|
||
private void ButtonAddTractor_Click(object sender, EventArgs e)
|
||
{
|
||
if (_Tractors == null) return;
|
||
FormBulldozer form = new();
|
||
if (form.ShowDialog() == DialogResult.OK)
|
||
{
|
||
//проверяем, удалось ли нам загрузить объект
|
||
if (_Tractors + form.SelectedTractor != -1)
|
||
{
|
||
MessageBox.Show("Объект добавлен");
|
||
pictureBoxCollections.Image = _Tractors.ShowTractors();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось добавить объект");
|
||
}
|
||
}
|
||
}
|
||
private void ButtonRemoveTractor_Click(object sender, EventArgs e)
|
||
{
|
||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||
{
|
||
return;
|
||
}
|
||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||
if (_Tractors - pos != null)
|
||
{
|
||
MessageBox.Show("Объект удален");
|
||
pictureBoxCollections.Image = _Tractors.ShowTractors();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось удалить объект");
|
||
}
|
||
}
|
||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||
{
|
||
pictureBoxCollections.Image = _Tractors.ShowTractors();
|
||
}
|
||
}
|
||
}
|