PIbd-22_Fedorenko_G.Y._Hydr.../Hydroplane/FormHydroplaneCollection.cs

73 lines
2.2 KiB
C#
Raw Normal View History

2023-10-25 02:19:13 +04:00
using Hydroplane.DrawningObjects;
using Hydroplane.Generics;
using Hydroplane.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 Hydroplane
{
public partial class FormHydroplaneCollection : Form
{
2023-10-25 02:19:13 +04:00
private readonly PlanesGenericCollection<DrawningPlane, DrawningObjectPlane> _planes;
public FormHydroplaneCollection()
{
InitializeComponent();
2023-10-25 02:19:13 +04:00
_planes = new PlanesGenericCollection<DrawningPlane, DrawningObjectPlane>(DrawPlane.Width, DrawPlane.Height);
}
private void ButtonAddTank_Click(object sender, EventArgs e)
{
FormHydroplane form = new FormHydroplane();
if (form.ShowDialog() == DialogResult.OK)
{
if (_planes + form.SelectedPlane != -1)
{
MessageBox.Show("Объект добавлен");
DrawPlane.Image = _planes.ShowPlanes();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
}
private void ButtonRemoveCar_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Удалить объект?", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = -1;
try
{
pos = Convert.ToInt32(InputNum.Text);
}
catch (Exception ex) { }
if (_planes - pos)
{
MessageBox.Show("Объект удален");
DrawPlane.Image = _planes.ShowPlanes();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
{
DrawPlane.Image = _planes.ShowPlanes();
}
}
}