Tsukanova I.V. LabWork5 #7
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
/// Удаление объекта
|
||||
|
8
AircraftCarrier/AircraftCarrier/WarshipDelegate.cs
Normal file
8
AircraftCarrier/AircraftCarrier/WarshipDelegate.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace AircraftCarrier
|
||||
{
|
||||
/// <summary>
|
||||
/// Делегат для передачи объекта-корабля
|
||||
/// </summary>
|
||||
/// <param name="warship"></param>
|
||||
public delegate void WarshipDelegate(DrawingWarship warship);
|
||||
}
|
Loading…
Reference in New Issue
Block a user