PIbd-23_Starostin_I.K._Lain.../lainer/Lainer1/FormLainerCollection.cs

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