2023-10-21 15:06:49 +04:00

90 lines
3.0 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 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 ProjectBomber.MovementStrategy;
using ProjectBomber.Generics;
using ProjectBomber.DrawningObjects;
namespace ProjectBomber
{
/// <summary>
/// Форма для работы с набором объектов класса DrawningCar
/// </summary>
public partial class FormPlaneCollection : Form
{
/// <summary>
/// Набор объектов
/// </summary>
private readonly PlanesGenericCollection<DrawningBomber,
DrawningObjectBomber> _planes;
/// <summary>
/// Конструктор
/// </summary>
public FormPlaneCollection()
{
InitializeComponent();
_planes = new PlanesGenericCollection<DrawningBomber,
DrawningObjectBomber>(pictureBoxCollection.Width, pictureBoxCollection.Height);
}
/// <summary>
/// Добавление объекта в набор
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddPlane_Click(object sender, EventArgs e)
{
FormBomber form = new FormBomber();
if (form.ShowDialog() == DialogResult.OK)
{
if (_planes + form.SelectedBomber != 1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = _planes.ShowPlanes();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
}
/// <summary>
/// Удаление объекта из набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonRemovePlane_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Удалить объект?", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
if (_planes - pos != null)
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = _planes.ShowPlanes();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
/// <summary>
/// Обновление рисунка по набору
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
{
pictureBoxCollection.Image = _planes.ShowPlanes();
}
}
}