This commit is contained in:
devil_1nc 2022-11-22 14:35:09 +04:00
parent bfc075b964
commit 98658b2047
3 changed files with 44 additions and 9 deletions

View File

@ -102,18 +102,25 @@ namespace Airbus
//добавление объекта //добавление объекта
private void ButtonAddPlane_Click(object sender, EventArgs e) private void ButtonAddPlane_Click(object sender, EventArgs e)
{ {
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] == null) var formPlaneConfig = new FormPlaneConfig();
{
//TODO Call method AvvEvent from formPlaneConfig
formPlaneConfig.Show();
////////////// ЭТО
/*if(_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] == null)*/
{
return; return;
} }
FormAirbus form = new(); /*FormAirbus form = new();
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
DrawningObjectPlane plane = new(form.SelectedPlane); DrawningObjectPlane plane = new(form.SelectedPlane);*/
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] + plane != -1) /* if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] + plane != -1)
{ {
MessageBox.Show("Объект добавлен"); MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty].ShowSet(); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty].ShowSet();
@ -122,7 +129,7 @@ namespace Airbus
{ {
MessageBox.Show("Не удалось добавить объект"); MessageBox.Show("Не удалось добавить объект");
} }
} }*/
} }
//удаление объекта //удаление объекта
private void ButtonRemovePlane_Click(object sender, EventArgs e) private void ButtonRemovePlane_Click(object sender, EventArgs e)

View File

@ -14,6 +14,9 @@ namespace Airbus
{//переменная-выбранная машина {//переменная-выбранная машина
DrawningAirbus _plane = null; DrawningAirbus _plane = null;
//событие
private event PlaneDelegate EventAddPlane;
//конструктор //конструктор
public FormPlaneConfig() public FormPlaneConfig()
{ {
@ -28,6 +31,7 @@ namespace Airbus
panelBlue.MouseDown += PanelColor_MouseDown; panelBlue.MouseDown += PanelColor_MouseDown;
} }
//отрисовка самолёт
private void DrawPlane() private void DrawPlane()
{ {
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
@ -36,7 +40,18 @@ namespace Airbus
_plane?.DrawTransport(gr); _plane?.DrawTransport(gr);
pictureBoxObject.Image = bmp; pictureBoxObject.Image = bmp;
} }
//добавление события
public void AddEvent(PlaneDelegate ev)
{
if (EventAddPlane == null)
{
EventAddPlane = new PlaneDelegate(ev);
}
else
{
EventAddPlane += ev;
}
}
private void LabelObject_MouseDown(object sender, MouseEventArgs e) private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{ {
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy); (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
@ -103,9 +118,17 @@ namespace Airbus
//TODO Call method from object _plane is DrawningSuperAirbus and set add color //TODO Call method from object _plane is DrawningSuperAirbus and set add color
} }
private void PanelObject_DragEnter(object sender, EventArgs e) //добавление самолета
private void ButtonAddObject_Click(object sender, EventArgs e)
{ {
EventAddPlane?.Invoke(_plane);
Close();
} }
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
} }
} }

View File

@ -0,0 +1,5 @@
namespace Airbus
{
//делегат для передачи объекта-самолёта
public delegate void PlaneDelegate(DrawningAirbus plane);
}