2022-10-03 03:04:38 +04:00
|
|
|
|
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 AirFighter
|
|
|
|
|
{
|
|
|
|
|
public partial class FormMapWithSetAircrafts : Form
|
|
|
|
|
{
|
|
|
|
|
private MapWithSetAircraftsGeneric<DrawingObjectAircraft, AbstractMap> _mapAircraftsCollectionGeneric;
|
|
|
|
|
|
|
|
|
|
public FormMapWithSetAircrafts()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowMapButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_mapAircraftsCollectionGeneric == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
pictureBox.Image = _mapAircraftsCollectionGeneric.ShowOnMap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void comboBoxMapSelection_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
AbstractMap map = null;
|
|
|
|
|
switch (comboBoxMapSelection.Text)
|
|
|
|
|
{
|
|
|
|
|
case "1. Simple map":
|
|
|
|
|
{
|
|
|
|
|
map = new SimpleMap();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "2. NightSky map":
|
|
|
|
|
{
|
|
|
|
|
map = new NightSkyMap();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (map != null)
|
|
|
|
|
{
|
|
|
|
|
_mapAircraftsCollectionGeneric = new MapWithSetAircraftsGeneric<DrawingObjectAircraft, AbstractMap>(pictureBox.Width, pictureBox.Height, map);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_mapAircraftsCollectionGeneric = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddAircraftButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_mapAircraftsCollectionGeneric == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
AirFighterForm form = new();
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
DrawingObjectAircraft aircraft = new(form.SelectedAircraft);
|
2022-10-03 16:12:35 +04:00
|
|
|
|
if (_mapAircraftsCollectionGeneric + aircraft != -1)
|
2022-10-03 03:04:38 +04:00
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Object is added");
|
|
|
|
|
pictureBox.Image = _mapAircraftsCollectionGeneric.ShowSet();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Unable to add object");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DeleteAircraftButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(maskedTextBoxPostion.Text))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (MessageBox.Show("Delete object?", "Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int pos = Convert.ToInt32(maskedTextBoxPostion.Text);
|
2022-10-03 16:12:35 +04:00
|
|
|
|
if (_mapAircraftsCollectionGeneric - pos != null)
|
2022-10-03 03:04:38 +04:00
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Object is deleted");
|
|
|
|
|
pictureBox.Image = _mapAircraftsCollectionGeneric.ShowSet();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Unable to delete object");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowHangarButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_mapAircraftsCollectionGeneric == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
pictureBox.Image = _mapAircraftsCollectionGeneric.ShowSet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ButtonMove_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_mapAircraftsCollectionGeneric == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
|
|
|
Direction dir = Direction.None;
|
|
|
|
|
switch (name)
|
|
|
|
|
{
|
|
|
|
|
case "buttonUp":
|
|
|
|
|
{
|
|
|
|
|
dir = Direction.Up;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "buttonDown":
|
|
|
|
|
{
|
|
|
|
|
dir = Direction.Down;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "buttonLeft":
|
|
|
|
|
{
|
|
|
|
|
dir = Direction.Left;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "buttonRight":
|
|
|
|
|
{
|
|
|
|
|
dir = Direction.Right;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
pictureBox.Image = _mapAircraftsCollectionGeneric.MoveObject(dir);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|