diff --git a/ProjectSeaplane/ProjectSeaplane/Entities/EntityBasicSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Entities/EntityBasicSeaplane.cs
index ac8659e..4ef27b8 100644
--- a/ProjectSeaplane/ProjectSeaplane/Entities/EntityBasicSeaplane.cs
+++ b/ProjectSeaplane/ProjectSeaplane/Entities/EntityBasicSeaplane.cs
@@ -7,26 +7,34 @@ public class EntityBasicSeaplane
///
/// Скорость
///
- public int Speed { get; private set; }
+ public int Speed { get;set; }
///
/// Вес
///
- public double Weight { get; private set; }
+ public double Weight { get; set; }
///
/// Основной цвет
///
- public Color BodyColor { get; private set; }
+ public Color BodyColor { get; set; }
///
/// Расстояние шага передвижения
///
public double Step => Speed * 100 / Weight;
///
+ /// Метод установки основного цвета
+ ///
+ ///
+ public void setBodyColor(Color color)
+ {
+ BodyColor = color;
+ }
+ ///
/// Конструктор сущности
///
/// Скорость
/// Вес
/// Основной цвет
-
+
public EntityBasicSeaplane(int speed, double weight, Color bodyColor)
{
Speed = speed;
diff --git a/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs
index 45d0ba0..1dc08f5 100644
--- a/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs
+++ b/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs
@@ -18,6 +18,14 @@ public class EntitySeaplane : EntityBasicSeaplane
/// Признак наличия радара
///
public bool Radar { get; private set; }
+ ///
+ /// Метод установки доп цвета
+ ///
+ ///
+ public void setAdditionalColor(Color color)
+ {
+ AdditionalColor = color;
+ }
///
/// Конструктор
@@ -25,7 +33,7 @@ public class EntitySeaplane : EntityBasicSeaplane
/// Дополнительный цвет
/// Тип "шасси"
/// При
-
+
public EntitySeaplane(int speed, double weight, Color bodyColor, Color additionalColor, bool landingGear, bool radar) : base(speed, weight, bodyColor)
{
diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs
index 0edd49a..873657a 100644
--- a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs
+++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs
@@ -31,7 +31,6 @@
groupBoxTools = new GroupBox();
panelCompanyTools = new Panel();
buttonAddBasicSeaplane = new Button();
- buttonAddSeaplane = new Button();
buttonRefresh = new Button();
maskedTextBox = new MaskedTextBox();
buttonGoToCheck = new Button();
@@ -70,7 +69,6 @@
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonAddBasicSeaplane);
- panelCompanyTools.Controls.Add(buttonAddSeaplane);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(maskedTextBox);
panelCompanyTools.Controls.Add(buttonGoToCheck);
@@ -93,18 +91,6 @@
buttonAddBasicSeaplane.UseVisualStyleBackColor = true;
buttonAddBasicSeaplane.Click += ButtonAddBasicSeaplane_Click;
//
- // buttonAddSeaplane
- //
- buttonAddSeaplane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonAddSeaplane.FlatStyle = FlatStyle.Flat;
- buttonAddSeaplane.Location = new Point(0, 48);
- buttonAddSeaplane.Name = "buttonAddSeaplane";
- buttonAddSeaplane.Size = new Size(174, 43);
- buttonAddSeaplane.TabIndex = 2;
- buttonAddSeaplane.Text = "Добавление гидросамолета";
- buttonAddSeaplane.UseVisualStyleBackColor = true;
- buttonAddSeaplane.Click += ButtonAddSeaplane_Click;
- //
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@@ -285,7 +271,6 @@
private GroupBox groupBoxTools;
private Button buttonAddBasicSeaplane;
private ComboBox СomboBoxSelectorCompany;
- private Button buttonAddSeaplane;
private Button buttonGoToCheck;
private Button buttonDelSeaplane;
private MaskedTextBox maskedTextBox;
diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs
index e32a9e9..b3500ec 100644
--- a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs
+++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs
@@ -38,48 +38,28 @@ public partial class FormPlaneCollection : Form
}
///
- /// Добавление обычного самолета
+ /// Добавление самолета
///
///
///
- private void ButtonAddBasicSeaplane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingBasicSeaplane));
-
- ///
- /// Добавление гидросамолета
- ///
- ///
- ///
- private void ButtonAddSeaplane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingSeaplane));
-
- ///
- /// Создание объекта класса-перемещения
- ///
- /// Тип создаваемого объекта
- private void CreateObject(string type)
+ private void ButtonAddBasicSeaplane_Click(object sender, EventArgs e)
{
- if (_company == null)
+ FormPlaneConfig form = new();
+ form.Show();
+ form.AddEvent(SetPlane);
+ }
+ ///
+ /// Добавление самолета в коллекцию
+ ///
+ ///
+ private void SetPlane(DrawingBasicSeaplane plane)
+ {
+ if (_company == null || plane == null)
{
return;
}
- Random random = new();
- DrawingBasicSeaplane drawingBasicSeaplane;
- switch (type)
- {
- case nameof(DrawingBasicSeaplane):
- drawingBasicSeaplane = new DrawingBasicSeaplane(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
- break;
- case nameof(DrawingSeaplane):
- // TODO вызов диалогового окна для выбора цвета
- drawingBasicSeaplane = new DrawingSeaplane(random.Next(100, 300), random.Next(1000, 3000),
- GetColor(random), GetColor(random),
- Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
- break;
- default:
- return;
- }
-
- if (_company + drawingBasicSeaplane != -1)
+ if (_company + plane != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@@ -90,22 +70,6 @@ public partial class FormPlaneCollection : Form
}
}
- ///
- /// Получение цвета
- ///
- /// Генератор случайных чисел
- ///
- 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;
- }
///
/// Удаление объекта
@@ -279,5 +243,5 @@ public partial class FormPlaneCollection : Form
}
-
+
}
diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.Designer.cs b/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.Designer.cs
new file mode 100644
index 0000000..909fa48
--- /dev/null
+++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.Designer.cs
@@ -0,0 +1,363 @@
+namespace ProjectSeaplane
+{
+ partial class FormPlaneConfig
+ {
+ ///
+ /// 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();
+ panelPurple = new Panel();
+ panelYellow = new Panel();
+ panelBlack = new Panel();
+ panelBlue = new Panel();
+ panelGray = new Panel();
+ panelGreen = new Panel();
+ panelWhite = new Panel();
+ panelRed = new Panel();
+ checkBoxRadar = new CheckBox();
+ checkBoxLandingGear = new CheckBox();
+ numericUpDownWeight = new NumericUpDown();
+ labelWeight = new Label();
+ numericUpDownSpeed = new NumericUpDown();
+ 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(checkBoxRadar);
+ groupBoxConfig.Controls.Add(checkBoxLandingGear);
+ groupBoxConfig.Controls.Add(numericUpDownWeight);
+ groupBoxConfig.Controls.Add(labelWeight);
+ groupBoxConfig.Controls.Add(numericUpDownSpeed);
+ 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(557, 217);
+ groupBoxConfig.TabIndex = 0;
+ groupBoxConfig.TabStop = false;
+ groupBoxConfig.Text = "Параметры";
+ //
+ // groupBoxColors
+ //
+ groupBoxColors.Controls.Add(panelPurple);
+ groupBoxColors.Controls.Add(panelYellow);
+ groupBoxColors.Controls.Add(panelBlack);
+ groupBoxColors.Controls.Add(panelBlue);
+ groupBoxColors.Controls.Add(panelGray);
+ groupBoxColors.Controls.Add(panelGreen);
+ groupBoxColors.Controls.Add(panelWhite);
+ groupBoxColors.Controls.Add(panelRed);
+ groupBoxColors.Location = new Point(225, 22);
+ groupBoxColors.Name = "groupBoxColors";
+ groupBoxColors.Size = new Size(268, 118);
+ groupBoxColors.TabIndex = 8;
+ groupBoxColors.TabStop = false;
+ groupBoxColors.Text = "Цвета";
+ //
+ // panelPurple
+ //
+ panelPurple.BackColor = Color.Purple;
+ panelPurple.Location = new Point(217, 70);
+ panelPurple.Name = "panelPurple";
+ panelPurple.Size = new Size(35, 31);
+ panelPurple.TabIndex = 5;
+ panelPurple.MouseDown += Panel_MouseDown;
+ //
+ // panelYellow
+ //
+ panelYellow.BackColor = Color.Yellow;
+ panelYellow.Location = new Point(217, 22);
+ panelYellow.Name = "panelYellow";
+ panelYellow.Size = new Size(35, 31);
+ panelYellow.TabIndex = 2;
+ panelYellow.MouseDown += Panel_MouseDown;
+ //
+ // panelBlack
+ //
+ panelBlack.BackColor = Color.Black;
+ panelBlack.Location = new Point(150, 70);
+ panelBlack.Name = "panelBlack";
+ panelBlack.Size = new Size(35, 31);
+ panelBlack.TabIndex = 6;
+ panelBlack.MouseDown += Panel_MouseDown;
+ //
+ // panelBlue
+ //
+ panelBlue.BackColor = Color.Blue;
+ panelBlue.Location = new Point(150, 22);
+ panelBlue.Name = "panelBlue";
+ panelBlue.Size = new Size(35, 31);
+ panelBlue.TabIndex = 2;
+ panelBlue.MouseDown += Panel_MouseDown;
+ //
+ // panelGray
+ //
+ panelGray.BackColor = Color.Gray;
+ panelGray.Location = new Point(81, 70);
+ panelGray.Name = "panelGray";
+ panelGray.Size = new Size(35, 31);
+ panelGray.TabIndex = 4;
+ panelGray.MouseDown += Panel_MouseDown;
+ //
+ // panelGreen
+ //
+ panelGreen.BackColor = Color.Green;
+ panelGreen.Location = new Point(81, 22);
+ panelGreen.Name = "panelGreen";
+ panelGreen.Size = new Size(35, 31);
+ panelGreen.TabIndex = 1;
+ panelGreen.MouseDown += Panel_MouseDown;
+ //
+ // panelWhite
+ //
+ panelWhite.BackColor = Color.White;
+ panelWhite.Location = new Point(15, 70);
+ panelWhite.Name = "panelWhite";
+ panelWhite.Size = new Size(35, 31);
+ panelWhite.TabIndex = 3;
+ panelWhite.MouseDown += Panel_MouseDown;
+ //
+ // panelRed
+ //
+ panelRed.BackColor = Color.Red;
+ panelRed.Location = new Point(15, 22);
+ panelRed.Name = "panelRed";
+ panelRed.Size = new Size(35, 31);
+ panelRed.TabIndex = 0;
+ panelRed.MouseDown += Panel_MouseDown;
+ //
+ // checkBoxRadar
+ //
+ checkBoxRadar.AutoSize = true;
+ checkBoxRadar.Location = new Point(12, 128);
+ checkBoxRadar.Name = "checkBoxRadar";
+ checkBoxRadar.Size = new Size(164, 19);
+ checkBoxRadar.TabIndex = 7;
+ checkBoxRadar.Text = "Признак наличия радара";
+ checkBoxRadar.UseVisualStyleBackColor = true;
+ //
+ // checkBoxLandingGear
+ //
+ checkBoxLandingGear.AutoSize = true;
+ checkBoxLandingGear.Location = new Point(12, 163);
+ checkBoxLandingGear.Name = "checkBoxLandingGear";
+ checkBoxLandingGear.Size = new Size(315, 19);
+ checkBoxLandingGear.TabIndex = 6;
+ checkBoxLandingGear.Text = "Тип \"шасси\" (Выкл - лодочный, Вкл - поплавковый)";
+ checkBoxLandingGear.UseVisualStyleBackColor = true;
+ //
+ // numericUpDownWeight
+ //
+ numericUpDownWeight.Location = new Point(77, 69);
+ 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, 23);
+ numericUpDownWeight.TabIndex = 5;
+ numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // labelWeight
+ //
+ labelWeight.AutoSize = true;
+ labelWeight.Location = new Point(12, 69);
+ labelWeight.Name = "labelWeight";
+ labelWeight.Size = new Size(26, 15);
+ labelWeight.TabIndex = 4;
+ labelWeight.Text = "Вес";
+ //
+ // numericUpDownSpeed
+ //
+ numericUpDownSpeed.Location = new Point(77, 40);
+ 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, 23);
+ numericUpDownSpeed.TabIndex = 3;
+ numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // labelSpeed
+ //
+ labelSpeed.AutoSize = true;
+ labelSpeed.Location = new Point(12, 40);
+ labelSpeed.Name = "labelSpeed";
+ labelSpeed.Size = new Size(59, 15);
+ labelSpeed.TabIndex = 2;
+ labelSpeed.Text = "Скорость";
+ //
+ // labelModifiedObject
+ //
+ labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
+ labelModifiedObject.Location = new Point(431, 150);
+ labelModifiedObject.Name = "labelModifiedObject";
+ labelModifiedObject.Size = new Size(92, 42);
+ labelModifiedObject.TabIndex = 1;
+ labelModifiedObject.Text = "Продвинутый";
+ labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelModifiedObject.MouseDown += LabelObject_MouseDown;
+ //
+ // labelSimpleObject
+ //
+ labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
+ labelSimpleObject.Location = new Point(333, 150);
+ labelSimpleObject.Name = "labelSimpleObject";
+ labelSimpleObject.Size = new Size(92, 42);
+ labelSimpleObject.TabIndex = 0;
+ labelSimpleObject.Text = "Простой ";
+ labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
+ labelSimpleObject.MouseDown += LabelObject_MouseDown;
+ //
+ // pictureBoxObject
+ //
+ pictureBoxObject.Location = new Point(12, 54);
+ pictureBoxObject.Name = "pictureBoxObject";
+ pictureBoxObject.Size = new Size(179, 93);
+ pictureBoxObject.TabIndex = 1;
+ pictureBoxObject.TabStop = false;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(589, 174);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(75, 23);
+ buttonAdd.TabIndex = 2;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(693, 174);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ 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(577, 0);
+ panelObject.Name = "panelObject";
+ panelObject.Size = new Size(200, 168);
+ panelObject.TabIndex = 4;
+ panelObject.DragDrop += PanelObject_DragDrop;
+ panelObject.DragEnter += PanelObject_DragEnter;
+ //
+ // labelAdditionalColor
+ //
+ labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
+ labelAdditionalColor.Location = new Point(105, 9);
+ labelAdditionalColor.Name = "labelAdditionalColor";
+ labelAdditionalColor.Size = new Size(92, 29);
+ labelAdditionalColor.TabIndex = 11;
+ labelAdditionalColor.Text = "Доп. цвет";
+ labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelAdditionalColor.DragDrop += LabelAdditionalColor_DragDrop;
+ labelAdditionalColor.DragEnter += LabelAdditionalColor_DragEnter;
+ //
+ // labelBodyColor
+ //
+ labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
+ labelBodyColor.Location = new Point(12, 9);
+ labelBodyColor.Name = "labelBodyColor";
+ labelBodyColor.Size = new Size(87, 29);
+ labelBodyColor.TabIndex = 10;
+ labelBodyColor.Text = "Цвет";
+ labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelBodyColor.DragDrop += LabelBodyColor_DragDrop;
+ labelBodyColor.DragEnter += LabelBodyColor_DragEnter;
+ //
+ // FormPlaneConfig
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(789, 217);
+ Controls.Add(panelObject);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonAdd);
+ Controls.Add(groupBoxConfig);
+ Name = "FormPlaneConfig";
+ Text = "FormPlaneConfig";
+ 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 CheckBox checkBoxLandingGear;
+ private NumericUpDown numericUpDownWeight;
+ private Label labelWeight;
+ private NumericUpDown numericUpDownSpeed;
+ private Label labelSpeed;
+ private CheckBox checkBoxRadar;
+ private GroupBox groupBoxColors;
+ private Panel panelRed;
+ private Panel panelPurple;
+ private Panel panelYellow;
+ private Panel panelBlack;
+ private Panel panelBlue;
+ private Panel panelGray;
+ private Panel panelGreen;
+ private Panel panelWhite;
+ 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/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.cs b/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.cs
new file mode 100644
index 0000000..4178a75
--- /dev/null
+++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.cs
@@ -0,0 +1,201 @@
+using ProjectSeaplane.Drawnings;
+using ProjectSeaplane.Entities;
+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 ProjectSeaplane;
+
+public partial class FormPlaneConfig : Form
+{
+ private DrawingBasicSeaplane _plane;
+
+ ///
+ /// Событие для передачи объекта
+ ///
+
+ private event Action? PlaneDelegate;
+
+ ///
+ /// Конструктор
+ ///
+ public FormPlaneConfig()
+ {
+ InitializeComponent();
+ panelRed.MouseDown += Panel_MouseDown;
+ panelGreen.MouseDown += Panel_MouseDown;
+ panelBlue.MouseDown += Panel_MouseDown;
+ panelYellow.MouseDown += Panel_MouseDown;
+ panelWhite.MouseDown += Panel_MouseDown;
+ panelGray.MouseDown += Panel_MouseDown;
+ panelBlack.MouseDown += Panel_MouseDown;
+ panelPurple.MouseDown += Panel_MouseDown;
+ // TODO buttonCancel.Click привязать анонимный метод через lambda закрытием формы
+ buttonCancel.Click += (sender, e) => Close();
+ }
+ ///
+ /// Передаем информацию при нажатии на Label
+ ///
+ ///
+ ///
+ private void LabelObject_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ ///
+ /// Привязка внешнего метода к событию
+ ///
+ ///
+ public void AddEvent(Action planeDelegate)
+ {
+ PlaneDelegate += planeDelegate;
+ }
+ ///
+ /// Отрисовка объекта
+ ///
+ private void DrawObject()
+ {
+ Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _plane?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
+ _plane?.SetPosition(15, 15);
+ _plane?.DrawTransport(gr);
+ pictureBoxObject.Image = bmp;
+ }
+ ///
+ /// Проверка получаемой информации (ее типа на соответствие требуемому)
+ ///
+ ///
+ ///
+ 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":
+ _plane = new DrawingBasicSeaplane((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
+ break;
+ case "labelModifiedObject":
+ _plane = new DrawingSeaplane((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value,
+ Color.White,
+ Color.Black, checkBoxLandingGear.Checked,
+ checkBoxRadar.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, 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 (_plane != null)
+ {
+ _plane.EntityBasicSeaplane.setBodyColor((Color)e.Data.GetData(typeof(Color)));
+ DrawObject();
+ }
+ }
+ ///
+ /// проверка получаемой информации по доп. цвету
+ ///
+ ///
+ ///
+ private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (_plane is DrawingSeaplane)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+ }
+
+ ///
+ /// Действия при приеме доп. цвета
+ ///
+ ///
+ ///
+ private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_plane.EntityBasicSeaplane is EntitySeaplane _seaplane)
+ {
+ _seaplane.setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
+ }
+ DrawObject();
+
+ }
+ ///
+ /// Передача объекта
+ ///
+ ///
+ ///
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ if (_plane != null)
+ {
+ PlaneDelegate?.Invoke(_plane);
+ Close();
+ }
+ }
+
+
+}
diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.resx b/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.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
diff --git a/ProjectSeaplane/ProjectSeaplane/PlaneDelegate.cs b/ProjectSeaplane/ProjectSeaplane/PlaneDelegate.cs
new file mode 100644
index 0000000..00c42c9
--- /dev/null
+++ b/ProjectSeaplane/ProjectSeaplane/PlaneDelegate.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ProjectSeaplane.Drawnings;
+
+namespace ProjectSeaplane;
+
+///
+/// Делегат для передачи объекта-самолета
+///
+///
+public delegate void PlaneDelegate(DrawingBasicSeaplane plane);