63 lines
2.2 KiB
C#
63 lines
2.2 KiB
C#
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 AircraftCarrier.DrawningObjects;
|
||
using AircraftCarrier.Generics;
|
||
using AircraftCarrier.MovementStrategy;
|
||
namespace AircraftCarrier
|
||
{
|
||
public partial class FormAircraftCollection : Form
|
||
{
|
||
private readonly AircraftsGenericCollection<DrawningAircraft, DrawningObjectAircraft> _Aircrafts;
|
||
public FormAircraftCollection()
|
||
{
|
||
InitializeComponent();
|
||
_Aircrafts = new AircraftsGenericCollection<DrawningAircraft, DrawningObjectAircraft>(PictureBoxCollection.Width, PictureBoxCollection.Height);
|
||
}
|
||
private void ButtonAddAircraft_Click(object sender, EventArgs e)
|
||
{
|
||
FormAircraftCarrier form = new();
|
||
if (form.ShowDialog() == DialogResult.OK)
|
||
{
|
||
if (_Aircrafts + form.SelectedAircraft != -1)
|
||
{
|
||
MessageBox.Show("Объект добавлен");
|
||
PictureBoxCollection.Image = _Aircrafts.ShowAircraft();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось добавить объект");
|
||
}
|
||
}
|
||
|
||
}
|
||
private void ButtonRemoveAircraft_Click(object sender, EventArgs e)
|
||
{
|
||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||
{
|
||
return;
|
||
}
|
||
int pos = Convert.ToInt32(MaskedTextBoxNumber.Text);
|
||
if (_Aircrafts - pos != null)
|
||
{
|
||
MessageBox.Show("Объект удален");
|
||
PictureBoxCollection.Image = _Aircrafts.ShowAircraft();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("Не удалось удалить объект");
|
||
}
|
||
}
|
||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||
{
|
||
PictureBoxCollection.Image = _Aircrafts.ShowAircraft();
|
||
}
|
||
}
|
||
}
|