diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs index b88cb93..9276ad4 100644 --- a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs @@ -33,27 +33,16 @@ namespace HoistingCrane InitializeComponent(); } - listBoxMaps.Items.Clear(); - for (int i = 0; i < _mapsCollection.Keys.Count; i++) - { - listBoxMaps.Items.Add(_mapsCollection.Keys[i]); - } + private MapWithSetHoistingCraneGeneric _mapHoistingCraneCollectionGeneric; - if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count)) - { - listBoxMaps.SelectedIndex = 0; - } - else if (listBoxMaps.Items.Count > 0 && index > -1 && index < listBoxMaps.Items.Count) - { - listBoxMaps.SelectedIndex = index; - } + { } + private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) { AbstractMap map = null; switch (comboBoxSelectorMap.Text) { - case "Простая карта": map = new SimpleMap(); break; case "Вторая карта": @@ -64,7 +53,7 @@ namespace HoistingCrane if (map != null) { _mapHoistingCraneCollectionGeneric = new MapWithSetHoistingCraneGeneric( - pictureBox.Width, pictureBox.Height, map); + pictureBox.Width, pictureBox.Height, map); } else { @@ -107,37 +96,21 @@ namespace HoistingCrane if (listBoxMaps.SelectedIndex == -1) { return; - } - if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - _mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty); - ReloadMaps(); - _logger.LogInformation($"Удалена карта {listBoxMaps.SelectedItem?.ToString()}"); - } } private void ButtonAddHoistingCrane_Click(object sender, EventArgs e) { if (_mapHoistingCraneCollectionGeneric == null) { - var formHoistingCraneConfig = new FormHoistingCraneConfig(); - formHoistingCraneConfig.AddEvent(AddHoistingCrane); - formHoistingCraneConfig.Show(); - } - private void AddHoistingCrane(DrawingHoistingCrane drawingHoistingCrane) - { - DrawingObjectHoistingCrane hoistingCrane = new DrawingObjectHoistingCrane(drawingHoistingCrane); - if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + hoistingCrane != -1) + } { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + { + MessageBox.Show("Объект добавлен"); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } - } - } } private void ButtonRemoveHoistingCrane_Click(object sender, EventArgs e) { @@ -202,7 +175,6 @@ namespace HoistingCrane enums = Direction.Right; break; } - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(enums); } private void pictureBox_Click(object sender, EventArgs e) diff --git a/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs b/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs index efa7298..6704aac 100644 --- a/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs +++ b/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs @@ -107,7 +107,6 @@ namespace HoistingCrane } } - private void DrawHoistingCranes(Graphics gr) { int heightEl = _pictureHeight / _placeSizeHeight; int widthEl = _pictureWidth / _placeSizeWidth;