73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
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
|
||
{
|
||
private readonly PlanesGenericCollection<DrawningPlane, DrawningObjectPlane> _planes;
|
||
|
||
public FormHydroplaneCollection()
|
||
{
|
||
InitializeComponent();
|
||
_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();
|
||
}
|
||
}
|
||
}
|