Завершено задание преподавателя

This commit is contained in:
Arklightning 2022-11-26 11:03:31 +04:00
parent 2d6108c489
commit 37c182fa78

View File

@ -38,6 +38,11 @@ namespace Trolleybus
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
}
foreach (string map in _mapsCollection.Keys)
{
listBoxMaps.Items.Add(map);
}
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
{
listBoxMaps.SelectedIndex = 0;
@ -153,7 +158,7 @@ namespace Trolleybus
/// <param name="e"></param>
private void ButtonShowStorage_Click(object sender, EventArgs e)
{
if (listBoxMaps.SelectedIndex == -1)
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] == null)
{
return;
}
@ -185,23 +190,23 @@ namespace Trolleybus
}
//получаем имя кнопки
string name = ((Button)sender)?.Name ?? string.Empty;
Direction enums = Direction.None;
Direction dir = Direction.None;
switch (name)
{
case "buttonsUp":
enums = Direction.Up;
case "buttonUp":
dir = Direction.Up;
break;
case "buttonsDown":
enums = Direction.Down;
case "buttonDown":
dir = Direction.Down;
break;
case "buttonsLeft":
enums = Direction.Left;
case "buttonLeft":
dir = Direction.Left;
break;
case "buttonsRight":
enums = Direction.Right;
case "buttonRight":
dir = Direction.Right;
break;
}
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(enums);
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
}
}
}