добавлены проверки в AirplanesGenericStorage.cs
This commit is contained in:
parent
fc9c663a4e
commit
4f80893e3e
@ -18,11 +18,13 @@ namespace AirplaneWithRadar.Generics
|
|||||||
|
|
||||||
public void AddSet(string name)
|
public void AddSet(string name)
|
||||||
{
|
{
|
||||||
|
if (airplaneStorages.ContainsKey(name)) { return; }
|
||||||
airplaneStorages.Add(name, new AirplanesGenericCollection<PaintAirplane, PaintObjectAirplane>(pictWidth, pictHeight));
|
airplaneStorages.Add(name, new AirplanesGenericCollection<PaintAirplane, PaintObjectAirplane>(pictWidth, pictHeight));
|
||||||
}
|
}
|
||||||
public void DelSet(string name)
|
public void DelSet(string name)
|
||||||
{
|
{
|
||||||
airplaneStorages.Remove(name);
|
if (airplaneStorages.ContainsKey(name))
|
||||||
|
airplaneStorages.Remove(name);
|
||||||
}
|
}
|
||||||
public AirplanesGenericCollection<PaintAirplane, PaintObjectAirplane>? this[string ind]
|
public AirplanesGenericCollection<PaintAirplane, PaintObjectAirplane>? this[string ind]
|
||||||
{
|
{
|
||||||
|
@ -50,12 +50,11 @@ namespace AirplaneWithRadar
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MessageBox.Show($"Удалить объект { listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
storage.DelSet(listBoxStorages.SelectedItem.ToString() ?? string.Empty);
|
storage.DelSet(listBoxStorages.SelectedItem.ToString() ?? string.Empty);
|
||||||
ReloadObjects();
|
ReloadObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void ButtonAddAirplane_Click(object sender, EventArgs e)
|
private void ButtonAddAirplane_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user