From 72344e2aa50d975efb2789b3bf48ec8365d84caa 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 | 60 +++++++------------ .../MapWithSetHoistingCraneGeneric.cs | 3 +- 2 files changed, 22 insertions(+), 41 deletions(-) diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs index 124aab0..03df1c9 100644 --- a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs @@ -12,19 +12,9 @@ namespace HoistingCrane { public partial class FormMapWithSetHoistingCrane : Form { - /// Словарь для выпадающего списка - /// - private readonly Dictionary _mapsDict = new() - { - { "Простая карта", new SimpleMap() }, - { "Вторая карта", new SecondMap() }, - }; - /// - /// Объект от коллекции карт - /// - private readonly MapsCollection _mapsCollection; - /// + private MapWithSetHoistingCraneGeneric _mapHoistingCraneCollectionGeneric; + public FormMapWithSetHoistingCrane() { InitializeComponent(); @@ -46,7 +36,7 @@ namespace HoistingCrane for (int i = 0; i < _mapsCollection.Keys.Count; i++) { listBoxMaps.Items.Add(_mapsCollection.Keys[i]); - } + } if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count)) { @@ -62,17 +52,16 @@ namespace HoistingCrane AbstractMap map = null; switch (comboBoxSelectorMap.Text) { - case "Простая карта": map = new SimpleMap(); break; case "Вторая карта": map = new SecondMap(); - break; + break; } if (map != null) { _mapHoistingCraneCollectionGeneric = new MapWithSetHoistingCraneGeneric( - pictureBox.Width, pictureBox.Height, map); + pictureBox.Width, pictureBox.Height, map); } else { @@ -123,30 +112,22 @@ namespace HoistingCrane } private void ButtonAddHoistingCrane_Click(object sender, EventArgs e) { - if (listBoxMaps.SelectedIndex == -1) { return; } - 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(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); + { + MessageBox.Show("Объект добавлен"); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } } } + private void ButtonRemoveHoistingCrane_Click(object sender, EventArgs e) { - if (listBoxMaps.SelectedIndex == -1) { return; } @@ -155,35 +136,31 @@ namespace HoistingCrane return; } int pos = Convert.ToInt32(maskedTextBoxPosition.Text); - if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null) { MessageBox.Show("Объект удален"); - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } else { MessageBox.Show("Не удалось удалить объект"); } } + private void ButtonShowStorage_Click(object sender, EventArgs e) { - if (listBoxMaps.SelectedIndex == -1) { return; } - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } + private void ButtonShowOnMap_Click(object sender, EventArgs e) { - if (listBoxMaps.SelectedIndex == -1) { return; } - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap(); } + private void ButtonMove_Click(object sender, EventArgs e) { - if (listBoxMaps.SelectedIndex == -1) { return; } @@ -206,5 +183,10 @@ namespace HoistingCrane } pictureBox.Image = _mapHoistingCraneCollectionGeneric.MoveObject(enums); } + + private void pictureBox_Click(object sender, EventArgs e) + { + + } } } diff --git a/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs b/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs index efa7298..720e334 100644 --- a/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs +++ b/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs @@ -42,7 +42,7 @@ namespace HoistingCrane Bitmap bmp = new(_pictureWidth, _pictureWidth); Graphics gr = Graphics.FromImage(bmp); DrawBackground(gr); - DrawHoistingCranes(gr); + DrawBulldozers(gr); return bmp; } @@ -107,7 +107,6 @@ namespace HoistingCrane } } - private void DrawHoistingCranes(Graphics gr) { int heightEl = _pictureHeight / _placeSizeHeight; int widthEl = _pictureWidth / _placeSizeWidth;