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(); - } - } -} -