всё готово
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.TabIndex = 3;
|
||||||
this.buttonAdd.Text = "Добавить";
|
this.buttonAdd.Text = "Добавить";
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
|
@ -13,6 +13,7 @@ namespace Stormtrooper
|
|||||||
public partial class FormAirConfig : Form
|
public partial class FormAirConfig : Form
|
||||||
{
|
{
|
||||||
DrawningMilitaryAirplane _airplane = null;
|
DrawningMilitaryAirplane _airplane = null;
|
||||||
|
private event AirDelegate EventAddAirplane;
|
||||||
public FormAirConfig()
|
public FormAirConfig()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -24,6 +25,7 @@ namespace Stormtrooper
|
|||||||
panelCyan.MouseDown += PanelColor_MouseDown;
|
panelCyan.MouseDown += PanelColor_MouseDown;
|
||||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||||
|
buttonCancel.Click += (object sender, EventArgs e) => Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawAirplane()
|
private void DrawAirplane()
|
||||||
@ -34,6 +36,17 @@ namespace Stormtrooper
|
|||||||
_airplane?.DrawAirplane(gr);
|
_airplane?.DrawAirplane(gr);
|
||||||
pictureBoxShow.Image = bmp;
|
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)
|
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,32 +78,26 @@ namespace Stormtrooper
|
|||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
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)
|
if (listBoxMap.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MainForm form = new();
|
DrawningObject airplane = new(drawningMilitaryAirplane);
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (_mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty] + airplane != -1)
|
||||||
{
|
{
|
||||||
if(form.SelectedAirplane != null)
|
MessageBox.Show("Объект добавлен");
|
||||||
{
|
pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
DrawningObject airplane = new (form.SelectedAirplane);
|
}
|
||||||
if (_mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty] + airplane != -1)
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект не создан");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -16,7 +16,7 @@ namespace Stormtrooper
|
|||||||
{
|
{
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new FormAirConfig());
|
Application.Run(new FormMapWithSetAirplane());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user