diff --git a/Trolleybus/Trolleybus/FormMapWithSetTrolleybus.cs b/Trolleybus/Trolleybus/FormMapWithSetTrolleybus.cs index e176789..5680c38 100644 --- a/Trolleybus/Trolleybus/FormMapWithSetTrolleybus.cs +++ b/Trolleybus/Trolleybus/FormMapWithSetTrolleybus.cs @@ -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 /// 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); } } }