ISE_22.Aparyan.Bulldozer.Base/ProjectBulldozer/FormBulldozerCollections.cs

57 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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();
}
}
}