Изменение логики многих классов, исправление ошибок, создание класса AirPlaneDelegate
This commit is contained in:
parent
2b1fbcbf93
commit
ede63a0ae5
10
AirBomber/AirBomber/AirPlaneDelegate.cs
Normal file
10
AirBomber/AirBomber/AirPlaneDelegate.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirBomber
|
||||||
|
{
|
||||||
|
public delegate void AirPlaneDelegate(DrawningAirPlane plane);
|
||||||
|
}
|
@ -39,18 +39,24 @@ namespace AirBomber
|
|||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor);
|
Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor);
|
||||||
base.DrawPlane(g);
|
base.DrawPlane(g);
|
||||||
// обвесы
|
// bombs
|
||||||
g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 20, 15, 29);
|
if(airBomber.Bombs)
|
||||||
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 20, 15, 29);
|
{
|
||||||
g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 70, 15, 29);
|
g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 20, 15, 29);
|
||||||
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 70, 15, 29);
|
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 20, 15, 29);
|
||||||
g.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 50, 15, 15);
|
g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 70, 15, 29);
|
||||||
g.DrawEllipse(pen, _startPosX + 140, _startPosY + 50, 15, 15);
|
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 70, 15, 29);
|
||||||
|
g.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 50, 15, 15);
|
||||||
|
g.DrawEllipse(pen, _startPosX + 140, _startPosY + 50, 15, 15);
|
||||||
|
}
|
||||||
// fueltanks
|
// fueltanks
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 34, 20, 15);
|
if (airBomber.FuelTanks)
|
||||||
g.DrawRectangle(pen, _startPosX + 63, _startPosY + 34, 20, 15);
|
{
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 70, 20, 15);
|
g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 34, 20, 15);
|
||||||
g.DrawRectangle(pen, _startPosX + 63, _startPosY + 70, 20, 15);
|
g.DrawRectangle(pen, _startPosX + 63, _startPosY + 34, 20, 15);
|
||||||
|
g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 70, 20, 15);
|
||||||
|
g.DrawRectangle(pen, _startPosX + 63, _startPosY + 70, 20, 15);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,11 @@ namespace AirBomber
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна
|
/// Ширина окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _pictureWidth;
|
public int _pictureWidth;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота окна
|
/// Высота окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _pictureHeight;
|
public int _pictureHeight;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Левая координата прорисовки самолета
|
/// Левая координата прорисовки самолета
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -272,7 +272,6 @@ namespace AirBomber
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта IMoveableObject из объекта DrawningAirPlane
|
/// Получение объекта IMoveableObject из объекта DrawningAirPlane
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IMoveableObject GetMoveableObject => new
|
public IMoveableObject GetMoveableObject => new DrawningObjectAirPlane(this);
|
||||||
DrawningObjectAirPlane(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,15 @@ namespace AirBomber
|
|||||||
public bool Bombs { get; private set; }
|
public bool Bombs { get; private set; }
|
||||||
public Color BombsColor { get; private set; }
|
public Color BombsColor { get; private set; }
|
||||||
public bool FuelTanks { get; private set; }
|
public bool FuelTanks { get; private set; }
|
||||||
public EntityAirBomber(int speed, double weight, Color bodyColor, Color
|
public EntityAirBomber(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks) : base(speed, weight, bodyColor)
|
||||||
additionalColor, bool bombs, bool fuelTanks) : base(speed, weight, bodyColor)
|
|
||||||
{
|
{
|
||||||
AdditionalColor = additionalColor;
|
AdditionalColor = additionalColor;
|
||||||
Bombs = bombs;
|
Bombs = bombs;
|
||||||
FuelTanks = fuelTanks;
|
FuelTanks = fuelTanks;
|
||||||
}
|
}
|
||||||
|
public void SetAdditionalColor(Color color)
|
||||||
|
{
|
||||||
|
AdditionalColor = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,5 +37,9 @@ namespace AirBomber
|
|||||||
Weight = weight;
|
Weight = weight;
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
|
public void SetBodyColor(Color color)
|
||||||
|
{
|
||||||
|
BodyColor = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,28 +58,10 @@ namespace AirBomber
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void buttonAddPlane_Click(object sender, EventArgs e)
|
private void buttonAddPlane_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
var formPlaneConfig = new FormPlaneConfig();
|
||||||
{
|
// TODO DONE
|
||||||
return;
|
formPlaneConfig.AddEvent(AddPlane);
|
||||||
}
|
formPlaneConfig.Show();
|
||||||
var obj = _storage[listBoxStorages.SelectedItem.ToString()?? string.Empty];
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FormAirBomber form = new();
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (obj + form.SelectedPlane > -1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
pictureBoxCollection.Image = obj.ShowPlanes();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление объекта из набора
|
/// Удаление объекта из набора
|
||||||
@ -158,5 +140,27 @@ namespace AirBomber
|
|||||||
ReloadObjects();
|
ReloadObjects();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void AddPlane(DrawningAirPlane plane)
|
||||||
|
{
|
||||||
|
plane._pictureWidth = pictureBoxCollection.Width;
|
||||||
|
plane._pictureHeight = pictureBoxCollection.Height;
|
||||||
|
|
||||||
|
if (listBoxStorages.SelectedIndex == -1) return;
|
||||||
|
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (obj + plane > -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBoxCollection.Image = obj.ShowPlanes();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
79
AirBomber/AirBomber/FormPlaneConfig.Designer.cs
generated
79
AirBomber/AirBomber/FormPlaneConfig.Designer.cs
generated
@ -34,7 +34,7 @@
|
|||||||
groupBoxColors = new GroupBox();
|
groupBoxColors = new GroupBox();
|
||||||
panelPurple = new Panel();
|
panelPurple = new Panel();
|
||||||
panelBlack = new Panel();
|
panelBlack = new Panel();
|
||||||
panelGrey = new Panel();
|
panelGray = new Panel();
|
||||||
panelWhite = new Panel();
|
panelWhite = new Panel();
|
||||||
panelYellow = new Panel();
|
panelYellow = new Panel();
|
||||||
panelBlue = new Panel();
|
panelBlue = new Panel();
|
||||||
@ -48,8 +48,8 @@
|
|||||||
labelSpeed = new Label();
|
labelSpeed = new Label();
|
||||||
pictureBoxObject = new PictureBox();
|
pictureBoxObject = new PictureBox();
|
||||||
panelObject = new Panel();
|
panelObject = new Panel();
|
||||||
labelColor = new Label();
|
|
||||||
labelAddColor = new Label();
|
labelAddColor = new Label();
|
||||||
|
labelColor = new Label();
|
||||||
buttonOk = new Button();
|
buttonOk = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
groupBoxParameters.SuspendLayout();
|
groupBoxParameters.SuspendLayout();
|
||||||
@ -87,6 +87,7 @@
|
|||||||
labelModifiedObject.TabIndex = 8;
|
labelModifiedObject.TabIndex = 8;
|
||||||
labelModifiedObject.Text = "Продвинутый";
|
labelModifiedObject.Text = "Продвинутый";
|
||||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelModifiedObject.MouseDown += labelObject_MouseDown;
|
||||||
//
|
//
|
||||||
// labelSimpleObject
|
// labelSimpleObject
|
||||||
//
|
//
|
||||||
@ -97,13 +98,13 @@
|
|||||||
labelSimpleObject.TabIndex = 7;
|
labelSimpleObject.TabIndex = 7;
|
||||||
labelSimpleObject.Text = "Простой";
|
labelSimpleObject.Text = "Простой";
|
||||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
labelSimpleObject.MouseDown += labelSimpleObject_MouseDown;
|
labelSimpleObject.MouseDown += labelObject_MouseDown;
|
||||||
//
|
//
|
||||||
// groupBoxColors
|
// groupBoxColors
|
||||||
//
|
//
|
||||||
groupBoxColors.Controls.Add(panelPurple);
|
groupBoxColors.Controls.Add(panelPurple);
|
||||||
groupBoxColors.Controls.Add(panelBlack);
|
groupBoxColors.Controls.Add(panelBlack);
|
||||||
groupBoxColors.Controls.Add(panelGrey);
|
groupBoxColors.Controls.Add(panelGray);
|
||||||
groupBoxColors.Controls.Add(panelWhite);
|
groupBoxColors.Controls.Add(panelWhite);
|
||||||
groupBoxColors.Controls.Add(panelYellow);
|
groupBoxColors.Controls.Add(panelYellow);
|
||||||
groupBoxColors.Controls.Add(panelBlue);
|
groupBoxColors.Controls.Add(panelBlue);
|
||||||
@ -115,6 +116,8 @@
|
|||||||
groupBoxColors.TabIndex = 6;
|
groupBoxColors.TabIndex = 6;
|
||||||
groupBoxColors.TabStop = false;
|
groupBoxColors.TabStop = false;
|
||||||
groupBoxColors.Text = "Цвета";
|
groupBoxColors.Text = "Цвета";
|
||||||
|
groupBoxColors.DragDrop += PanelObject_DragDrop;
|
||||||
|
groupBoxColors.DragEnter += PanelObject_DragEnter;
|
||||||
//
|
//
|
||||||
// panelPurple
|
// panelPurple
|
||||||
//
|
//
|
||||||
@ -123,6 +126,9 @@
|
|||||||
panelPurple.Name = "panelPurple";
|
panelPurple.Name = "panelPurple";
|
||||||
panelPurple.Size = new Size(54, 54);
|
panelPurple.Size = new Size(54, 54);
|
||||||
panelPurple.TabIndex = 1;
|
panelPurple.TabIndex = 1;
|
||||||
|
panelPurple.DragDrop += PanelObject_DragDrop;
|
||||||
|
panelPurple.DragEnter += PanelObject_DragEnter;
|
||||||
|
panelPurple.MouseDown += panelColor_MouseDown;
|
||||||
//
|
//
|
||||||
// panelBlack
|
// panelBlack
|
||||||
//
|
//
|
||||||
@ -131,14 +137,20 @@
|
|||||||
panelBlack.Name = "panelBlack";
|
panelBlack.Name = "panelBlack";
|
||||||
panelBlack.Size = new Size(54, 54);
|
panelBlack.Size = new Size(54, 54);
|
||||||
panelBlack.TabIndex = 1;
|
panelBlack.TabIndex = 1;
|
||||||
|
panelBlack.DragDrop += PanelObject_DragDrop;
|
||||||
|
panelBlack.DragEnter += PanelObject_DragEnter;
|
||||||
|
panelBlack.MouseDown += panelColor_MouseDown;
|
||||||
//
|
//
|
||||||
// panelGrey
|
// panelGray
|
||||||
//
|
//
|
||||||
panelGrey.BackColor = Color.Gray;
|
panelGray.BackColor = Color.Gray;
|
||||||
panelGrey.Location = new Point(96, 113);
|
panelGray.Location = new Point(96, 113);
|
||||||
panelGrey.Name = "panelGrey";
|
panelGray.Name = "panelGray";
|
||||||
panelGrey.Size = new Size(54, 54);
|
panelGray.Size = new Size(54, 54);
|
||||||
panelGrey.TabIndex = 1;
|
panelGray.TabIndex = 1;
|
||||||
|
panelGray.DragDrop += PanelObject_DragDrop;
|
||||||
|
panelGray.DragEnter += PanelObject_DragEnter;
|
||||||
|
panelGray.MouseDown += panelColor_MouseDown;
|
||||||
//
|
//
|
||||||
// panelWhite
|
// panelWhite
|
||||||
//
|
//
|
||||||
@ -147,6 +159,9 @@
|
|||||||
panelWhite.Name = "panelWhite";
|
panelWhite.Name = "panelWhite";
|
||||||
panelWhite.Size = new Size(54, 54);
|
panelWhite.Size = new Size(54, 54);
|
||||||
panelWhite.TabIndex = 1;
|
panelWhite.TabIndex = 1;
|
||||||
|
panelWhite.DragDrop += PanelObject_DragDrop;
|
||||||
|
panelWhite.DragEnter += PanelObject_DragEnter;
|
||||||
|
panelWhite.MouseDown += panelColor_MouseDown;
|
||||||
//
|
//
|
||||||
// panelYellow
|
// panelYellow
|
||||||
//
|
//
|
||||||
@ -155,6 +170,9 @@
|
|||||||
panelYellow.Name = "panelYellow";
|
panelYellow.Name = "panelYellow";
|
||||||
panelYellow.Size = new Size(54, 54);
|
panelYellow.Size = new Size(54, 54);
|
||||||
panelYellow.TabIndex = 1;
|
panelYellow.TabIndex = 1;
|
||||||
|
panelYellow.DragDrop += PanelObject_DragDrop;
|
||||||
|
panelYellow.DragEnter += PanelObject_DragEnter;
|
||||||
|
panelYellow.MouseDown += panelColor_MouseDown;
|
||||||
//
|
//
|
||||||
// panelBlue
|
// panelBlue
|
||||||
//
|
//
|
||||||
@ -163,6 +181,9 @@
|
|||||||
panelBlue.Name = "panelBlue";
|
panelBlue.Name = "panelBlue";
|
||||||
panelBlue.Size = new Size(54, 54);
|
panelBlue.Size = new Size(54, 54);
|
||||||
panelBlue.TabIndex = 1;
|
panelBlue.TabIndex = 1;
|
||||||
|
panelBlue.DragDrop += PanelObject_DragDrop;
|
||||||
|
panelBlue.DragEnter += PanelObject_DragEnter;
|
||||||
|
panelBlue.MouseDown += panelColor_MouseDown;
|
||||||
//
|
//
|
||||||
// panelGreen
|
// panelGreen
|
||||||
//
|
//
|
||||||
@ -171,6 +192,9 @@
|
|||||||
panelGreen.Name = "panelGreen";
|
panelGreen.Name = "panelGreen";
|
||||||
panelGreen.Size = new Size(54, 54);
|
panelGreen.Size = new Size(54, 54);
|
||||||
panelGreen.TabIndex = 1;
|
panelGreen.TabIndex = 1;
|
||||||
|
panelGreen.DragDrop += PanelObject_DragDrop;
|
||||||
|
panelGreen.DragEnter += PanelObject_DragEnter;
|
||||||
|
panelGreen.MouseDown += panelColor_MouseDown;
|
||||||
//
|
//
|
||||||
// panelRed
|
// panelRed
|
||||||
//
|
//
|
||||||
@ -179,6 +203,9 @@
|
|||||||
panelRed.Name = "panelRed";
|
panelRed.Name = "panelRed";
|
||||||
panelRed.Size = new Size(54, 54);
|
panelRed.Size = new Size(54, 54);
|
||||||
panelRed.TabIndex = 0;
|
panelRed.TabIndex = 0;
|
||||||
|
panelRed.DragDrop += PanelObject_DragDrop;
|
||||||
|
panelRed.DragEnter += PanelObject_DragEnter;
|
||||||
|
panelRed.MouseDown += panelColor_MouseDown;
|
||||||
//
|
//
|
||||||
// checkBoxFuelTanks
|
// checkBoxFuelTanks
|
||||||
//
|
//
|
||||||
@ -256,19 +283,12 @@
|
|||||||
panelObject.Name = "panelObject";
|
panelObject.Name = "panelObject";
|
||||||
panelObject.Size = new Size(418, 253);
|
panelObject.Size = new Size(418, 253);
|
||||||
panelObject.TabIndex = 2;
|
panelObject.TabIndex = 2;
|
||||||
//
|
panelObject.DragDrop += PanelObject_DragDrop;
|
||||||
// labelColor
|
panelObject.DragEnter += PanelObject_DragEnter;
|
||||||
//
|
|
||||||
labelColor.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelColor.Location = new Point(32, 9);
|
|
||||||
labelColor.Name = "labelColor";
|
|
||||||
labelColor.Size = new Size(165, 49);
|
|
||||||
labelColor.TabIndex = 2;
|
|
||||||
labelColor.Text = "Цвет";
|
|
||||||
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
//
|
//
|
||||||
// labelAddColor
|
// labelAddColor
|
||||||
//
|
//
|
||||||
|
labelAddColor.AllowDrop = true;
|
||||||
labelAddColor.BorderStyle = BorderStyle.FixedSingle;
|
labelAddColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
labelAddColor.Location = new Point(225, 9);
|
labelAddColor.Location = new Point(225, 9);
|
||||||
labelAddColor.Name = "labelAddColor";
|
labelAddColor.Name = "labelAddColor";
|
||||||
@ -276,6 +296,21 @@
|
|||||||
labelAddColor.TabIndex = 3;
|
labelAddColor.TabIndex = 3;
|
||||||
labelAddColor.Text = "Доп. цвет";
|
labelAddColor.Text = "Доп. цвет";
|
||||||
labelAddColor.TextAlign = ContentAlignment.MiddleCenter;
|
labelAddColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelAddColor.DragDrop += labelColor_dragDrop;
|
||||||
|
labelAddColor.DragEnter += labelColor_dragEnter;
|
||||||
|
//
|
||||||
|
// labelColor
|
||||||
|
//
|
||||||
|
labelColor.AllowDrop = true;
|
||||||
|
labelColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelColor.Location = new Point(32, 9);
|
||||||
|
labelColor.Name = "labelColor";
|
||||||
|
labelColor.Size = new Size(165, 49);
|
||||||
|
labelColor.TabIndex = 2;
|
||||||
|
labelColor.Text = "Цвет";
|
||||||
|
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelColor.DragDrop += labelColor_dragDrop;
|
||||||
|
labelColor.DragEnter += labelColor_dragEnter;
|
||||||
//
|
//
|
||||||
// buttonOk
|
// buttonOk
|
||||||
//
|
//
|
||||||
@ -285,6 +320,7 @@
|
|||||||
buttonOk.TabIndex = 3;
|
buttonOk.TabIndex = 3;
|
||||||
buttonOk.Text = "Добавить";
|
buttonOk.Text = "Добавить";
|
||||||
buttonOk.UseVisualStyleBackColor = true;
|
buttonOk.UseVisualStyleBackColor = true;
|
||||||
|
buttonOk.Click += buttonOk_Click;
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
@ -319,7 +355,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private GroupBox groupBoxParameters;
|
private GroupBox groupBoxParameters;
|
||||||
private CheckBox checkBox3;
|
|
||||||
private CheckBox checkBoxFuelTanks;
|
private CheckBox checkBoxFuelTanks;
|
||||||
private CheckBox checkBoxBombs;
|
private CheckBox checkBoxBombs;
|
||||||
private NumericUpDown numericUpDownWeight;
|
private NumericUpDown numericUpDownWeight;
|
||||||
@ -331,7 +366,7 @@
|
|||||||
private GroupBox groupBoxColors;
|
private GroupBox groupBoxColors;
|
||||||
private Panel panelPurple;
|
private Panel panelPurple;
|
||||||
private Panel panelBlack;
|
private Panel panelBlack;
|
||||||
private Panel panelGrey;
|
private Panel panelGray;
|
||||||
private Panel panelWhite;
|
private Panel panelWhite;
|
||||||
private Panel panelYellow;
|
private Panel panelYellow;
|
||||||
private Panel panelBlue;
|
private Panel panelBlue;
|
||||||
|
@ -12,14 +12,144 @@ namespace AirBomber
|
|||||||
{
|
{
|
||||||
public partial class FormPlaneConfig : Form
|
public partial class FormPlaneConfig : Form
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Переменная-выбранная машина
|
||||||
|
/// </summary>
|
||||||
|
DrawningAirPlane? _plane = null;
|
||||||
|
/// <summary>
|
||||||
|
/// Делегат для передачи объекта-автомобиля
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="car"></param>
|
||||||
|
private event AirPlaneDelegate? EventAddPlane;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
public FormPlaneConfig()
|
public FormPlaneConfig()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
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;
|
||||||
|
// TODO buttonCancel.Click with lambda DONE
|
||||||
|
buttonCancel.Click += (s, e) => Close();
|
||||||
|
}
|
||||||
|
private void DrawPlane()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_plane?.SetPosition(5, 5);
|
||||||
|
_plane?.DrawPlane(gr);
|
||||||
|
pictureBoxObject.Image = bmp;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление события
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ev">Привязанный метод</param>
|
||||||
|
public void AddEvent(AirPlaneDelegate ev)
|
||||||
|
{
|
||||||
|
if (EventAddPlane == null)
|
||||||
|
{
|
||||||
|
EventAddPlane = ev;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EventAddPlane += ev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Передаем информацию при нажатии на Label
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void labelObject_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void labelSimpleObject_MouseDown(object sender, MouseEventArgs e)
|
/// <summary>
|
||||||
|
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Действия при приеме перетаскиваемой информации
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||||
|
{
|
||||||
|
case "labelSimpleObject":
|
||||||
|
_plane = new DrawningAirPlane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
case "labelModifiedObject":
|
||||||
|
_plane = new DrawningAirBomber((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxBombs.Checked, checkBoxFuelTanks.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawPlane();
|
||||||
|
}
|
||||||
|
// TODO Реализовать логику смены цветов DONE
|
||||||
|
public 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 (_plane == null)
|
||||||
|
return;
|
||||||
|
switch (((Label)sender).Name)
|
||||||
|
{
|
||||||
|
case "labelColor":
|
||||||
|
_plane?.EntityAirPlane?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
case "labelAddColor":
|
||||||
|
if (!(_plane is DrawningAirBomber))
|
||||||
|
return;
|
||||||
|
(_plane.EntityAirPlane as EntityAirBomber)?.SetAdditionalColor(color: (Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawPlane();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление самолета
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void buttonOk_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EventAddPlane?.Invoke(_plane);
|
||||||
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user