diff --git a/HoistingCrane/HoistingCrane/AdditionEntityCrane.cs b/HoistingCrane/HoistingCrane/AdditionEntityCrane.cs
index 286d24d..4c319ed 100644
--- a/HoistingCrane/HoistingCrane/AdditionEntityCrane.cs
+++ b/HoistingCrane/HoistingCrane/AdditionEntityCrane.cs
@@ -3,7 +3,7 @@
public class AdditionEntityCrane : EntityCrane
{
//дополнительный
- public Color AdditionalColor { get; private set; }
+ public Color AdditionalColor { get; set; }
//противовес
public bool CounterWeight { get; private set; }
//кран
diff --git a/HoistingCrane/HoistingCrane/EntityCrane.cs b/HoistingCrane/HoistingCrane/EntityCrane.cs
index e3a4ee9..ea9e482 100644
--- a/HoistingCrane/HoistingCrane/EntityCrane.cs
+++ b/HoistingCrane/HoistingCrane/EntityCrane.cs
@@ -7,7 +7,7 @@
//вес
public double Weight { get; private set; }
//основной цввет
- public Color BodyColor { get; private set; }
+ public Color BodyColor { get; set; }
//шаг перемещения
public double Step => (double)Speed * 100 / Weight;
public EntityCrane(int speed, double weight, Color bodyColor)
diff --git a/HoistingCrane/HoistingCrane/FormCraneCollection.cs b/HoistingCrane/HoistingCrane/FormCraneCollection.cs
index d5e5a98..3770d11 100644
--- a/HoistingCrane/HoistingCrane/FormCraneCollection.cs
+++ b/HoistingCrane/HoistingCrane/FormCraneCollection.cs
@@ -64,24 +64,27 @@ namespace HoistingCrane
{
return;
}
- var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
- if (obj == null)
+ var formCraneConfig = new FormCraneConfig();
+ formCraneConfig.AddEvent(crane =>
{
- return;
- }
- CraneVisual form = new();
- if (form.ShowDialog() == DialogResult.OK)
- {
- if (obj + form.SelectedCrane != -1)
+ if (listBoxStorages.SelectedIndex != -1)
{
- MessageBox.Show("Объект добавлен");
- pictureBoxCollection.Image = obj.ShowCars();
+ var obj = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty];
+ if (obj != null)
+ {
+ if (obj + crane != 1)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBoxCollection.Image = obj.ShowCars();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
}
- else
- {
- MessageBox.Show("Не удалось добавить объект");
- }
- }
+ });
+ formCraneConfig.Show();
}
diff --git a/HoistingCrane/HoistingCrane/FormCraneConfig.Designer.cs b/HoistingCrane/HoistingCrane/FormCraneConfig.Designer.cs
new file mode 100644
index 0000000..a2137ec
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/FormCraneConfig.Designer.cs
@@ -0,0 +1,394 @@
+namespace HoistingCrane
+{
+ partial class FormCraneConfig
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.labelSpeed = new System.Windows.Forms.Label();
+ this.labelWeight = new System.Windows.Forms.Label();
+ this.groupBoxParametres = new System.Windows.Forms.GroupBox();
+ this.labelModifiedObject = new System.Windows.Forms.Label();
+ this.labelSimpleObject = new System.Windows.Forms.Label();
+ this.groupBoxColors = new System.Windows.Forms.GroupBox();
+ this.panelWhite = new System.Windows.Forms.Panel();
+ this.panelYellow = new System.Windows.Forms.Panel();
+ this.panelGreen = new System.Windows.Forms.Panel();
+ this.panelBlack = new System.Windows.Forms.Panel();
+ this.panelGray = new System.Windows.Forms.Panel();
+ this.panelPurple = new System.Windows.Forms.Panel();
+ this.panelBlue = new System.Windows.Forms.Panel();
+ this.panelRed = new System.Windows.Forms.Panel();
+ this.checkBoxCounterweight = new System.Windows.Forms.CheckBox();
+ this.checkBoxCrane = new System.Windows.Forms.CheckBox();
+ this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
+ this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.pictureBoxCrane = new System.Windows.Forms.PictureBox();
+ this.labelAdditionalColor = new System.Windows.Forms.Label();
+ this.labelBodyColor = new System.Windows.Forms.Label();
+ this.panelColor = new System.Windows.Forms.Panel();
+ this.groupBoxParametres.SuspendLayout();
+ this.groupBoxColors.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCrane)).BeginInit();
+ this.panelColor.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // labelSpeed
+ //
+ this.labelSpeed.AutoSize = true;
+ this.labelSpeed.Location = new System.Drawing.Point(6, 27);
+ this.labelSpeed.Name = "labelSpeed";
+ this.labelSpeed.Size = new System.Drawing.Size(89, 25);
+ this.labelSpeed.TabIndex = 0;
+ this.labelSpeed.Text = "Скорость";
+ //
+ // labelWeight
+ //
+ this.labelWeight.AutoSize = true;
+ this.labelWeight.Location = new System.Drawing.Point(12, 70);
+ this.labelWeight.Name = "labelWeight";
+ this.labelWeight.Size = new System.Drawing.Size(39, 25);
+ this.labelWeight.TabIndex = 1;
+ this.labelWeight.Text = "Вес";
+ //
+ // groupBoxParametres
+ //
+ this.groupBoxParametres.Controls.Add(this.labelModifiedObject);
+ this.groupBoxParametres.Controls.Add(this.labelSimpleObject);
+ this.groupBoxParametres.Controls.Add(this.groupBoxColors);
+ this.groupBoxParametres.Controls.Add(this.checkBoxCounterweight);
+ this.groupBoxParametres.Controls.Add(this.checkBoxCrane);
+ this.groupBoxParametres.Controls.Add(this.numericUpDownWeight);
+ this.groupBoxParametres.Controls.Add(this.numericUpDownSpeed);
+ this.groupBoxParametres.Controls.Add(this.labelSpeed);
+ this.groupBoxParametres.Controls.Add(this.labelWeight);
+ this.groupBoxParametres.Location = new System.Drawing.Point(0, 0);
+ this.groupBoxParametres.Name = "groupBoxParametres";
+ this.groupBoxParametres.Size = new System.Drawing.Size(540, 304);
+ this.groupBoxParametres.TabIndex = 2;
+ this.groupBoxParametres.TabStop = false;
+ this.groupBoxParametres.Text = "Параметры";
+ //
+ // labelModifiedObject
+ //
+ this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelModifiedObject.Font = new System.Drawing.Font("Segoe UI", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ this.labelModifiedObject.Location = new System.Drawing.Point(394, 210);
+ this.labelModifiedObject.Name = "labelModifiedObject";
+ this.labelModifiedObject.Size = new System.Drawing.Size(115, 56);
+ this.labelModifiedObject.TabIndex = 7;
+ this.labelModifiedObject.Text = "Продвинутый";
+ this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
+ //
+ // labelSimpleObject
+ //
+ this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelSimpleObject.Font = new System.Drawing.Font("Segoe UI", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
+ this.labelSimpleObject.Location = new System.Drawing.Point(247, 210);
+ this.labelSimpleObject.Name = "labelSimpleObject";
+ this.labelSimpleObject.Size = new System.Drawing.Size(115, 56);
+ this.labelSimpleObject.TabIndex = 3;
+ this.labelSimpleObject.Text = "Простой";
+ this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
+ //
+ // groupBoxColors
+ //
+ this.groupBoxColors.Controls.Add(this.panelWhite);
+ this.groupBoxColors.Controls.Add(this.panelYellow);
+ this.groupBoxColors.Controls.Add(this.panelGreen);
+ this.groupBoxColors.Controls.Add(this.panelBlack);
+ this.groupBoxColors.Controls.Add(this.panelGray);
+ this.groupBoxColors.Controls.Add(this.panelPurple);
+ this.groupBoxColors.Controls.Add(this.panelBlue);
+ this.groupBoxColors.Controls.Add(this.panelRed);
+ this.groupBoxColors.Location = new System.Drawing.Point(247, 25);
+ this.groupBoxColors.Name = "groupBoxColors";
+ this.groupBoxColors.Size = new System.Drawing.Size(271, 159);
+ this.groupBoxColors.TabIndex = 6;
+ this.groupBoxColors.TabStop = false;
+ this.groupBoxColors.Text = "Цвета";
+ //
+ // panelWhite
+ //
+ this.panelWhite.BackColor = System.Drawing.Color.White;
+ this.panelWhite.Location = new System.Drawing.Point(214, 96);
+ this.panelWhite.Name = "panelWhite";
+ this.panelWhite.Size = new System.Drawing.Size(40, 40);
+ this.panelWhite.TabIndex = 21;
+ this.panelWhite.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
+ //
+ // panelYellow
+ //
+ this.panelYellow.BackColor = System.Drawing.Color.Yellow;
+ this.panelYellow.Location = new System.Drawing.Point(214, 34);
+ this.panelYellow.Name = "panelYellow";
+ this.panelYellow.Size = new System.Drawing.Size(40, 40);
+ this.panelYellow.TabIndex = 17;
+ this.panelYellow.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
+ //
+ // panelGreen
+ //
+ this.panelGreen.BackColor = System.Drawing.Color.Green;
+ this.panelGreen.Location = new System.Drawing.Point(147, 96);
+ this.panelGreen.Name = "panelGreen";
+ this.panelGreen.Size = new System.Drawing.Size(40, 40);
+ this.panelGreen.TabIndex = 20;
+ this.panelGreen.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
+ //
+ // panelBlack
+ //
+ this.panelBlack.BackColor = System.Drawing.Color.Black;
+ this.panelBlack.Location = new System.Drawing.Point(147, 34);
+ this.panelBlack.Name = "panelBlack";
+ this.panelBlack.Size = new System.Drawing.Size(40, 40);
+ this.panelBlack.TabIndex = 16;
+ this.panelBlack.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
+ //
+ // panelGray
+ //
+ this.panelGray.BackColor = System.Drawing.Color.Gray;
+ this.panelGray.Location = new System.Drawing.Point(75, 96);
+ this.panelGray.Name = "panelGray";
+ this.panelGray.Size = new System.Drawing.Size(40, 40);
+ this.panelGray.TabIndex = 19;
+ this.panelGray.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
+ //
+ // panelPurple
+ //
+ this.panelPurple.BackColor = System.Drawing.Color.Purple;
+ this.panelPurple.Location = new System.Drawing.Point(6, 96);
+ this.panelPurple.Name = "panelPurple";
+ this.panelPurple.Size = new System.Drawing.Size(40, 40);
+ this.panelPurple.TabIndex = 18;
+ this.panelPurple.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
+ //
+ // panelBlue
+ //
+ this.panelBlue.BackColor = System.Drawing.Color.Blue;
+ this.panelBlue.Location = new System.Drawing.Point(75, 34);
+ this.panelBlue.Name = "panelBlue";
+ this.panelBlue.Size = new System.Drawing.Size(40, 40);
+ this.panelBlue.TabIndex = 15;
+ this.panelBlue.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
+ //
+ // panelRed
+ //
+ this.panelRed.BackColor = System.Drawing.Color.Red;
+ this.panelRed.Location = new System.Drawing.Point(6, 34);
+ this.panelRed.Name = "panelRed";
+ this.panelRed.Size = new System.Drawing.Size(40, 40);
+ this.panelRed.TabIndex = 14;
+ this.panelRed.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
+ //
+ // checkBoxCounterweight
+ //
+ this.checkBoxCounterweight.AutoSize = true;
+ this.checkBoxCounterweight.Location = new System.Drawing.Point(12, 155);
+ this.checkBoxCounterweight.Name = "checkBoxCounterweight";
+ this.checkBoxCounterweight.Size = new System.Drawing.Size(138, 29);
+ this.checkBoxCounterweight.TabIndex = 5;
+ this.checkBoxCounterweight.Text = "Противовес";
+ this.checkBoxCounterweight.UseVisualStyleBackColor = true;
+ //
+ // checkBoxCrane
+ //
+ this.checkBoxCrane.AutoSize = true;
+ this.checkBoxCrane.Location = new System.Drawing.Point(12, 118);
+ this.checkBoxCrane.Name = "checkBoxCrane";
+ this.checkBoxCrane.Size = new System.Drawing.Size(78, 29);
+ this.checkBoxCrane.TabIndex = 4;
+ this.checkBoxCrane.Text = "Кран";
+ this.checkBoxCrane.UseVisualStyleBackColor = true;
+ //
+ // numericUpDownWeight
+ //
+ this.numericUpDownWeight.Location = new System.Drawing.Point(138, 68);
+ this.numericUpDownWeight.Maximum = new decimal(new int[] {
+ 1000,
+ 0,
+ 0,
+ 0});
+ this.numericUpDownWeight.Minimum = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
+ this.numericUpDownWeight.Name = "numericUpDownWeight";
+ this.numericUpDownWeight.Size = new System.Drawing.Size(85, 31);
+ this.numericUpDownWeight.TabIndex = 3;
+ this.numericUpDownWeight.Value = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
+ //
+ // numericUpDownSpeed
+ //
+ this.numericUpDownSpeed.Location = new System.Drawing.Point(138, 25);
+ this.numericUpDownSpeed.Maximum = new decimal(new int[] {
+ 1000,
+ 0,
+ 0,
+ 0});
+ this.numericUpDownSpeed.Minimum = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
+ this.numericUpDownSpeed.Name = "numericUpDownSpeed";
+ this.numericUpDownSpeed.Size = new System.Drawing.Size(85, 31);
+ this.numericUpDownSpeed.TabIndex = 2;
+ this.numericUpDownSpeed.Value = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(147, 241);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(112, 34);
+ this.buttonCancel.TabIndex = 4;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(3, 241);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(112, 34);
+ this.buttonAdd.TabIndex = 3;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonOK_Click);
+ //
+ // pictureBoxCrane
+ //
+ this.pictureBoxCrane.Location = new System.Drawing.Point(3, 72);
+ this.pictureBoxCrane.Name = "pictureBoxCrane";
+ this.pictureBoxCrane.Size = new System.Drawing.Size(256, 163);
+ this.pictureBoxCrane.TabIndex = 2;
+ this.pictureBoxCrane.TabStop = false;
+ //
+ // labelAdditionalColor
+ //
+ this.labelAdditionalColor.AllowDrop = true;
+ this.labelAdditionalColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelAdditionalColor.Location = new System.Drawing.Point(134, 13);
+ this.labelAdditionalColor.Name = "labelAdditionalColor";
+ this.labelAdditionalColor.Size = new System.Drawing.Size(125, 56);
+ this.labelAdditionalColor.TabIndex = 0;
+ this.labelAdditionalColor.Text = "Доп. цвет";
+ this.labelAdditionalColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelAdditionalColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelAddBoxColor_DragDrop);
+ this.labelAdditionalColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
+ this.labelAdditionalColor.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
+ //
+ // labelBodyColor
+ //
+ this.labelBodyColor.AllowDrop = true;
+ this.labelBodyColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelBodyColor.Location = new System.Drawing.Point(3, 13);
+ this.labelBodyColor.Name = "labelBodyColor";
+ this.labelBodyColor.Size = new System.Drawing.Size(125, 56);
+ this.labelBodyColor.TabIndex = 0;
+ this.labelBodyColor.Text = "Цвет";
+ this.labelBodyColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelBodyColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop);
+ this.labelBodyColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
+ this.labelBodyColor.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
+ //
+ // panelColor
+ //
+ this.panelColor.AllowDrop = true;
+ this.panelColor.Controls.Add(this.pictureBoxCrane);
+ this.panelColor.Controls.Add(this.buttonCancel);
+ this.panelColor.Controls.Add(this.labelBodyColor);
+ this.panelColor.Controls.Add(this.buttonAdd);
+ this.panelColor.Controls.Add(this.labelAdditionalColor);
+ this.panelColor.Location = new System.Drawing.Point(546, 12);
+ this.panelColor.Name = "panelColor";
+ this.panelColor.Size = new System.Drawing.Size(262, 278);
+ this.panelColor.TabIndex = 5;
+ this.panelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
+ this.panelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
+ this.panelColor.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
+ //
+ // FormCraneConfig
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(807, 302);
+ this.Controls.Add(this.panelColor);
+ this.Controls.Add(this.groupBoxParametres);
+ this.Name = "FormCraneConfig";
+ this.Text = "FormCraneConfig";
+ this.groupBoxParametres.ResumeLayout(false);
+ this.groupBoxParametres.PerformLayout();
+ this.groupBoxColors.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCrane)).EndInit();
+ this.panelColor.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Label labelSpeed;
+ private Label labelWeight;
+ private GroupBox groupBoxParametres;
+ private Label labelModifiedObject;
+ private Label labelSimpleObject;
+ private GroupBox groupBoxColors;
+ private CheckBox checkBoxCounterweight;
+ private CheckBox checkBoxCrane;
+ private NumericUpDown numericUpDownWeight;
+ private NumericUpDown numericUpDownSpeed;
+ private PictureBox pictureBoxCrane;
+ private Label labelAdditionalColor;
+ private Label labelBodyColor;
+ private Button buttonCancel;
+ private Button buttonAdd;
+ private Panel panelColor;
+ private Panel panelWhite;
+ private Panel panelYellow;
+ private Panel panelGreen;
+ private Panel panelBlack;
+ private Panel panelGray;
+ private Panel panelPurple;
+ private Panel panelBlue;
+ private Panel panelRed;
+ }
+}
\ No newline at end of file
diff --git a/HoistingCrane/HoistingCrane/FormCraneConfig.cs b/HoistingCrane/HoistingCrane/FormCraneConfig.cs
new file mode 100644
index 0000000..cbe77fe
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/FormCraneConfig.cs
@@ -0,0 +1,169 @@
+
+using HoistingCrane.DrawningObjects;
+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;
+using HoistingCrane.Entities;
+
+namespace HoistingCrane
+{
+ public partial class FormCraneConfig : Form
+ {
+ private event Action EventAddCar;
+ DrawingCrane? _crane = null;
+ ///
+ /// Событие
+ ///
+ ///
+ /// Конструктор
+ ///
+ public FormCraneConfig()
+ {
+ 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 += (sender, e) =>Close();
+ }
+ ///
+ /// Отрисовать машину
+ ///
+ private void DrawCar()
+ {
+ Bitmap bmp = new(pictureBoxCrane.Width, pictureBoxCrane.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _crane?.SetPosition(5, 5);
+ _crane?.DrawTransport(gr);
+ pictureBoxCrane.Image = bmp;
+ }
+
+ public void AddEvent(Action ev)
+ {
+ if (EventAddCar == null)
+ {
+ EventAddCar = new Action< DrawingCrane>(ev);
+ }
+ else
+ {
+ EventAddCar += ev;
+ }
+
+ }
+ ///
+ /// Передаем информацию при нажатии на Label
+ ///
+ ///
+ ///
+ 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) ?? false)
+ {
+ 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":
+ _crane = new DrawingCrane((int)numericUpDownSpeed.Value,
+ (int)numericUpDownWeight.Value, Color.White, 900, 500);
+ break;
+ case "labelModifiedObject":
+ _crane = new AdditionalDrawingCrane((int)numericUpDownSpeed.Value,
+ (int)numericUpDownWeight.Value, Color.White, Color.Black,
+ checkBoxCounterweight.Checked, checkBoxCrane.Checked, 900,
+ 500);
+ break;
+ }
+ DrawCar();
+ }
+ /// Добавление машины
+ ///
+ ///
+ ///
+ private void ButtonOK_Click(object sender, EventArgs e)
+ {
+ EventAddCar?.Invoke(_crane);
+ Close();
+ }
+
+
+ private void PanelColor_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ private void LabelColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (_crane != null && _crane.EntityCrane is AdditionEntityCrane entityCrane)
+ {
+ labelAdditionalColor.AllowDrop = true;
+ }
+ else
+ labelAdditionalColor.AllowDrop = false;
+
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
+ private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_crane != null)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ _crane.EntityCrane.BodyColor = (Color)e.Data.GetData(typeof(Color));
+ }
+ DrawCar();
+ }
+ }
+ private void labelAddBoxColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_crane != null && _crane.EntityCrane is AdditionEntityCrane entityCrane2)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ entityCrane2.AdditionalColor = (Color)e.Data.GetData(typeof(Color));
+ }
+ DrawCar();
+ }
+ }
+ }
+}
diff --git a/HoistingCrane/HoistingCrane/FormCraneConfig.resx b/HoistingCrane/HoistingCrane/FormCraneConfig.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/HoistingCrane/HoistingCrane/FormCraneConfig.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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