diff --git a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs deleted file mode 100644 index 6566f0e..0000000 --- a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs +++ /dev/null @@ -1,134 +0,0 @@ -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 FormHoistingCraneConfig : Form - { - //переменная-выбранный кран - DrawingHoistingCrane _hoistingCrane = null; - public DrawingHoistingCrane SelectedHoistingCrane { get; private set; } - //событие - private event Action EventAddHoistingCrane; - //конструктор - public FormHoistingCraneConfig() - { - InitializeComponent(); - panelBlack.MouseDown += PanelColor_MouseDown; - panelPurple.MouseDown += PanelColor_MouseDown; - panelGray.MouseDown += PanelColor_MouseDown; - panelGreen.MouseDown += PanelColor_MouseDown; - panelRed.MouseDown += PanelColor_MouseDown; - panelWhite.MouseDown += PanelColor_MouseDown; - panelYellow.MouseDown += PanelColor_MouseDown; - panelBlue.MouseDown += PanelColor_MouseDown; - buttonCancel.Click += (object sender, EventArgs e) => Close(); - } - //отрисовка кран - private void DrawHoistingCrane() - { - Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); - Graphics gr = Graphics.FromImage(bmp); - _hoistingCrane?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height); - _hoistingCrane?.DrawTransport(gr); - pictureBoxObject.Image = bmp; - } - //добавление события - public void AddEvent(Action ev) - { - if (EventAddHoistingCrane == null) - { - EventAddHoistingCrane = new Action(ev); - } - else - { - EventAddHoistingCrane += ev; - } - } - private void LabelObject_MouseDown(object sender, MouseEventArgs e) - { - (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy); - } - - //проверка получаемой информации (ее типа на соответствие требуемому) - private void PanelObject_DragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(DataFormats.Text)) - { - e.Effect = DragDropEffects.Copy; - } - else - { - e.Effect = DragDropEffects.None; - } - } - //действия при приеме перетаскиваемой информации - private void PanelObject_DragDrop(object sender, DragEventArgs e) - { - switch (e.Data.GetData(DataFormats.Text).ToString()) - { - case "labelSimpleObject": - _hoistingCrane = new DrawingHoistingCrane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor); - break; - case "labelModifiedObject": - _hoistingCrane = new DrawingAdvancedHoistingCrane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor, labelDopColor.BackColor, - checkBoxCounterweight.Checked, checkBoxCrane.Checked); - break; - } - - DrawHoistingCrane(); - } - //отправляем цвет с панели - private void PanelColor_MouseDown(object sender, MouseEventArgs e) - { - (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); - } - //проверка получаемой информации (её типа на соответсвие требуемому) - private void LabelColor_DragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(typeof(Color))) - { - e.Effect = DragDropEffects.Copy; - } - else - { - e.Effect = DragDropEffects.None; - } - } - //принимаем основной цвет - private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) - { - //проверка на пустоту объекта - if (_hoistingCrane != null) - { - _hoistingCrane.HoistingCrane.BodyColor = (Color)e.Data.GetData(typeof(Color)); - - DrawHoistingCrane(); - } - } - //принимаем дополнительный цвет - private void LabelDopColor_DragDrop(object sender, DragEventArgs e) - { - //проверка на пустоту объекта и правильную сущноть - if (_hoistingCrane != null && _hoistingCrane.HoistingCrane is EntityAdvancedHoistingCrane entityHoistingCrane) - { - entityHoistingCrane.DopColor = (Color)e.Data.GetData(typeof(Color)); - DrawHoistingCrane(); - } - } - //добавление крана - private void ButtonAddObject_Click(object sender, EventArgs e) - { - EventAddHoistingCrane?.Invoke(_hoistingCrane); - Close(); - } - } -} - diff --git a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx deleted file mode 100644 index 1af7de1..0000000 --- a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs deleted file mode 100644 index 725cc15..0000000 --- a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs +++ /dev/null @@ -1,155 +0,0 @@ -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) - { - - } - } -}