diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs new file mode 100644 index 0000000..725cc15 --- /dev/null +++ b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs @@ -0,0 +1,155 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace HoistingCrane +{ + public partial class FormMapWithSetHoistingCrane : Form + { + + private MapWithSetHoistingCraneGeneric _mapHoistingCraneCollectionGeneric; + + public FormMapWithSetHoistingCrane() + { + { "Простая карта", new SimpleMap() }, + { "Вторая карта", new SecondMap() }, + }; + /// + /// Объект от коллекции карт + /// Логер + /// + private readonly ILogger _logger; + /// + private readonly MapsCollection _mapsCollection; + /// + public FormMapWithSetHoistingCrane(ILogger logger) + { + { + InitializeComponent(); + } + + private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) + { + AbstractMap map = null; + switch (comboBoxSelectorMap.Text) + { + case "Первая карта": + map = new SimpleMap(); + break; + case "Вторая карта": + map = new SecondMap(); + break; + + + } + if (map != null) + { + _mapHoistingCraneCollectionGeneric = new MapWithSetHoistingCraneGeneric( + pictureBox.Width, pictureBox.Height, map); + } + else + { + _mapHoistingCraneCollectionGeneric = null; + } + } + + private void ButtonAddHoistingCrane_Click(object sender, EventArgs e) + { + if (_mapHoistingCraneCollectionGeneric == null) + { + return; + } + FormHoistingCrane form = new(); + if (form.ShowDialog() == DialogResult.OK) + { + DrawingObjectHoistingCrane hoistingCrane = new(form.SelectedHoistingCrane); + if (_mapHoistingCraneCollectionGeneric + hoistingCrane == 1) + { + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapHoistingCraneCollectionGeneric.ShowSet(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } + } + + private void ButtonRemoveHoistingCrane_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(maskedTextBoxPosition.Text)) + { + return; + } + if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + int pos = Convert.ToInt32(maskedTextBoxPosition.Text); + if (_mapHoistingCraneCollectionGeneric - pos == null) + { + MessageBox.Show("Объект удален"); + pictureBox.Image = _mapHoistingCraneCollectionGeneric.ShowSet(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + } + } + + private void ButtonShowStorage_Click(object sender, EventArgs e) + { + if (_mapHoistingCraneCollectionGeneric == null) + { + return; + } + pictureBox.Image = _mapHoistingCraneCollectionGeneric.ShowSet(); + } + + private void ButtonShowOnMap_Click(object sender, EventArgs e) + { + if (_mapHoistingCraneCollectionGeneric == null) + { + return; + } + pictureBox.Image = _mapHoistingCraneCollectionGeneric.ShowOnMap(); + } + + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_mapHoistingCraneCollectionGeneric == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + Direction enums = Direction.None; + switch (name) + { + case "buttonUp": + enums = Direction.Up; + break; + case "buttonDown": + enums = Direction.Down; + break; + case "buttonLeft": + enums = Direction.Left; + break; + case "buttonRight": + enums = Direction.Right; + break; + } + pictureBox.Image = _mapHoistingCraneCollectionGeneric.MoveObject(enums); + } + + private void pictureBox_Click(object sender, EventArgs e) + { + + } + } +}