diff --git a/RPP/RPP/DrawningAirbus.cs b/RPP/RPP/DrawningAirbus.cs
index ce409ad..f5d5be8 100644
--- a/RPP/RPP/DrawningAirbus.cs
+++ b/RPP/RPP/DrawningAirbus.cs
@@ -8,7 +8,7 @@ namespace RPP.DrawningObjects
public class DrawningAirbus
{
- public EntityAirbus? EntityAirbus { get; protected set; }
+ public EntityAirbus? _EntityAirbus { get; protected set; }
private int _pictureWidth;
@@ -32,19 +32,19 @@ namespace RPP.DrawningObjects
public bool CanMove(Direction direction)
{
- if (EntityAirbus == null)
+ if (_EntityAirbus == null)
{
return false;
}
return direction switch
{
//влево
- Direction.Left => _startPosX - EntityAirbus.Step > 5,
+ Direction.Left => _startPosX - _EntityAirbus.Step > 5,
//вверх
- Direction.Up => _startPosY - EntityAirbus.Step > 0,
+ Direction.Up => _startPosY - _EntityAirbus.Step > 0,
// вправо
- Direction.Right => _startPosX + EntityAirbus.Step + _AirbusWidth < _pictureWidth,
- Direction.Down => _startPosY + EntityAirbus.Step + _AirbusHeight < _pictureHeight
+ Direction.Right => _startPosX + _EntityAirbus.Step + _AirbusWidth < _pictureWidth,
+ Direction.Down => _startPosY + _EntityAirbus.Step + _AirbusHeight < _pictureHeight
};
}
@@ -53,7 +53,7 @@ namespace RPP.DrawningObjects
_pictureWidth = width;
_pictureHeight = height;
- EntityAirbus = new EntityAirbus(speed, weight, bodyColor);
+ _EntityAirbus = new EntityAirbus(speed, weight, bodyColor);
}
@@ -65,10 +65,12 @@ namespace RPP.DrawningObjects
_pictureHeight = height;
_AirbusWidth = airbusWidth;
_AirbusHeight = airbusHeight;
- EntityAirbus = new EntityAirbus(speed, weight, bodyColor);
+ _EntityAirbus = new EntityAirbus(speed, weight, bodyColor);
+ }
+ public void SetBodyColor(Color bodyColor)
+ {
+ _EntityAirbus.ChangeColor(bodyColor);
}
-
-
public void SetPosition(int x, int y)
{
@@ -79,7 +81,7 @@ namespace RPP.DrawningObjects
public void MoveTransport(Direction direction)
{
- if (!CanMove(direction) || EntityAirbus == null)
+ if (!CanMove(direction) || _EntityAirbus == null)
{
return;
}
@@ -87,30 +89,30 @@ namespace RPP.DrawningObjects
{
//влево
case Direction.Left:
- if (_startPosX - EntityAirbus.Step > 5)
+ if (_startPosX - _EntityAirbus.Step > 5)
{
- _startPosX -= (int)EntityAirbus.Step;
+ _startPosX -= (int)_EntityAirbus.Step;
}
break;
//вверх
case Direction.Up:
- if (_startPosY - EntityAirbus.Step > 0)
+ if (_startPosY - _EntityAirbus.Step > 0)
{
- _startPosY -= (int)EntityAirbus.Step;
+ _startPosY -= (int)_EntityAirbus.Step;
}
break;
//вправо
case Direction.Right:
- if (_startPosX + EntityAirbus.Step + _AirbusWidth < _pictureWidth)
+ if (_startPosX + _EntityAirbus.Step + _AirbusWidth < _pictureWidth)
{
- _startPosX += (int)EntityAirbus.Step;
+ _startPosX += (int)_EntityAirbus.Step;
}
break;
//вниз
case Direction.Down:
- if (_startPosY + EntityAirbus.Step + _AirbusHeight < _pictureHeight)
+ if (_startPosY + _EntityAirbus.Step + _AirbusHeight < _pictureHeight)
{
- _startPosY += (int)EntityAirbus.Step;
+ _startPosY += (int)_EntityAirbus.Step;
}
break;
}
@@ -120,12 +122,11 @@ namespace RPP.DrawningObjects
public virtual void DrawTransport(Graphics g)
{
- if (EntityAirbus == null)
+ if (_EntityAirbus == null)
{
return;
}
- Pen pen = new(EntityAirbus.BodyColor, 3);
- Brush brush = new SolidBrush(EntityAirbus.BodyColor);
+ Pen pen = new(_EntityAirbus.BodyColor, 3);
//Тело
g.DrawRectangle(pen, _startPosX + 5, _startPosY + 50, 170, 30);
g.DrawPie(pen, _startPosX - 5, _startPosY + 50, 20, 30, 90, 180);
@@ -136,7 +137,7 @@ namespace RPP.DrawningObjects
g.DrawLine(pen, _startPosX, _startPosY, _startPosX, _startPosY + 52);
//Заднее боковые крылья
- Pen bigPen = new Pen(EntityAirbus.BodyColor, 8);
+ Pen bigPen = new Pen(_EntityAirbus.BodyColor, 8);
g.DrawPie(pen, _startPosX - 7, _startPosY + 45, 5, 10, 90, 180);
g.DrawLine(bigPen, _startPosX - 6, _startPosY + 48, _startPosX + 30, _startPosY + 48);
g.DrawLine(bigPen, _startPosX - 6, _startPosY + 52, _startPosX + 30, _startPosY + 52);
@@ -152,7 +153,6 @@ namespace RPP.DrawningObjects
g.DrawPie(pen, _startPosX + 139, _startPosY + 62, 5, 5, 180, 270);
//Задние шасси
g.DrawLine(pen, _startPosX + 55, _startPosY + 80, _startPosX + 55, _startPosY + 90);
- Pen tallpen = new(EntityAirbus.BodyColor, 2);
g.DrawEllipse(pen, _startPosX + 47, _startPosY + 90, 5, 5);
g.DrawEllipse(pen, _startPosX + 57, _startPosY + 90, 5, 5);
//Передние шасси
diff --git a/RPP/RPP/DrawningFlyAirbus.cs b/RPP/RPP/DrawningFlyAirbus.cs
index e1c0c10..5e5a9fc 100644
--- a/RPP/RPP/DrawningFlyAirbus.cs
+++ b/RPP/RPP/DrawningFlyAirbus.cs
@@ -14,16 +14,19 @@ namespace RPP.DrawningObjects
additionalColor, bool compartment, bool engine, int width, int height) :
base(speed, weight, bodyColor, width, height, 200, 100)
{
- if (EntityAirbus != null)
+ if (_EntityAirbus != null)
{
- EntityAirbus = new EntityFlyAirbus(speed, weight, bodyColor,
+ _EntityAirbus = new EntityFlyAirbus(speed, weight, bodyColor,
additionalColor, compartment, engine);
}
}
-
+ public void SetAdditionalColor(Color additionalColor)
+ {
+ (_EntityAirbus as EntityFlyAirbus).ChangedAddColor(additionalColor);
+ }
public override void DrawTransport(Graphics g)
{
- if (EntityAirbus is not EntityFlyAirbus FlyAirbus)
+ if (_EntityAirbus is not EntityFlyAirbus FlyAirbus)
{
return;
}
diff --git a/RPP/RPP/DrawningObjectAirbus.cs b/RPP/RPP/DrawningObjectAirbus.cs
index 8f9796d..f94dc4e 100644
--- a/RPP/RPP/DrawningObjectAirbus.cs
+++ b/RPP/RPP/DrawningObjectAirbus.cs
@@ -18,7 +18,7 @@ namespace RPP.MovementStrategy
{
get
{
- if (_drawningAirbus == null || _drawningAirbus.EntityAirbus == null)
+ if (_drawningAirbus == null || _drawningAirbus._EntityAirbus == null)
{
return null;
}
@@ -26,7 +26,7 @@ namespace RPP.MovementStrategy
_drawningAirbus.GetPosY, _drawningAirbus.GetWidth, _drawningAirbus.GetHeight);
}
}
- public int GetStep => (int)(_drawningAirbus?.EntityAirbus?.Step ?? 0);
+ public int GetStep => (int)(_drawningAirbus?._EntityAirbus?.Step ?? 0);
public bool CheckCanMove(Direction direction) =>
_drawningAirbus?.CanMove(direction) ?? false;
public void MoveObject(Direction direction) =>
diff --git a/RPP/RPP/EntityAirbus.cs b/RPP/RPP/EntityAirbus.cs
index c0f1718..da8f333 100644
--- a/RPP/RPP/EntityAirbus.cs
+++ b/RPP/RPP/EntityAirbus.cs
@@ -23,6 +23,9 @@ namespace RPP.Entities
Weight = weight;
BodyColor = bodyColor;
}
-
+ public void ChangeColor(Color color)
+ {
+ BodyColor = color;
+ }
}
}
diff --git a/RPP/RPP/EntityFlyAirbus.cs b/RPP/RPP/EntityFlyAirbus.cs
index d5a91c6..8faeee9 100644
--- a/RPP/RPP/EntityFlyAirbus.cs
+++ b/RPP/RPP/EntityFlyAirbus.cs
@@ -22,5 +22,9 @@ namespace RPP.Entities
Compartment = compartment;
Engine = engine;
}
+ public void ChangedAddColor(Color color)
+ {
+ AdditionalColor = color;
+ }
}
}
diff --git a/RPP/RPP/FormAirbusCollection.cs b/RPP/RPP/FormAirbusCollection.cs
index 8dc7fe1..e4587cd 100644
--- a/RPP/RPP/FormAirbusCollection.cs
+++ b/RPP/RPP/FormAirbusCollection.cs
@@ -13,13 +13,35 @@ namespace RPP
{
InitializeComponent();
_storage = new AirbusGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
+
}
private void FormFlyAirbus_Load(object sender, EventArgs e)
{
}
+ private void AddAirbus(DrawningAirbus Airbus)
+ {
+ if (listBoxStorages.SelectedIndex == -1)
+ {
+ return;
+ }
+ var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
+ if (obj == null)
+ {
+ return;
+ }
+ if (obj + Airbus)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBoxCollection.Image = obj.ShowCars();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
private void AddAirbusButton_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
@@ -31,20 +53,9 @@ namespace RPP
{
return;
}
- FormAirbus form = new();
- if (form.ShowDialog() == DialogResult.OK)
- {
- if (obj + form.SelectedAirbus)
- {
- MessageBox.Show("Объект добавлен");
- pictureBoxCollection.Image = obj.ShowCars();
- }
- else
- {
- MessageBox.Show("Не удалось добавить объект");
- }
- }
-
+ var formAirbusConfig = new FormAirbusConfig();
+ formAirbusConfig.Show();
+ formAirbusConfig.AddEvent(AddAirbus);
}
private void ReloadObjects()
{
diff --git a/RPP/RPP/FormAirbusConfig.Designer.cs b/RPP/RPP/FormAirbusConfig.Designer.cs
new file mode 100644
index 0000000..d34e4fd
--- /dev/null
+++ b/RPP/RPP/FormAirbusConfig.Designer.cs
@@ -0,0 +1,378 @@
+namespace RPP
+{
+ partial class FormAirbusConfig
+ {
+ ///
+ /// 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()
+ {
+ groupBoxParameters = new GroupBox();
+ labelFly = new Label();
+ labelBase = new Label();
+ groupBoxColor = new GroupBox();
+ panelPurple = new Panel();
+ panelBlack = new Panel();
+ panelGray = new Panel();
+ panelWhite = new Panel();
+ panelYellow = new Panel();
+ panelBlue = new Panel();
+ panelGreen = new Panel();
+ panelRed = new Panel();
+ checkBoxEngine = new CheckBox();
+ checkBoxCompartment = new CheckBox();
+ numericUpDownWeight = new NumericUpDown();
+ label2 = new Label();
+ numericUpDownSpeed = new NumericUpDown();
+ label1 = new Label();
+ panel9 = new Panel();
+ pictureBoxObject = new PictureBox();
+ labelAdditionalColor = new Label();
+ labelColor = new Label();
+ buttonAdd = new Button();
+ buttonCancel = new Button();
+ groupBoxParameters.SuspendLayout();
+ groupBoxColor.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
+ panel9.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
+ SuspendLayout();
+ //
+ // groupBoxParameters
+ //
+ groupBoxParameters.Controls.Add(labelFly);
+ groupBoxParameters.Controls.Add(labelBase);
+ groupBoxParameters.Controls.Add(groupBoxColor);
+ groupBoxParameters.Controls.Add(checkBoxEngine);
+ groupBoxParameters.Controls.Add(checkBoxCompartment);
+ groupBoxParameters.Controls.Add(numericUpDownWeight);
+ groupBoxParameters.Controls.Add(label2);
+ groupBoxParameters.Controls.Add(numericUpDownSpeed);
+ groupBoxParameters.Controls.Add(label1);
+ groupBoxParameters.Location = new Point(14, 16);
+ groupBoxParameters.Margin = new Padding(3, 4, 3, 4);
+ groupBoxParameters.Name = "groupBoxParameters";
+ groupBoxParameters.Padding = new Padding(3, 4, 3, 4);
+ groupBoxParameters.Size = new Size(627, 368);
+ groupBoxParameters.TabIndex = 0;
+ groupBoxParameters.TabStop = false;
+ groupBoxParameters.Text = "Параметры";
+ //
+ // labelFly
+ //
+ labelFly.BorderStyle = BorderStyle.FixedSingle;
+ labelFly.Location = new Point(446, 292);
+ labelFly.Name = "labelFly";
+ labelFly.Size = new Size(135, 47);
+ labelFly.TabIndex = 8;
+ labelFly.Text = "Продвинутый";
+ labelFly.TextAlign = ContentAlignment.MiddleCenter;
+ labelFly.MouseDown += LabelObject_MouseDown;
+ //
+ // labelBase
+ //
+ labelBase.BorderStyle = BorderStyle.FixedSingle;
+ labelBase.Location = new Point(291, 292);
+ labelBase.Name = "labelBase";
+ labelBase.Size = new Size(129, 47);
+ labelBase.TabIndex = 7;
+ labelBase.Text = "Простой";
+ labelBase.TextAlign = ContentAlignment.MiddleCenter;
+ labelBase.MouseDown += LabelObject_MouseDown;
+ //
+ // groupBoxColor
+ //
+ groupBoxColor.Controls.Add(panelPurple);
+ groupBoxColor.Controls.Add(panelBlack);
+ groupBoxColor.Controls.Add(panelGray);
+ groupBoxColor.Controls.Add(panelWhite);
+ groupBoxColor.Controls.Add(panelYellow);
+ groupBoxColor.Controls.Add(panelBlue);
+ groupBoxColor.Controls.Add(panelGreen);
+ groupBoxColor.Controls.Add(panelRed);
+ groupBoxColor.Location = new Point(272, 40);
+ groupBoxColor.Margin = new Padding(3, 4, 3, 4);
+ groupBoxColor.Name = "groupBoxColor";
+ groupBoxColor.Padding = new Padding(3, 4, 3, 4);
+ groupBoxColor.Size = new Size(327, 223);
+ groupBoxColor.TabIndex = 6;
+ groupBoxColor.TabStop = false;
+ groupBoxColor.Text = "Цвета";
+ //
+ // panelPurple
+ //
+ panelPurple.BackColor = Color.Purple;
+ panelPurple.Location = new Point(255, 129);
+ panelPurple.Margin = new Padding(3, 4, 3, 4);
+ panelPurple.Name = "panelPurple";
+ panelPurple.Size = new Size(54, 59);
+ panelPurple.TabIndex = 7;
+ //
+ // panelBlack
+ //
+ panelBlack.BackColor = Color.Black;
+ panelBlack.Location = new Point(174, 129);
+ panelBlack.Margin = new Padding(3, 4, 3, 4);
+ panelBlack.Name = "panelBlack";
+ panelBlack.Size = new Size(54, 59);
+ panelBlack.TabIndex = 6;
+ //
+ // panelGray
+ //
+ panelGray.BackColor = Color.Gray;
+ panelGray.Location = new Point(95, 129);
+ panelGray.Margin = new Padding(3, 4, 3, 4);
+ panelGray.Name = "panelGray";
+ panelGray.Size = new Size(54, 59);
+ panelGray.TabIndex = 5;
+ //
+ // panelWhite
+ //
+ panelWhite.BackColor = Color.White;
+ panelWhite.Location = new Point(19, 129);
+ panelWhite.Margin = new Padding(3, 4, 3, 4);
+ panelWhite.Name = "panelWhite";
+ panelWhite.Size = new Size(54, 59);
+ panelWhite.TabIndex = 4;
+ //
+ // panelYellow
+ //
+ panelYellow.BackColor = Color.Yellow;
+ panelYellow.Location = new Point(255, 43);
+ panelYellow.Margin = new Padding(3, 4, 3, 4);
+ panelYellow.Name = "panelYellow";
+ panelYellow.Size = new Size(54, 60);
+ panelYellow.TabIndex = 3;
+ //
+ // panelBlue
+ //
+ panelBlue.BackColor = Color.Blue;
+ panelBlue.Location = new Point(174, 43);
+ panelBlue.Margin = new Padding(3, 4, 3, 4);
+ panelBlue.Name = "panelBlue";
+ panelBlue.Size = new Size(54, 60);
+ panelBlue.TabIndex = 2;
+ //
+ // panelGreen
+ //
+ panelGreen.BackColor = Color.Green;
+ panelGreen.Location = new Point(95, 43);
+ panelGreen.Margin = new Padding(3, 4, 3, 4);
+ panelGreen.Name = "panelGreen";
+ panelGreen.Size = new Size(54, 60);
+ panelGreen.TabIndex = 1;
+ //
+ // panelRed
+ //
+ panelRed.BackColor = Color.Red;
+ panelRed.Location = new Point(19, 43);
+ panelRed.Margin = new Padding(3, 4, 3, 4);
+ panelRed.Name = "panelRed";
+ panelRed.Size = new Size(54, 59);
+ panelRed.TabIndex = 0;
+ //
+ // checkBoxEngine
+ //
+ checkBoxEngine.AutoSize = true;
+ checkBoxEngine.Location = new Point(17, 264);
+ checkBoxEngine.Margin = new Padding(3, 4, 3, 4);
+ checkBoxEngine.Name = "checkBoxEngine";
+ checkBoxEngine.Size = new Size(269, 24);
+ checkBoxEngine.TabIndex = 5;
+ checkBoxEngine.Text = "Признак наличия доп. двигателей";
+ checkBoxEngine.UseVisualStyleBackColor = true;
+ //
+ // checkBoxCompartment
+ //
+ checkBoxCompartment.AutoSize = true;
+ checkBoxCompartment.Location = new Point(17, 203);
+ checkBoxCompartment.Margin = new Padding(3, 4, 3, 4);
+ checkBoxCompartment.Name = "checkBoxCompartment";
+ checkBoxCompartment.Size = new Size(236, 24);
+ checkBoxCompartment.TabIndex = 4;
+ checkBoxCompartment.Text = "Признак наличия доп. отсека";
+ checkBoxCompartment.UseVisualStyleBackColor = true;
+ //
+ // numericUpDownWeight
+ //
+ numericUpDownWeight.Location = new Point(95, 89);
+ numericUpDownWeight.Margin = new Padding(3, 4, 3, 4);
+ 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(79, 27);
+ numericUpDownWeight.TabIndex = 3;
+ numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(17, 89);
+ label2.Name = "label2";
+ label2.Size = new Size(36, 20);
+ label2.TabIndex = 2;
+ label2.Text = "Вес:";
+ //
+ // numericUpDownSpeed
+ //
+ numericUpDownSpeed.Location = new Point(95, 36);
+ numericUpDownSpeed.Margin = new Padding(3, 4, 3, 4);
+ 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(79, 27);
+ numericUpDownSpeed.TabIndex = 1;
+ numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(17, 39);
+ label1.Name = "label1";
+ label1.Size = new Size(76, 20);
+ label1.TabIndex = 0;
+ label1.Text = "Скорость:";
+ //
+ // panel9
+ //
+ panel9.AllowDrop = true;
+ panel9.Controls.Add(pictureBoxObject);
+ panel9.Location = new Point(675, 87);
+ panel9.Margin = new Padding(3, 4, 3, 4);
+ panel9.Name = "panel9";
+ panel9.Size = new Size(354, 244);
+ panel9.TabIndex = 1;
+ panel9.DragDrop += PanelObject_DragDrop;
+ panel9.DragEnter += PanelObject_DragEnter;
+ //
+ // pictureBoxObject
+ //
+ pictureBoxObject.Location = new Point(27, 4);
+ pictureBoxObject.Margin = new Padding(3, 4, 3, 4);
+ pictureBoxObject.Name = "pictureBoxObject";
+ pictureBoxObject.Size = new Size(323, 236);
+ pictureBoxObject.TabIndex = 2;
+ pictureBoxObject.TabStop = false;
+ //
+ // labelAdditionalColor
+ //
+ labelAdditionalColor.AllowDrop = true;
+ labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
+ labelAdditionalColor.Location = new Point(870, 35);
+ labelAdditionalColor.Name = "labelAdditionalColor";
+ labelAdditionalColor.Size = new Size(133, 47);
+ labelAdditionalColor.TabIndex = 1;
+ labelAdditionalColor.Text = "Доп. цвет";
+ labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelAdditionalColor.DragDrop += labelColor_DragDrop;
+ labelAdditionalColor.DragEnter += labelColor_DragEnter;
+ //
+ // labelColor
+ //
+ labelColor.AllowDrop = true;
+ labelColor.BorderStyle = BorderStyle.FixedSingle;
+ labelColor.Location = new Point(703, 35);
+ labelColor.Name = "labelColor";
+ labelColor.Size = new Size(133, 47);
+ labelColor.TabIndex = 0;
+ labelColor.Text = "Цвет";
+ labelColor.TextAlign = ContentAlignment.MiddleCenter;
+ labelColor.DragDrop += labelColor_DragDrop;
+ labelColor.DragEnter += labelColor_DragEnter;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(703, 339);
+ buttonAdd.Margin = new Padding(3, 4, 3, 4);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(134, 45);
+ buttonAdd.TabIndex = 2;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonOk_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(870, 339);
+ buttonCancel.Margin = new Padding(3, 4, 3, 4);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(134, 45);
+ buttonCancel.TabIndex = 3;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // FormAirbusConfig
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1057, 400);
+ Controls.Add(buttonCancel);
+ Controls.Add(labelAdditionalColor);
+ Controls.Add(labelColor);
+ Controls.Add(buttonAdd);
+ Controls.Add(panel9);
+ Controls.Add(groupBoxParameters);
+ Margin = new Padding(3, 4, 3, 4);
+ Name = "FormAirbusConfig";
+ Text = "FormAirbusConfig";
+ Load += FormAirbusConfig_Load;
+ groupBoxParameters.ResumeLayout(false);
+ groupBoxParameters.PerformLayout();
+ groupBoxColor.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
+ panel9.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private GroupBox groupBoxParameters;
+ private NumericUpDown numericUpDownWeight;
+ private Label label2;
+ private NumericUpDown numericUpDownSpeed;
+ private Label label1;
+ private CheckBox checkBoxCompartment;
+ private GroupBox groupBoxColor;
+ private CheckBox checkBoxEngine;
+ private Panel panelBlack;
+ private Panel panelGray;
+ private Panel panelWhite;
+ private Panel panelYellow;
+ private Panel panelBlue;
+ private Panel panelGreen;
+ private Panel panelRed;
+ private Label labelFly;
+ private Label labelBase;
+ private Panel panelPurple;
+ private Panel panel9;
+ private Label labelAdditionalColor;
+ private Label labelColor;
+ private PictureBox pictureBoxObject;
+ private Button buttonAdd;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/RPP/RPP/FormAirbusConfig.cs b/RPP/RPP/FormAirbusConfig.cs
new file mode 100644
index 0000000..148c717
--- /dev/null
+++ b/RPP/RPP/FormAirbusConfig.cs
@@ -0,0 +1,170 @@
+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 RPP.DrawningObjects;
+using RPP.Entities;
+
+namespace RPP
+{
+ public delegate void AirbusDelegate(DrawningAirbus Airbus);
+ public partial class FormAirbusConfig : Form
+ {
+ DrawningAirbus? _airbus = null;
+ ///
+ /// Событие
+ ///
+ private event Action? EventAddAirbus;
+
+ public FormAirbusConfig()
+ {
+
+ 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 += (s, e) => Close();
+ }
+
+ private void FormAirbusConfig_Load(object sender, EventArgs e)
+ {
+
+ }
+
+ ///
+ /// Отрисовать машину
+ ///
+ private void DrawAirbus()
+ {
+ Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _airbus?.SetPosition(15, 5);
+ if (_airbus is DrawningFlyAirbus drawningFlyAirbus)
+ drawningFlyAirbus.DrawTransport(gr);
+ else
+ _airbus?.DrawTransport(gr);
+ pictureBoxObject.Image = bmp;
+ }
+ ///
+ /// Передаем информацию при нажатии на 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 "labelBase":
+ _airbus = new DrawningAirbus((int)numericUpDownSpeed.Value,
+ (int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
+ pictureBoxObject.Height);
+ break;
+ case "labelFly":
+ _airbus = new DrawningFlyAirbus((int)numericUpDownSpeed.Value,
+ (int)numericUpDownWeight.Value, Color.White, Color.Black,
+ checkBoxCompartment.Checked, checkBoxEngine.Checked, pictureBoxObject.Width,
+ pictureBoxObject.Height);
+ break;
+ }
+ DrawAirbus();
+ }
+ /// Добавление события
+ ///
+ /// Привязанный метод
+ public void AddEvent(Action ev)
+ {
+ if (EventAddAirbus == null)
+ {
+ EventAddAirbus = ev;
+ }
+ else
+ {
+ EventAddAirbus += ev;
+ }
+ }
+ ///
+ /// Добавление машины
+ ///
+ ///
+ ///
+ private void ButtonOk_Click(object sender, EventArgs e)
+ {
+ EventAddAirbus?.Invoke(_airbus);
+ 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 (e.Data?.GetDataPresent(typeof(Color)) ?? false)
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
+ private void labelColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_airbus == null)
+ return;
+ ((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color));
+ switch (((Label)sender).Name)
+ {
+ case "labelColor":
+ _airbus.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
+ break;
+ case "labelAdditionalColor":
+ if (!(_airbus is DrawningFlyAirbus))
+ return;
+ (_airbus as DrawningFlyAirbus).SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
+ break;
+ }
+ DrawAirbus();
+ }
+ }
+}
+
diff --git a/RPP/RPP/FormAirbusConfig.resx b/RPP/RPP/FormAirbusConfig.resx
new file mode 100644
index 0000000..a395bff
--- /dev/null
+++ b/RPP/RPP/FormAirbusConfig.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