Eliseev E.E. LabWork05 #6

Merged
eegov merged 11 commits from LabWork05 into LabWork04 2022-11-07 10:02:56 +04:00
4 changed files with 53 additions and 8 deletions
Showing only changes of commit 18aa8f88dc - Show all commits

View File

@ -103,18 +103,27 @@ namespace Airbus
//добавление объекта
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;
}
Form1 form = new();
}*/
//////////////
/*Form1 form = new();
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("Объект добавлен");
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty].ShowSet();
@ -122,8 +131,9 @@ namespace Airbus
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
}*/
//////////////////
//}
}
//удаление объекта

View File

@ -305,6 +305,7 @@
this.buttonAddObject.TabIndex = 3;
this.buttonAddObject.Text = "Добавить";
this.buttonAddObject.UseVisualStyleBackColor = true;
this.buttonAddObject.Click += new System.EventHandler(this.ButtonAddObject_Click);
//
// buttonCancel
//
@ -314,6 +315,7 @@
this.buttonCancel.TabIndex = 4;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// FormPlaneConfig
//

View File

@ -15,6 +15,9 @@ namespace Airbus
//переменная-выбранная машина
DrawningAirbus _plane = null;
//событие
private event PlaneDelegate EventAddPlane;
//конструктор
public FormPlaneConfig()
{
@ -29,6 +32,7 @@ namespace Airbus
panelBlue.MouseDown += PanelColor_MouseDown;
}
//отрисовка самолёт
private void DrawPlane()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
@ -38,6 +42,19 @@ namespace Airbus
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)
{
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
@ -104,5 +121,16 @@ namespace Airbus
//TODO Call method from object _plane is DrawningSuperAirbus and set add color
}
//добавление машины
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);
}