From 37c182fa78e53c987bb0af55180e48bc37a99642 Mon Sep 17 00:00:00 2001 From: Arklightning Date: Sat, 26 Nov 2022 11:03:31 +0400 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B2=D0=B5=D1=80=D1=88=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B5=D0=BF=D0=BE=D0=B4=D0=B0=D0=B2=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Trolleybus/FormMapWithSetTrolleybus.cs | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) 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); } } }