всё готово
This commit is contained in:
parent
b82e72038d
commit
f3d2973c84
10
Stormtrooper/Stormtrooper/AirDelegate.cs
Normal file
10
Stormtrooper/Stormtrooper/AirDelegate.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Stormtrooper
|
||||
{
|
||||
public delegate void AirDelegate(DrawningMilitaryAirplane airplane);
|
||||
}
|
@ -334,6 +334,7 @@
|
||||
this.buttonAdd.TabIndex = 3;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
|
@ -13,6 +13,7 @@ namespace Stormtrooper
|
||||
public partial class FormAirConfig : Form
|
||||
{
|
||||
DrawningMilitaryAirplane _airplane = null;
|
||||
private event AirDelegate EventAddAirplane;
|
||||
public FormAirConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -24,6 +25,7 @@ namespace Stormtrooper
|
||||
panelCyan.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
buttonCancel.Click += (object sender, EventArgs e) => Close();
|
||||
}
|
||||
|
||||
private void DrawAirplane()
|
||||
@ -34,6 +36,17 @@ namespace Stormtrooper
|
||||
_airplane?.DrawAirplane(gr);
|
||||
pictureBoxShow.Image = bmp;
|
||||
}
|
||||
public void AddEvent(AirDelegate ev)
|
||||
{
|
||||
if (EventAddAirplane == null)
|
||||
{
|
||||
EventAddAirplane = new AirDelegate(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddAirplane += ev;
|
||||
}
|
||||
}
|
||||
|
||||
private void label_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
@ -118,5 +131,11 @@ namespace Stormtrooper
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddAirplane?.Invoke(_airplane);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,17 +78,18 @@ namespace Stormtrooper
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formLocomotiveConfig = new FormAirConfig();
|
||||
formLocomotiveConfig.AddEvent(AddLocomotive);
|
||||
formLocomotiveConfig.Show();
|
||||
}
|
||||
private void AddLocomotive(DrawningMilitaryAirplane drawningMilitaryAirplane)
|
||||
{
|
||||
if (listBoxMap.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MainForm form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if(form.SelectedAirplane != null)
|
||||
{
|
||||
DrawningObject airplane = new (form.SelectedAirplane);
|
||||
DrawningObject airplane = new(drawningMilitaryAirplane);
|
||||
if (_mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty] + airplane != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
@ -99,13 +100,6 @@ namespace Stormtrooper
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Объект не создан");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта
|
||||
/// </summary>
|
||||
|
@ -16,7 +16,7 @@ namespace Stormtrooper
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new FormAirConfig());
|
||||
Application.Run(new FormMapWithSetAirplane());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user