PIbd-22_Isaeva_A.I._Airbus_.../Airbus/FormAirbusCollection.cs

80 lines
2.4 KiB
C#
Raw Normal View History

2023-11-18 10:47:46 +04:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ProjectAirbus.Generics;
using ProjectAirbus.Drawnings;
using ProjectAirbus.MovementStrategy;
namespace ProjectAirbus
{
public partial class FormAirbusCollection : Form
{
// Набор объектов
private readonly AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus> _airbus;
public FormAirbusCollection()
{
InitializeComponent();
_airbus = new AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>(pictureBoxCollection.Width, pictureBoxCollection.Height);
}
// добавить в набор
private void buttonAdd_Click(object sender, EventArgs e)
{
FormPlane form = new();
if (form.ShowDialog() == DialogResult.OK)
{
if (_airbus + form.SelectedAirbus != -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = _airbus.ShowAirbus();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
}
// удалить
private void buttonDelete_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = 0;
try
{
pos = Convert.ToInt32(maskedTextBoxNumber.Text);
}
catch
{
MessageBox.Show("Ошибка ввода данных");
return;
}
if (_airbus - pos)
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = _airbus.ShowAirbus();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
// обновить
private void buttonUpdate_Click(object sender, EventArgs e)
{
pictureBoxCollection.Image = _airbus.ShowAirbus();
}
}
}