Merge pull request 'устранение замечаний преподавателя' (#6) from Lab04 into Lab05

Reviewed-on: http://student.git.athene.tech/Igor-Melnikov/ISEbd-21_Melnikov_I.O._Locomotives._Advanced/pulls/6
This commit is contained in:
Igor-Melnikov 2022-12-08 19:02:44 +04:00
commit 12aff45c51
2 changed files with 11 additions and 4 deletions

View File

@ -149,11 +149,11 @@
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
DrawningObjectLocomotive removableObject = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos;
if (removableObject != null)
var removableObject = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty, pos];
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
{
MessageBox.Show("Объект удален");
_mapsCollection.RemovedObject = removableObject;
_mapsCollection.RemovedObject = (DrawningObjectLocomotive)removableObject;
pictureBoxLocomotives.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
@ -227,11 +227,13 @@
{
if (_mapsCollection.RemovedObject == null)
{
MessageBox.Show("Коллекция удалённых элементов пуста");
return;
}
FormLocomotive formWithLastRemovedObject = new(_mapsCollection.RemovedObject._locomotive);
formWithLastRemovedObject.Show();
formWithLastRemovedObject.Draw();
_mapsCollection.RemoveLastObject();
}
}
}

View File

@ -107,9 +107,14 @@
{
return null;
}
return _removedObjects.Last.Value;
var removedObject = _removedObjects.Last();
return removedObject;
}
}
public void RemoveLastObject()
{
_removedObjects.RemoveLast();
}
}
}