PIbd_23_Kislitsa_E.D_AirFig.../AirFighter/FormAirplaneCollection.cs
2023-10-15 16:11:27 +03:00

70 lines
2.2 KiB
C#
Raw Permalink 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 ProjectAirFighter.DrawningObjects;
using ProjectAirFighter.Generics;
using ProjectAirFighter.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 ProjectAirFighter
{
public partial class FormAirplaneCollection : Form
{
private readonly AirplaneslGenericCollection<DrawningAirplane, DrawningObjectAirplane> _airplanes;
public FormAirplaneCollection()
{
InitializeComponent();
_airplanes = new AirplaneslGenericCollection<DrawningAirplane,
DrawningObjectAirplane>(pictureBoxCollection.Width, pictureBoxCollection.Height);
}
private void deleteAirplaneButton_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Удалить объект?", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = Convert.ToInt32(maskedTextBox.Text);
if (_airplanes - pos != null)
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = _airplanes.ShowAirplanes();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
private void updateCollectionButton_Click(object sender, EventArgs e)
{
pictureBoxCollection.Image = _airplanes.ShowAirplanes();
}
private void addAirplaneButton_Click(object sender, EventArgs e)
{
FormAirFighter form = new();
if (form.ShowDialog() == DialogResult.OK)
{
if (_airplanes + form.SelectedAirplane != null)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = _airplanes.ShowAirplanes();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
}
}
}