Tsukanova I.V. LabWork5 #7

Closed
Inohara wants to merge 4 commits from LabWork05 into LabWork04
3 changed files with 40 additions and 18 deletions
Showing only changes of commit 9310d810a1 - Show all commits

View File

@ -17,6 +17,10 @@ namespace AircraftCarrier
/// </summary>
DrawingWarship _warship = null;
/// <summary>
/// Событие
/// </summary>
private event WarshipDelegate EventAddWarshp;
/// <summary>
/// Конструктор
/// </summary>
public FormCarConfig()
@ -43,6 +47,21 @@ namespace AircraftCarrier
pictureBoxObject.Image = bmp;
}
/// <summary>
/// Добавление события
/// </summary>
/// <param name="ev"></param>
public void AddEvent(WarshipDelegate ev)
{
if (EventAddWarshp == null)
{
EventAddWarshp = new WarshipDelegate(ev);
}
else
{
EventAddWarshp += ev;
}
}
/// <summary>
/// Передаем информацию при нажатии на Label
/// </summary>
/// <param name="sender"></param>
@ -129,5 +148,15 @@ namespace AircraftCarrier
{
// TODO Call method from object _car if _car is DrawningSportCar and set dop color
}
/// <summary>
/// Добавление корабля
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonOk_Click(object sender, EventArgs e)
{
EventAddWarshp?.Invoke(_warship);
Close();
}
}
}

View File

@ -114,24 +114,9 @@ namespace AircraftCarrier
/// <param name="e"></param>
private void ButtonAddWarship_Click(object sender, EventArgs e)
{
if (listBoxMaps.SelectedIndex == -1)
{
return;
}
FormWarship form = new();
if (form.ShowDialog() == DialogResult.OK)
{
DrawingObjectWarship warship = new(form.SelectedWarship);
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + warship >= 0)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
var formCarConfig = new FormCarConfig();
// TODO Call method AddEvent from formCarConfig
formCarConfig.Show();
}
/// <summary>
/// Удаление объекта

View File

@ -0,0 +1,8 @@
namespace AircraftCarrier
{
/// <summary>
/// Делегат для передачи объекта-корабля
/// </summary>
/// <param name="warship"></param>
public delegate void WarshipDelegate(DrawingWarship warship);
}