From 3e6dcd8f818a095fc2fd2e04bf09393b6abbb187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Mon, 10 Oct 2022 19:53:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D1=80=D0=B5=D1=82=D1=8C=D1=8F=20=D0=BB?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=B0?= =?UTF-8?q?=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormMapWithSetHoistingCrane.cs | 52 +++++-------------- .../MapWithSetHoistingCraneGeneric.cs | 1 - 2 files changed, 12 insertions(+), 41 deletions(-) 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;