diff --git a/ProjectContainerShip/ProjectContainerShip/Entities/EntityContainerShip.cs b/ProjectContainerShip/ProjectContainerShip/Entities/EntityContainerShip.cs
index 53ab768..3fe15a1 100644
--- a/ProjectContainerShip/ProjectContainerShip/Entities/EntityContainerShip.cs
+++ b/ProjectContainerShip/ProjectContainerShip/Entities/EntityContainerShip.cs
@@ -10,6 +10,8 @@ public class EntityContainerShip : EntityShip
///
public Color AdditionalColor { get; private set; }
+ public void SetAdditionalColor(Color color) => AdditionalColor = color;
+
///
/// Признак (опция) наличия крана
///
diff --git a/ProjectContainerShip/ProjectContainerShip/Entities/EntityShip.cs b/ProjectContainerShip/ProjectContainerShip/Entities/EntityShip.cs
index d223d46..90a3fd0 100644
--- a/ProjectContainerShip/ProjectContainerShip/Entities/EntityShip.cs
+++ b/ProjectContainerShip/ProjectContainerShip/Entities/EntityShip.cs
@@ -22,6 +22,8 @@ public class EntityShip
///
public Color BodyColor { get; private set; }
+ public void SetBodyColor(Color color) => BodyColor = color;
+
///
/// Шаг перемещения корабля
///
diff --git a/ProjectContainerShip/ProjectContainerShip/FormShipCollection.Designer.cs b/ProjectContainerShip/ProjectContainerShip/FormShipCollection.Designer.cs
index babf245..fe7acee 100644
--- a/ProjectContainerShip/ProjectContainerShip/FormShipCollection.Designer.cs
+++ b/ProjectContainerShip/ProjectContainerShip/FormShipCollection.Designer.cs
@@ -31,7 +31,6 @@
groupBoxTools = new GroupBox();
panelCompanyTools = new Panel();
buttonAddShip = new Button();
- buttonAddContainerShip = new Button();
maskedTextBoxPosition = new MaskedTextBox();
buttonRefresh = new Button();
buttonDelShip = new Button();
@@ -70,7 +69,6 @@
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonAddShip);
- panelCompanyTools.Controls.Add(buttonAddContainerShip);
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(buttonDelShip);
@@ -92,17 +90,6 @@
buttonAddShip.UseVisualStyleBackColor = true;
buttonAddShip.Click += ButtonAddShip_Click;
//
- // buttonAddContainerShip
- //
- buttonAddContainerShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonAddContainerShip.Location = new Point(3, 52);
- buttonAddContainerShip.Name = "buttonAddContainerShip";
- buttonAddContainerShip.Size = new Size(191, 34);
- buttonAddContainerShip.TabIndex = 2;
- buttonAddContainerShip.Text = "Добавление контейнеровоза";
- buttonAddContainerShip.UseVisualStyleBackColor = true;
- buttonAddContainerShip.Click += ButtonAddContainerShip_Click;
- //
// maskedTextBoxPosition
//
maskedTextBoxPosition.Location = new Point(3, 92);
@@ -285,7 +272,6 @@
private Button buttonAddShip;
private ComboBox comboBoxSelectorCompany;
private MaskedTextBox maskedTextBoxPosition;
- private Button buttonAddContainerShip;
private PictureBox pictureBox;
private Button buttonDelShip;
private Button buttonRefresh;
diff --git a/ProjectContainerShip/ProjectContainerShip/FormShipCollection.cs b/ProjectContainerShip/ProjectContainerShip/FormShipCollection.cs
index ffc5ec9..e4dbdc4 100644
--- a/ProjectContainerShip/ProjectContainerShip/FormShipCollection.cs
+++ b/ProjectContainerShip/ProjectContainerShip/FormShipCollection.cs
@@ -38,35 +38,32 @@ namespace ProjectContainerShip
panelCompanyTools.Enabled = false;
}
+ ///
+ /// Добавление корабля
+ ///
+ ///
+ ///
+ private void ButtonAddShip_Click(object sender, EventArgs e)
+ {
+ FormShipConfig form = new();
+ // TODO передать метод
+ form.Show();
+ form.AddEvent(SetShip);
+ }
+
///
- /// Создание объекта класса-перемещения
+ /// Добавление лодки в коллекцию
///
- /// Тип создаваемого объекта
- private void CreateObject(string type)
+ ///
+ private void SetShip(DrawningShip? ship)
{
- if (_company == null)
+ if (_company == null || ship == null)
{
return;
}
- DrawningShip _drawningShip;
- Random random = new();
- switch (type)
- {
- case nameof(DrawningShip):
- _drawningShip = new DrawningShip(random.Next(30, 70), random.Next(100, 500),
- GetColor(random));
- break;
- case nameof(DrawningContainerShip):
- _drawningShip = new DrawningContainerShip(random.Next(30, 70), random.Next(100, 500),
- GetColor(random), GetColor(random),
- Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
- break;
- default:
- return;
- }
- if (_company + _drawningShip != -1)
+ if (_company + ship != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@@ -77,38 +74,6 @@ namespace ProjectContainerShip
}
}
-
- ///
- /// Добавление обычного корабля
- ///
- ///
- ///
- private void ButtonAddShip_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningShip));
-
- ///
- /// Добавление контейнеровоза
- ///
- ///
- ///
- private void ButtonAddContainerShip_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningContainerShip));
-
- ///
- /// Получение цвета
- ///
- /// Генератор случайных чисел
- ///
- private static Color GetColor(Random random)
- {
- Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
- ColorDialog dialog = new();
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- color = dialog.Color;
- }
-
- return color;
- }
-
///
/// Удаление объекта
///
diff --git a/ProjectContainerShip/ProjectContainerShip/FormShipConfig.Designer.cs b/ProjectContainerShip/ProjectContainerShip/FormShipConfig.Designer.cs
new file mode 100644
index 0000000..0237699
--- /dev/null
+++ b/ProjectContainerShip/ProjectContainerShip/FormShipConfig.Designer.cs
@@ -0,0 +1,357 @@
+namespace ProjectContainerShip
+{
+ partial class FormShipConfig
+ {
+ ///
+ /// 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()
+ {
+ groupBoxConfig = new GroupBox();
+ groupBoxColors = new GroupBox();
+ panelIndigo = new Panel();
+ panelViolet = new Panel();
+ panelGray = new Panel();
+ panelBlack = new Panel();
+ panelBlue = new Panel();
+ panelGreen = new Panel();
+ panelYellow = new Panel();
+ panelRed = new Panel();
+ checkBoxContainer = new CheckBox();
+ checkBoxCrane = new CheckBox();
+ numericUpDownWeight = new NumericUpDown();
+ numericUpDownSpeed = new NumericUpDown();
+ labelWeight = new Label();
+ labelSpeed = new Label();
+ labelModifiedObject = new Label();
+ labelSimpleObject = new Label();
+ pictureBoxObject = new PictureBox();
+ buttonAdd = new Button();
+ buttonCancel = new Button();
+ panelObject = new Panel();
+ labelAdditionalColor = new Label();
+ labelBodyColor = new Label();
+ groupBoxConfig.SuspendLayout();
+ groupBoxColors.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
+ panelObject.SuspendLayout();
+ SuspendLayout();
+ //
+ // groupBoxConfig
+ //
+ groupBoxConfig.Controls.Add(groupBoxColors);
+ groupBoxConfig.Controls.Add(checkBoxContainer);
+ groupBoxConfig.Controls.Add(checkBoxCrane);
+ groupBoxConfig.Controls.Add(numericUpDownWeight);
+ groupBoxConfig.Controls.Add(numericUpDownSpeed);
+ groupBoxConfig.Controls.Add(labelWeight);
+ groupBoxConfig.Controls.Add(labelSpeed);
+ groupBoxConfig.Controls.Add(labelModifiedObject);
+ groupBoxConfig.Controls.Add(labelSimpleObject);
+ groupBoxConfig.Dock = DockStyle.Left;
+ groupBoxConfig.Location = new Point(0, 0);
+ groupBoxConfig.Name = "groupBoxConfig";
+ groupBoxConfig.Size = new Size(522, 221);
+ groupBoxConfig.TabIndex = 0;
+ groupBoxConfig.TabStop = false;
+ groupBoxConfig.Text = "Параметры:";
+ //
+ // groupBoxColors
+ //
+ groupBoxColors.Controls.Add(panelIndigo);
+ groupBoxColors.Controls.Add(panelViolet);
+ groupBoxColors.Controls.Add(panelGray);
+ groupBoxColors.Controls.Add(panelBlack);
+ groupBoxColors.Controls.Add(panelBlue);
+ groupBoxColors.Controls.Add(panelGreen);
+ groupBoxColors.Controls.Add(panelYellow);
+ groupBoxColors.Controls.Add(panelRed);
+ groupBoxColors.Location = new Point(241, 19);
+ groupBoxColors.Name = "groupBoxColors";
+ groupBoxColors.Size = new Size(246, 109);
+ groupBoxColors.TabIndex = 8;
+ groupBoxColors.TabStop = false;
+ groupBoxColors.Text = "Цвета";
+ //
+ // panelIndigo
+ //
+ panelIndigo.BackColor = Color.Indigo;
+ panelIndigo.Location = new Point(192, 71);
+ panelIndigo.Name = "panelIndigo";
+ panelIndigo.Size = new Size(33, 32);
+ panelIndigo.TabIndex = 7;
+ //
+ // panelViolet
+ //
+ panelViolet.BackColor = Color.Violet;
+ panelViolet.Location = new Point(134, 71);
+ panelViolet.Name = "panelViolet";
+ panelViolet.Size = new Size(33, 32);
+ panelViolet.TabIndex = 6;
+ //
+ // panelGray
+ //
+ panelGray.BackColor = Color.Gray;
+ panelGray.Location = new Point(77, 71);
+ panelGray.Name = "panelGray";
+ panelGray.Size = new Size(33, 32);
+ panelGray.TabIndex = 5;
+ //
+ // panelBlack
+ //
+ panelBlack.BackColor = Color.Black;
+ panelBlack.Location = new Point(19, 71);
+ panelBlack.Name = "panelBlack";
+ panelBlack.Size = new Size(35, 32);
+ panelBlack.TabIndex = 4;
+ //
+ // panelBlue
+ //
+ panelBlue.BackColor = Color.Blue;
+ panelBlue.Location = new Point(192, 24);
+ panelBlue.Name = "panelBlue";
+ panelBlue.Size = new Size(33, 32);
+ panelBlue.TabIndex = 3;
+ //
+ // panelGreen
+ //
+ panelGreen.BackColor = Color.Green;
+ panelGreen.Location = new Point(134, 24);
+ panelGreen.Name = "panelGreen";
+ panelGreen.Size = new Size(33, 32);
+ panelGreen.TabIndex = 2;
+ //
+ // panelYellow
+ //
+ panelYellow.BackColor = Color.Yellow;
+ panelYellow.Location = new Point(77, 24);
+ panelYellow.Name = "panelYellow";
+ panelYellow.Size = new Size(33, 32);
+ panelYellow.TabIndex = 1;
+ //
+ // panelRed
+ //
+ panelRed.BackColor = Color.Red;
+ panelRed.Location = new Point(19, 24);
+ panelRed.Name = "panelRed";
+ panelRed.Size = new Size(35, 32);
+ panelRed.TabIndex = 0;
+ //
+ // checkBoxContainer
+ //
+ checkBoxContainer.AutoSize = true;
+ checkBoxContainer.Location = new Point(12, 138);
+ checkBoxContainer.Name = "checkBoxContainer";
+ checkBoxContainer.Size = new Size(211, 21);
+ checkBoxContainer.TabIndex = 7;
+ checkBoxContainer.Text = "Признак наличия контейнеров";
+ checkBoxContainer.UseVisualStyleBackColor = true;
+ //
+ // checkBoxCrane
+ //
+ checkBoxCrane.AutoSize = true;
+ checkBoxCrane.Location = new Point(12, 111);
+ checkBoxCrane.Name = "checkBoxCrane";
+ checkBoxCrane.Size = new Size(169, 21);
+ checkBoxCrane.TabIndex = 6;
+ checkBoxCrane.Text = "Признак наличия крана";
+ checkBoxCrane.UseVisualStyleBackColor = true;
+ //
+ // numericUpDownWeight
+ //
+ numericUpDownWeight.Location = new Point(79, 64);
+ numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
+ numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
+ numericUpDownWeight.Name = "numericUpDownWeight";
+ numericUpDownWeight.Size = new Size(120, 25);
+ numericUpDownWeight.TabIndex = 5;
+ numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // numericUpDownSpeed
+ //
+ numericUpDownSpeed.Location = new Point(79, 19);
+ numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
+ numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
+ numericUpDownSpeed.Name = "numericUpDownSpeed";
+ numericUpDownSpeed.Size = new Size(120, 25);
+ numericUpDownSpeed.TabIndex = 4;
+ numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // labelWeight
+ //
+ labelWeight.AutoSize = true;
+ labelWeight.Location = new Point(12, 66);
+ labelWeight.Name = "labelWeight";
+ labelWeight.Size = new Size(31, 17);
+ labelWeight.TabIndex = 3;
+ labelWeight.Text = "Вес:";
+ //
+ // labelSpeed
+ //
+ labelSpeed.AutoSize = true;
+ labelSpeed.Location = new Point(6, 27);
+ labelSpeed.Name = "labelSpeed";
+ labelSpeed.Size = new Size(67, 17);
+ labelSpeed.TabIndex = 2;
+ labelSpeed.Text = "Скорость:";
+ //
+ // labelModifiedObject
+ //
+ labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
+ labelModifiedObject.Location = new Point(366, 149);
+ labelModifiedObject.Name = "labelModifiedObject";
+ labelModifiedObject.Size = new Size(100, 32);
+ labelModifiedObject.TabIndex = 1;
+ labelModifiedObject.Text = "Продвинутый";
+ labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelModifiedObject.MouseDown += LabelObject_MouseDown;
+ //
+ // labelSimpleObject
+ //
+ labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
+ labelSimpleObject.Location = new Point(260, 149);
+ labelSimpleObject.Name = "labelSimpleObject";
+ labelSimpleObject.Size = new Size(100, 32);
+ labelSimpleObject.TabIndex = 0;
+ labelSimpleObject.Text = "Простой";
+ labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelSimpleObject.MouseDown += LabelObject_MouseDown;
+ //
+ // pictureBoxObject
+ //
+ pictureBoxObject.Location = new Point(13, 47);
+ pictureBoxObject.Name = "pictureBoxObject";
+ pictureBoxObject.Size = new Size(262, 128);
+ pictureBoxObject.TabIndex = 1;
+ pictureBoxObject.TabStop = false;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(828, 33);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(90, 50);
+ buttonAdd.TabIndex = 2;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(828, 131);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(90, 50);
+ buttonCancel.TabIndex = 3;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // panelObject
+ //
+ panelObject.AllowDrop = true;
+ panelObject.Controls.Add(labelAdditionalColor);
+ panelObject.Controls.Add(labelBodyColor);
+ panelObject.Controls.Add(pictureBoxObject);
+ panelObject.Location = new Point(534, 19);
+ panelObject.Name = "panelObject";
+ panelObject.Size = new Size(288, 190);
+ panelObject.TabIndex = 4;
+ panelObject.DragDrop += PanelObject_DragDrop;
+ panelObject.DragEnter += PanelObject_DragEnter;
+ //
+ // labelAdditionalColor
+ //
+ labelAdditionalColor.AllowDrop = true;
+ labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
+ labelAdditionalColor.Location = new Point(175, 8);
+ labelAdditionalColor.Name = "labelAdditionalColor";
+ labelAdditionalColor.Size = new Size(100, 32);
+ labelAdditionalColor.TabIndex = 3;
+ labelAdditionalColor.Text = "Доп. цвет";
+ labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
+ labelAdditionalColor.DragEnter += labelAdditionalColor_DragEnter;
+ //
+ // labelBodyColor
+ //
+ labelBodyColor.AllowDrop = true;
+ labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
+ labelBodyColor.Location = new Point(13, 8);
+ labelBodyColor.Name = "labelBodyColor";
+ labelBodyColor.Size = new Size(100, 32);
+ labelBodyColor.TabIndex = 2;
+ labelBodyColor.Text = "Цвет";
+ labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelBodyColor.DragDrop += labelBodyColor_DragDrop;
+ labelBodyColor.DragEnter += labelBodyColor_DragEnter;
+ //
+ // FormShipConfig
+ //
+ AutoScaleDimensions = new SizeF(7F, 17F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(964, 221);
+ Controls.Add(panelObject);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonAdd);
+ Controls.Add(groupBoxConfig);
+ Name = "FormShipConfig";
+ Text = "Создание объекта";
+ groupBoxConfig.ResumeLayout(false);
+ groupBoxConfig.PerformLayout();
+ groupBoxColors.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
+ panelObject.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private GroupBox groupBoxConfig;
+ private Label labelModifiedObject;
+ private Label labelSimpleObject;
+ private NumericUpDown numericUpDownWeight;
+ private NumericUpDown numericUpDownSpeed;
+ private Label labelWeight;
+ private Label labelSpeed;
+ private CheckBox checkBoxCrane;
+ private CheckBox checkBoxContainer;
+ private GroupBox groupBoxColors;
+ private Panel panelRed;
+ private Panel panelIndigo;
+ private Panel panelViolet;
+ private Panel panelGray;
+ private Panel panelBlack;
+ private Panel panelBlue;
+ private Panel panelGreen;
+ private Panel panelYellow;
+ private PictureBox pictureBoxObject;
+ private Button buttonAdd;
+ private Button buttonCancel;
+ private Panel panelObject;
+ private Label labelAdditionalColor;
+ private Label labelBodyColor;
+ }
+}
\ No newline at end of file
diff --git a/ProjectContainerShip/ProjectContainerShip/FormShipConfig.cs b/ProjectContainerShip/ProjectContainerShip/FormShipConfig.cs
new file mode 100644
index 0000000..5bd4f02
--- /dev/null
+++ b/ProjectContainerShip/ProjectContainerShip/FormShipConfig.cs
@@ -0,0 +1,168 @@
+using ProjectContainerShip.Drawnings;
+using ProjectContainerShip.Entities;
+
+namespace ProjectContainerShip;
+
+
+///
+/// Форма конфигурации объекта
+///
+public partial class FormShipConfig : Form
+{
+ ///
+ /// Объект - прорисовка корабля
+ ///
+ private DrawningShip? _ship = null;
+
+ private event Action? _shipDelegate;
+ public FormShipConfig()
+ {
+ InitializeComponent();
+
+ panelRed.MouseDown += Panel_MouseDown;
+ panelGreen.MouseDown += Panel_MouseDown;
+ panelBlue.MouseDown += Panel_MouseDown;
+ panelYellow.MouseDown += Panel_MouseDown;
+ panelViolet.MouseDown += Panel_MouseDown;
+ panelGray.MouseDown += Panel_MouseDown;
+ panelBlack.MouseDown += Panel_MouseDown;
+ panelIndigo.MouseDown += Panel_MouseDown;
+
+ buttonCancel.Click += (sender, e) => Close();
+ }
+
+ ///
+ /// Привязка внешнего метода к событию
+ ///
+ ///
+ public void AddEvent(Action shipDelegate)
+ {
+ _shipDelegate += shipDelegate;
+ }
+
+ ///
+ /// Прорисовка объекта
+ ///
+ private void DrawObject()
+ {
+ Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _ship?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
+ _ship?.SetPosition(15, 15);
+ _ship?.DrawTransport(gr);
+ pictureBoxObject.Image = bmp;
+ }
+
+ ///
+ /// Передаем информацию при нажатии на Label
+ ///
+ ///
+ ///
+ private void LabelObject_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ ///
+ /// Проверка получаемой информации (ее типа на соответствие требуемому)
+ ///
+ ///
+ ///
+ private void PanelObject_DragEnter(object sender, DragEventArgs e)
+ {
+ e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
+ }
+
+ ///
+ /// Действия при приеме перетаскиваемой информации
+ ///
+ ///
+ ///
+ private void PanelObject_DragDrop(object sender, DragEventArgs e)
+ {
+ switch (e.Data?.GetData(DataFormats.Text)?.ToString())
+ {
+ case "labelSimpleObject":
+ _ship = new DrawningShip((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
+ break;
+ case "labelModifiedObject":
+ _ship = new DrawningContainerShip((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White,
+ Color.Black, checkBoxCrane.Checked, checkBoxContainer.Checked);
+ break;
+ }
+ labelBodyColor.BackColor = Color.Empty;
+ labelAdditionalColor.BackColor = Color.Empty;
+ DrawObject();
+ }
+
+ ///
+ /// Передаем информацию при нажатии на Panel
+ ///
+ ///
+ ///
+ private void Panel_MouseDown(object? sender, MouseEventArgs e)
+ {
+ // TODO отправка цвета в Drag&Drop
+ (sender as Control)?.DoDragDrop((sender as Control)?.BackColor ?? Color.Black, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ // TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
+ private void labelBodyColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
+ private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_ship != null)
+ {
+ _ship.EntityShip.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
+ DrawObject();
+ }
+ }
+
+ private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (_ship is DrawningContainerShip)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+ }
+
+ private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_ship?.EntityShip is EntityContainerShip _catamaran)
+ {
+ _catamaran.SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
+ }
+ DrawObject();
+
+ }
+ ///
+ /// Передача объекта
+ ///
+ ///
+ ///
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ if (_ship != null)
+ {
+ _shipDelegate?.Invoke(_ship);
+ Close();
+ }
+ }
+}
diff --git a/ProjectContainerShip/ProjectContainerShip/FormShipConfig.resx b/ProjectContainerShip/ProjectContainerShip/FormShipConfig.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectContainerShip/ProjectContainerShip/FormShipConfig.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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