94 lines
3.1 KiB
C#
94 lines
3.1 KiB
C#
using Airbus_Base.DrawningObjects;
|
||
using Airbus_Base.Generics;
|
||
using Airbus_Base.MovementStrategy;
|
||
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;
|
||
|
||
namespace Airbus_Base
|
||
{
|
||
/// <summary>
|
||
/// Форма для работы с набором объектов класса DrawningAirbus
|
||
/// </summary>
|
||
public partial class FormAirplaneCollection : Form
|
||
{
|
||
/// <summary>
|
||
/// Набор объектов
|
||
/// </summary>
|
||
private readonly TheAirplanesGenericCollection<DrawningAirplane, DrawningObjectAirplane> _theAirplanes;
|
||
|
||
/// <summary>
|
||
/// Конструктор
|
||
/// </summary>
|
||
public FormAirplaneCollection()
|
||
{
|
||
InitializeComponent();
|
||
_theAirplanes = new TheAirplanesGenericCollection<DrawningAirplane, DrawningObjectAirplane>
|
||
(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||
}
|
||
|
||
/// <summary>
|
||
/// Добавление объекта в набор
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void ButtonAddAirplane_Click(object sender, EventArgs e)
|
||
{
|
||
FormAirbus form = new();
|
||
if (form.ShowDialog() == DialogResult.OK)
|
||
{
|
||
if (_theAirplanes + form.SelectedAirplane != -1)
|
||
{
|
||
MessageBox.Show("Объект добавлен");
|
||
pictureBoxCollection.Image = _theAirplanes.ShowTheAirplanes();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось добавить объект");
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Удаление объекта из набора
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void ButtonDeleteAirplane_Click(object sender, EventArgs e)
|
||
{
|
||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||
{
|
||
return;
|
||
}
|
||
|
||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||
|
||
if (_theAirplanes - pos != true)
|
||
{
|
||
MessageBox.Show("Объект удален");
|
||
pictureBoxCollection.Image = _theAirplanes.ShowTheAirplanes();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось удалить объект");
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Обновление рисунка по набору
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||
{
|
||
pictureBoxCollection.Image = _theAirplanes.ShowTheAirplanes();
|
||
}
|
||
}
|
||
}
|