This commit is contained in:
Daniya_Youdakova 2022-12-24 21:57:58 +04:00
parent 9ae7b9a2eb
commit 262f64521c
2 changed files with 33 additions and 14 deletions

View File

@ -116,26 +116,27 @@ pictureBox.Height);
} }
} }
private void ButtonAddAircraftCarrier_Click(object sender, EventArgs e) private void ButtonAddAircraftCarrier_Click(object sender, EventArgs e)
{
var formAircraftCarrierConfig = new FormAircraftCarrierConfig();
// TODO Call method AddEvent from formCarConfig
formAircraftCarrierConfig.AddEvent(AddAircraftCarrier);
formAircraftCarrierConfig.Show();
}
private void AddAircraftCarrier(DrawningAircraftCarrier drawningAircraftCarrier)
{ {
if (listBoxMaps.SelectedIndex == -1) if (listBoxMaps.SelectedIndex == -1)
{ {
return; return;
} }
FormAircraftCarrier form = new(); DrawningObjectAircraftCarrier aircraftcarrier = new(drawningAircraftCarrier);
if (form.ShowDialog() == DialogResult.OK) if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + aircraftcarrier != -1)
{ {
DrawningObjectAircraftCarrier aircraftcarrier = new(form.SelectedAircraftCarrier); MessageBox.Show("Объект добавлен");
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
string.Empty] + aircraftcarrier != -1) }
{ else
MessageBox.Show("Объект добавлен"); {
pictureBox.Image = MessageBox.Show("Не удалось добавить объект");
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
} }
} }
private void buttonRemoveAircraftCarrier_Click(object sender, EventArgs e) private void buttonRemoveAircraftCarrier_Click(object sender, EventArgs e)
@ -164,6 +165,7 @@ string.Empty] - pos != null)
{ {
MessageBox.Show("Не удалось удалить объект"); MessageBox.Show("Не удалось удалить объект");
} }
} }
private void buttonShowStorage_Click(object sender, EventArgs e) private void buttonShowStorage_Click(object sender, EventArgs e)
{ {
@ -179,6 +181,7 @@ string.Empty] - pos != null)
{ {
return; return;
} }
pictureBox.Image = _mapAircraftCarriersCollectionGeneric.ShowOnMap(); pictureBox.Image = _mapAircraftCarriersCollectionGeneric.ShowOnMap();
} }
private void ButtonMove_Click(object sender, EventArgs e) private void ButtonMove_Click(object sender, EventArgs e)

View File

@ -72,5 +72,21 @@ namespace AircraftCarrier
return mapWithSetAircraftCarriersGeneric; return mapWithSetAircraftCarriersGeneric;
} }
} }
public MapWithSetAircraftCarriersGeneric<DrawningObjectAircraftCarrier, AbstractMap> this[int index]
{
get
{
if ((index < 0) || (index >= Keys.Count))
{
return null;
}
else
{
string StringKey = Keys[index];
return _mapStorages[StringKey];
}
}
}
} }
} }