60 lines
2.2 KiB
C#
60 lines
2.2 KiB
C#
using ProjectLainer.DrawningObjects;
|
||
using ProjectLainer.Generics;
|
||
using ProjectLainer.MovementStrategy;
|
||
|
||
namespace ProjectLainer
|
||
{
|
||
public partial class FormLainerCollection : Form
|
||
{
|
||
private readonly LainersGenericCollection<DrawingLainer, DrawningObjectLainer> _lainers;
|
||
public FormLainerCollection()
|
||
{
|
||
InitializeComponent();
|
||
_lainers = new LainersGenericCollection<DrawingLainer, DrawningObjectLainer>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||
}
|
||
private void ButtonAddLainer_Click(object sender, EventArgs e)
|
||
{
|
||
LainerForm form = new();
|
||
if (form.ShowDialog() == DialogResult.OK)
|
||
{
|
||
if (_lainers + form.SelectedLainer)
|
||
{
|
||
MessageBox.Show("Объект добавлен");
|
||
pictureBoxCollection.Image = _lainers.ShowLainers();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось добавить объект");
|
||
}
|
||
}
|
||
}
|
||
private void ButtonRemove_Click(object sender, EventArgs e)
|
||
{
|
||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||
{
|
||
return;
|
||
}
|
||
try
|
||
{
|
||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||
if (_lainers - pos == true)
|
||
{
|
||
MessageBox.Show("Объект удален");
|
||
pictureBoxCollection.Image = _lainers.ShowLainers();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось удалить объект");
|
||
}
|
||
}
|
||
catch { MessageBox.Show("Не удалось удалить объект"); }
|
||
|
||
}
|
||
private void ButtonRefresh_Click(object sender, EventArgs e)
|
||
{
|
||
pictureBoxCollection.Image = _lainers.ShowLainers();
|
||
}
|
||
}
|
||
}
|