diff --git a/ProjectPlane/ProjectPlane/DrawingWarPlane.cs b/ProjectPlane/ProjectPlane/DrawingWarPlane.cs
index 7dfe2d2..fefa653 100644
--- a/ProjectPlane/ProjectPlane/DrawingWarPlane.cs
+++ b/ProjectPlane/ProjectPlane/DrawingWarPlane.cs
@@ -11,23 +11,23 @@ namespace ProjectPlane
///
/// Инициализация свойств
///
- /// Скорость
- /// Вес автомобиля
- /// Цвет кузова
+ /// Скорость
+ /// Вес самолета
+ /// Цвет корпуса
/// Дополнительный цвет
- /// Признак наличия обвеса
- /// Признак наличия антикрыла
- /// Признак наличия гоночной полосы
- public DrawingWarPlane(int speed, float weight, Color bodyColor, Color dopColor, bool isBomber, bool isFighter, bool superTurbine) :
+ /// Признак наличия доп отсека
+ /// Признак наличия супертурбины
+ public DrawingWarPlane(int speed, float weight, Color bodyColor, Color dopColor, bool extraCell, bool superTurbine) :
base(speed, weight, bodyColor, 110, 60)
{
- Plane = new EntityWarPlane(speed, weight, bodyColor, dopColor, isFighter, superTurbine);
+ Plane = new EntityWarPlane(speed, weight, bodyColor, dopColor, extraCell, superTurbine);
}
+
public override void DrawTransport(Graphics g)
{
- if (Plane is not EntityWarPlane warplane)
+ if (Plane is not EntityWarPlane warplane)
{
return;
}
@@ -69,5 +69,19 @@ namespace ProjectPlane
}
}
+ public void setDopColor(Color color)
+ {
+ if (Plane is EntityWarPlane)
+ {
+ var p = Plane as EntityWarPlane;
+ if (p is not null)
+ {
+ p = new EntityWarPlane(p.Speed, p.Weight, p.BodyColor, color, p.extraCell, p.SuperTurbine);
+ Plane = p;
+ }
+ else
+ Plane = new EntityPlane(Plane.Speed, Plane.Weight, color);
+ }
+ }
}
}
diff --git a/ProjectPlane/ProjectPlane/DrawningPlane.cs b/ProjectPlane/ProjectPlane/DrawningPlane.cs
index 28ee1ae..b70945f 100644
--- a/ProjectPlane/ProjectPlane/DrawningPlane.cs
+++ b/ProjectPlane/ProjectPlane/DrawningPlane.cs
@@ -239,5 +239,18 @@ namespace ProjectPlane
{
return (_startPosX, _startPosX + _planeWidth, _startPosY , _startPosY + _planeHeight);
}
+ public void setBaseColor(Color color)
+ {
+ if (Plane is EntityWarPlane)
+ {
+ var p = Plane as EntityWarPlane;
+ if (p is not null)
+ {
+ p = new EntityWarPlane(p.Speed, p.Weight, color, p.DopColor, p.extraCell, p.SuperTurbine);
+ Plane = p; return;
+ }
+ }
+ Plane = new EntityPlane(Plane.Speed, Plane.Weight, color);
+ }
}
}
\ No newline at end of file
diff --git a/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.cs b/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.cs
index 7bcd5fa..619fb67 100644
--- a/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.cs
+++ b/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.cs
@@ -76,25 +76,29 @@ namespace ProjectPlane
///
///
private void ButtonAddPlane_Click(object sender, EventArgs e)
+ {
+ var formPlaneConfig = new FormPlaneConfig();
+
+ formPlaneConfig.AddEvent(new (AddPlane));
+ formPlaneConfig.Show();
+ }
+ private void AddPlane(DrawingPlane plane)
{
if (listBoxMaps.SelectedIndex == -1)
{
return;
}
- FormPlane form = new();
- if (form.ShowDialog() == DialogResult.OK)
+
+ if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawingObject(plane) != -1)
{
- DrawingObject Plane = new(form.SelectedPlane);
- if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + Plane != -1)
- {
- MessageBox.Show("Object added");
- pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
- }
- else
- {
- MessageBox.Show("Error with object adding");
- }
+ MessageBox.Show("Object added");
+ pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
+ else
+ {
+ MessageBox.Show("Failed to add object");
+ }
+
}
///
/// Удаление объекта
diff --git a/ProjectPlane/ProjectPlane/FormPlane.cs b/ProjectPlane/ProjectPlane/FormPlane.cs
index bdb998f..a1bcbeb 100644
--- a/ProjectPlane/ProjectPlane/FormPlane.cs
+++ b/ProjectPlane/ProjectPlane/FormPlane.cs
@@ -94,7 +94,7 @@
dopColor = dialogDop.Color;
}
_plane = new DrawingWarPlane(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor,
- Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
+ Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
SetData();
Draw();
}
diff --git a/ProjectPlane/ProjectPlane/FormPlaneConfig.Designer.cs b/ProjectPlane/ProjectPlane/FormPlaneConfig.Designer.cs
new file mode 100644
index 0000000..a94f6ec
--- /dev/null
+++ b/ProjectPlane/ProjectPlane/FormPlaneConfig.Designer.cs
@@ -0,0 +1,381 @@
+namespace ProjectPlane
+{
+ 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()
+ {
+ this.groupBoxConfig = 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.panelPurple = new System.Windows.Forms.Panel();
+ this.panelYellow = new System.Windows.Forms.Panel();
+ this.panelBlack = new System.Windows.Forms.Panel();
+ this.panelBlue = new System.Windows.Forms.Panel();
+ this.panelGray = new System.Windows.Forms.Panel();
+ this.panelGreen = new System.Windows.Forms.Panel();
+ this.panelWhite = new System.Windows.Forms.Panel();
+ this.panelRed = new System.Windows.Forms.Panel();
+ this.checkBoxSuperTurbine = new System.Windows.Forms.CheckBox();
+ this.checkBoxExtraCell = new System.Windows.Forms.CheckBox();
+ this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
+ this.labelWeight = new System.Windows.Forms.Label();
+ this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
+ this.labelSpeed = new System.Windows.Forms.Label();
+ this.panelObject = new System.Windows.Forms.Panel();
+ this.labelDopColor = new System.Windows.Forms.Label();
+ this.labelBaseColor = new System.Windows.Forms.Label();
+ this.pictureBoxObject = new System.Windows.Forms.PictureBox();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonOk = new System.Windows.Forms.Button();
+ this.groupBoxConfig.SuspendLayout();
+ this.groupBoxColors.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
+ this.panelObject.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
+ this.SuspendLayout();
+ //
+ // groupBoxConfig
+ //
+ this.groupBoxConfig.Controls.Add(this.labelModifiedObject);
+ this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
+ this.groupBoxConfig.Controls.Add(this.groupBoxColors);
+ this.groupBoxConfig.Controls.Add(this.checkBoxSuperTurbine);
+ this.groupBoxConfig.Controls.Add(this.checkBoxExtraCell);
+ this.groupBoxConfig.Controls.Add(this.numericUpDownWeight);
+ this.groupBoxConfig.Controls.Add(this.labelWeight);
+ this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
+ this.groupBoxConfig.Controls.Add(this.labelSpeed);
+ this.groupBoxConfig.Location = new System.Drawing.Point(12, 12);
+ this.groupBoxConfig.Name = "groupBoxConfig";
+ this.groupBoxConfig.Size = new System.Drawing.Size(520, 220);
+ this.groupBoxConfig.TabIndex = 0;
+ this.groupBoxConfig.TabStop = false;
+ this.groupBoxConfig.Text = "Options";
+ //
+ // labelModifiedObject
+ //
+ this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelModifiedObject.Location = new System.Drawing.Point(394, 162);
+ this.labelModifiedObject.Name = "labelModifiedObject";
+ this.labelModifiedObject.Size = new System.Drawing.Size(97, 38);
+ this.labelModifiedObject.TabIndex = 16;
+ this.labelModifiedObject.Text = "Advanced";
+ 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.Location = new System.Drawing.Point(282, 162);
+ this.labelSimpleObject.Name = "labelSimpleObject";
+ this.labelSimpleObject.Size = new System.Drawing.Size(97, 38);
+ this.labelSimpleObject.TabIndex = 15;
+ this.labelSimpleObject.Text = "Basic";
+ this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
+ //
+ // groupBoxColors
+ //
+ this.groupBoxColors.Controls.Add(this.panelPurple);
+ this.groupBoxColors.Controls.Add(this.panelYellow);
+ this.groupBoxColors.Controls.Add(this.panelBlack);
+ this.groupBoxColors.Controls.Add(this.panelBlue);
+ this.groupBoxColors.Controls.Add(this.panelGray);
+ this.groupBoxColors.Controls.Add(this.panelGreen);
+ this.groupBoxColors.Controls.Add(this.panelWhite);
+ this.groupBoxColors.Controls.Add(this.panelRed);
+ this.groupBoxColors.Location = new System.Drawing.Point(267, 22);
+ this.groupBoxColors.Name = "groupBoxColors";
+ this.groupBoxColors.Size = new System.Drawing.Size(241, 127);
+ this.groupBoxColors.TabIndex = 14;
+ this.groupBoxColors.TabStop = false;
+ this.groupBoxColors.Text = "Colors";
+ //
+ // panelPurple
+ //
+ this.panelPurple.BackColor = System.Drawing.Color.Purple;
+ this.panelPurple.Location = new System.Drawing.Point(184, 73);
+ this.panelPurple.Name = "panelPurple";
+ this.panelPurple.Size = new System.Drawing.Size(40, 40);
+ this.panelPurple.TabIndex = 3;
+ //
+ // panelYellow
+ //
+ this.panelYellow.BackColor = System.Drawing.Color.Yellow;
+ this.panelYellow.Location = new System.Drawing.Point(184, 22);
+ this.panelYellow.Name = "panelYellow";
+ this.panelYellow.Size = new System.Drawing.Size(40, 40);
+ this.panelYellow.TabIndex = 1;
+ //
+ // panelBlack
+ //
+ this.panelBlack.BackColor = System.Drawing.Color.Black;
+ this.panelBlack.Location = new System.Drawing.Point(127, 73);
+ this.panelBlack.Name = "panelBlack";
+ this.panelBlack.Size = new System.Drawing.Size(40, 40);
+ this.panelBlack.TabIndex = 4;
+ //
+ // panelBlue
+ //
+ this.panelBlue.BackColor = System.Drawing.Color.Blue;
+ this.panelBlue.Location = new System.Drawing.Point(127, 22);
+ this.panelBlue.Name = "panelBlue";
+ this.panelBlue.Size = new System.Drawing.Size(40, 40);
+ this.panelBlue.TabIndex = 1;
+ //
+ // panelGray
+ //
+ this.panelGray.BackColor = System.Drawing.Color.Gray;
+ this.panelGray.Location = new System.Drawing.Point(72, 73);
+ this.panelGray.Name = "panelGray";
+ this.panelGray.Size = new System.Drawing.Size(40, 40);
+ this.panelGray.TabIndex = 5;
+ //
+ // panelGreen
+ //
+ this.panelGreen.BackColor = System.Drawing.Color.Green;
+ this.panelGreen.Location = new System.Drawing.Point(72, 22);
+ this.panelGreen.Name = "panelGreen";
+ this.panelGreen.Size = new System.Drawing.Size(40, 40);
+ this.panelGreen.TabIndex = 1;
+ //
+ // panelWhite
+ //
+ this.panelWhite.BackColor = System.Drawing.Color.White;
+ this.panelWhite.Location = new System.Drawing.Point(15, 73);
+ this.panelWhite.Name = "panelWhite";
+ this.panelWhite.Size = new System.Drawing.Size(40, 40);
+ this.panelWhite.TabIndex = 2;
+ //
+ // panelRed
+ //
+ this.panelRed.BackColor = System.Drawing.Color.Red;
+ this.panelRed.Location = new System.Drawing.Point(15, 22);
+ this.panelRed.Name = "panelRed";
+ this.panelRed.Size = new System.Drawing.Size(40, 40);
+ this.panelRed.TabIndex = 0;
+ //
+ // checkBoxSuperTurbine
+ //
+ this.checkBoxSuperTurbine.AutoSize = true;
+ this.checkBoxSuperTurbine.Location = new System.Drawing.Point(22, 185);
+ this.checkBoxSuperTurbine.Name = "checkBoxSuperTurbine";
+ this.checkBoxSuperTurbine.Size = new System.Drawing.Size(157, 19);
+ this.checkBoxSuperTurbine.TabIndex = 13;
+ this.checkBoxSuperTurbine.Text = "Indicator of superturbine";
+ this.checkBoxSuperTurbine.UseVisualStyleBackColor = true;
+ //
+ // checkBoxExtraCell
+ //
+ this.checkBoxExtraCell.AutoSize = true;
+ this.checkBoxExtraCell.Location = new System.Drawing.Point(22, 149);
+ this.checkBoxExtraCell.Name = "checkBoxExtraCell";
+ this.checkBoxExtraCell.Size = new System.Drawing.Size(137, 19);
+ this.checkBoxExtraCell.TabIndex = 12;
+ this.checkBoxExtraCell.Text = "Indicator of extra cell";
+ this.checkBoxExtraCell.UseVisualStyleBackColor = true;
+ //
+ // numericUpDownWeight
+ //
+ this.numericUpDownWeight.Location = new System.Drawing.Point(90, 72);
+ 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(79, 23);
+ this.numericUpDownWeight.TabIndex = 10;
+ this.numericUpDownWeight.Value = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
+ //
+ // labelWeight
+ //
+ this.labelWeight.AutoSize = true;
+ this.labelWeight.Location = new System.Drawing.Point(22, 74);
+ this.labelWeight.Name = "labelWeight";
+ this.labelWeight.Size = new System.Drawing.Size(48, 15);
+ this.labelWeight.TabIndex = 9;
+ this.labelWeight.Text = "Weight:";
+ //
+ // numericUpDownSpeed
+ //
+ this.numericUpDownSpeed.Location = new System.Drawing.Point(90, 30);
+ 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(79, 23);
+ this.numericUpDownSpeed.TabIndex = 8;
+ this.numericUpDownSpeed.Value = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
+ //
+ // labelSpeed
+ //
+ this.labelSpeed.AutoSize = true;
+ this.labelSpeed.Location = new System.Drawing.Point(22, 32);
+ this.labelSpeed.Name = "labelSpeed";
+ this.labelSpeed.Size = new System.Drawing.Size(42, 15);
+ this.labelSpeed.TabIndex = 7;
+ this.labelSpeed.Text = "Speed:";
+ //
+ // panelObject
+ //
+ this.panelObject.AllowDrop = true;
+ this.panelObject.Controls.Add(this.labelDopColor);
+ this.panelObject.Controls.Add(this.labelBaseColor);
+ this.panelObject.Controls.Add(this.pictureBoxObject);
+ this.panelObject.Location = new System.Drawing.Point(538, 12);
+ this.panelObject.Name = "panelObject";
+ this.panelObject.Size = new System.Drawing.Size(262, 184);
+ this.panelObject.TabIndex = 2;
+ this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
+ this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
+ //
+ // labelDopColor
+ //
+ this.labelDopColor.AllowDrop = true;
+ this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelDopColor.Location = new System.Drawing.Point(141, 9);
+ this.labelDopColor.Name = "labelDopColor";
+ this.labelDopColor.Size = new System.Drawing.Size(104, 32);
+ this.labelDopColor.TabIndex = 2;
+ this.labelDopColor.Text = "Extra color";
+ this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop);
+ this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragEnter);
+ //
+ // labelBaseColor
+ //
+ this.labelBaseColor.AllowDrop = true;
+ this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.labelBaseColor.Location = new System.Drawing.Point(20, 9);
+ this.labelBaseColor.Name = "labelBaseColor";
+ this.labelBaseColor.Size = new System.Drawing.Size(104, 32);
+ this.labelBaseColor.TabIndex = 1;
+ this.labelBaseColor.Text = "Color";
+ this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop);
+ this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragEnter);
+ //
+ // pictureBoxObject
+ //
+ this.pictureBoxObject.Location = new System.Drawing.Point(20, 44);
+ this.pictureBoxObject.Name = "pictureBoxObject";
+ this.pictureBoxObject.Size = new System.Drawing.Size(225, 125);
+ this.pictureBoxObject.TabIndex = 0;
+ this.pictureBoxObject.TabStop = false;
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(679, 202);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(104, 30);
+ this.buttonCancel.TabIndex = 5;
+ this.buttonCancel.Text = "Cancel";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // buttonOk
+ //
+ this.buttonOk.Location = new System.Drawing.Point(558, 202);
+ this.buttonOk.Name = "buttonOk";
+ this.buttonOk.Size = new System.Drawing.Size(104, 30);
+ this.buttonOk.TabIndex = 4;
+ this.buttonOk.Text = "Ok";
+ this.buttonOk.UseVisualStyleBackColor = true;
+ this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click);
+ //
+ // FormPlaneConfig
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(810, 242);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonOk);
+ this.Controls.Add(this.panelObject);
+ this.Controls.Add(this.groupBoxConfig);
+ this.Name = "FormPlaneConfig";
+ this.Text = "Create object";
+ this.groupBoxConfig.ResumeLayout(false);
+ this.groupBoxConfig.PerformLayout();
+ this.groupBoxColors.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
+ this.panelObject.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private GroupBox groupBoxConfig;
+ private CheckBox checkBoxSuperTurbine;
+ private CheckBox checkBoxExtraCell;
+ private NumericUpDown numericUpDownWeight;
+ private Label labelWeight;
+ private NumericUpDown numericUpDownSpeed;
+ private Label labelSpeed;
+ private Label labelModifiedObject;
+ private Label labelSimpleObject;
+ private GroupBox groupBoxColors;
+ private Panel panelPurple;
+ private Panel panelYellow;
+ private Panel panelBlack;
+ private Panel panelBlue;
+ private Panel panelGray;
+ private Panel panelGreen;
+ private Panel panelWhite;
+ private Panel panelRed;
+ private Panel panelObject;
+ private Label labelDopColor;
+ private Label labelBaseColor;
+ private PictureBox pictureBoxObject;
+ private Button buttonCancel;
+ private Button buttonOk;
+ }
+}
\ No newline at end of file
diff --git a/ProjectPlane/ProjectPlane/FormPlaneConfig.cs b/ProjectPlane/ProjectPlane/FormPlaneConfig.cs
new file mode 100644
index 0000000..72a7bce
--- /dev/null
+++ b/ProjectPlane/ProjectPlane/FormPlaneConfig.cs
@@ -0,0 +1,181 @@
+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 ProjectPlane
+{
+ public partial class FormPlaneConfig : Form
+ {
+ ///
+ /// Переменная-выбранная машина
+ ///
+ DrawingPlane _Plane = null;
+ ///
+ /// Событие
+ ///
+ private event PlaneDelegate EventAddPlane;
+ ///
+ /// Конструктор
+ ///
+ public FormPlaneConfig()
+ {
+ 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();
+ }
+ ///
+ /// Отрисовать cfvjktn
+ ///
+ private void DrawPlane()
+ {
+ Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _Plane?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height);
+ _Plane?.DrawTransport(gr);
+ pictureBoxObject.Image = bmp;
+ }
+ ///
+ /// Добавление события
+ ///
+ ///
+ public void AddEvent(PlaneDelegate ev)
+ {
+ if (EventAddPlane == null)
+ {
+ EventAddPlane = new PlaneDelegate(ev);
+ }
+ else
+ {
+ EventAddPlane += 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))
+ {
+ 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 DrawingPlane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White);
+ break;
+ case "labelModifiedObject":
+ _Plane = new DrawingWarPlane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black,
+ checkBoxExtraCell.Checked, checkBoxSuperTurbine.Checked);
+ break;
+ }
+ DrawPlane();
+ }
+ ///
+ /// Отправляем цвет с панели
+ ///
+ ///
+ ///
+ private void PanelColor_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+ ///
+ /// Проверка получаемой информации (ее типа на соответствие требуемому)
+ ///
+ ///
+ ///
+ private void LabelBaseColor_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)
+ {
+ _Plane.setBaseColor((Color)e.Data.GetData(typeof(Color)));
+
+ DrawPlane();
+ }
+ private void LabelDopColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(typeof(Color)))
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+ ///
+ /// Принимаем дополнительный цвет
+ ///
+ ///
+ ///
+ private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_Plane is DrawingWarPlane)
+ {
+ (_Plane as DrawingWarPlane).setDopColor((Color)e.Data.GetData(typeof(Color)));
+ }
+ DrawPlane();
+ }
+ ///
+ /// Добавление самолета
+ ///
+ ///
+ ///
+ private void ButtonOk_Click(object sender, EventArgs e)
+ {
+ EventAddPlane?.Invoke(_Plane);
+ Close();
+ }
+ }
+}
diff --git a/ProjectPlane/ProjectPlane/FormPlaneConfig.resx b/ProjectPlane/ProjectPlane/FormPlaneConfig.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/ProjectPlane/ProjectPlane/FormPlaneConfig.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
diff --git a/ProjectPlane/ProjectPlane/PlaneDelegate.cs b/ProjectPlane/ProjectPlane/PlaneDelegate.cs
new file mode 100644
index 0000000..c69f01b
--- /dev/null
+++ b/ProjectPlane/ProjectPlane/PlaneDelegate.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectPlane
+{
+ ///
+ /// Делегат для передачи объекта-самолета
+ ///
+ ///
+ public delegate void PlaneDelegate(DrawingPlane plane);
+}