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;