ISEbd-22 Alimova M.S. Lab Work 05 #5
@ -39,18 +39,24 @@ namespace AirBomber
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor);
|
||||
base.DrawPlane(g);
|
||||
// обвесы
|
||||
g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 20, 15, 29);
|
||||
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 20, 15, 29);
|
||||
g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 70, 15, 29);
|
||||
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);
|
||||
// bombs
|
||||
if(airBomber.Bombs)
|
||||
{
|
||||
g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 20, 15, 29);
|
||||
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 20, 15, 29);
|
||||
g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 70, 15, 29);
|
||||
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
|
||||
g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 34, 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);
|
||||
if (airBomber.FuelTanks)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 34, 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>
|
||||
private int _pictureWidth;
|
||||
public int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
private int _pictureHeight;
|
||||
public int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки самолета
|
||||
/// </summary>
|
||||
@ -272,7 +272,6 @@ namespace AirBomber
|
||||
/// <summary>
|
||||
/// Получение объекта IMoveableObject из объекта DrawningAirPlane
|
||||
/// </summary>
|
||||
public IMoveableObject GetMoveableObject => new
|
||||
DrawningObjectAirPlane(this);
|
||||
public IMoveableObject GetMoveableObject => new DrawningObjectAirPlane(this);
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,15 @@ namespace AirBomber
|
||||
public bool Bombs { get; private set; }
|
||||
public Color BombsColor { get; private set; }
|
||||
public bool FuelTanks { get; private set; }
|
||||
public EntityAirBomber(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool bombs, bool fuelTanks) : base(speed, weight, bodyColor)
|
||||
public EntityAirBomber(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks) : base(speed, weight, bodyColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
Bombs = bombs;
|
||||
FuelTanks = fuelTanks;
|
||||
}
|
||||
public void SetAdditionalColor(Color color)
|
||||
{
|
||||
AdditionalColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,5 +37,9 @@ namespace AirBomber
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
public void SetBodyColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,27 +58,31 @@ namespace AirBomber
|
||||
/// <param name="e"></param>
|
||||
private void buttonAddPlane_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString()?? string.Empty];
|
||||
var formPlaneConfig = new FormPlaneConfig();
|
||||
// TODO DONE
|
||||
formPlaneConfig.AddEvent(AddPlane);
|
||||
formPlaneConfig.Show();
|
||||
}
|
||||
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;
|
||||
}
|
||||
FormAirBomber form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (obj + plane > -1)
|
||||
{
|
||||
if (obj + form.SelectedPlane > -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowPlanes();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowPlanes();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@ -158,5 +162,6 @@ namespace AirBomber
|
||||
ReloadObjects();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
366
AirBomber/AirBomber/FormPlaneConfig.Designer.cs
generated
Normal file
366
AirBomber/AirBomber/FormPlaneConfig.Designer.cs
generated
Normal file
@ -0,0 +1,366 @@
|
||||
namespace AirBomber
|
||||
{
|
||||
partial class FormPlaneConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
groupBoxParameters = new GroupBox();
|
||||
labelModifiedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
groupBoxColors = 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();
|
||||
checkBoxFuelTanks = new CheckBox();
|
||||
checkBoxBombs = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
labelWeight = new Label();
|
||||
labelSpeed = new Label();
|
||||
pictureBoxObject = new PictureBox();
|
||||
panelObject = new Panel();
|
||||
labelAddColor = new Label();
|
||||
labelColor = new Label();
|
||||
buttonOk = new Button();
|
||||
buttonCancel = new Button();
|
||||
groupBoxParameters.SuspendLayout();
|
||||
groupBoxColors.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
panelObject.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxParameters
|
||||
//
|
||||
groupBoxParameters.Controls.Add(labelModifiedObject);
|
||||
groupBoxParameters.Controls.Add(labelSimpleObject);
|
||||
groupBoxParameters.Controls.Add(groupBoxColors);
|
||||
groupBoxParameters.Controls.Add(checkBoxFuelTanks);
|
||||
groupBoxParameters.Controls.Add(checkBoxBombs);
|
||||
groupBoxParameters.Controls.Add(numericUpDownWeight);
|
||||
groupBoxParameters.Controls.Add(numericUpDownSpeed);
|
||||
groupBoxParameters.Controls.Add(labelWeight);
|
||||
groupBoxParameters.Controls.Add(labelSpeed);
|
||||
groupBoxParameters.Location = new Point(12, 12);
|
||||
groupBoxParameters.Name = "groupBoxParameters";
|
||||
groupBoxParameters.Size = new Size(733, 340);
|
||||
groupBoxParameters.TabIndex = 0;
|
||||
groupBoxParameters.TabStop = false;
|
||||
groupBoxParameters.Text = "Параметры";
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelModifiedObject.Location = new Point(563, 259);
|
||||
labelModifiedObject.Name = "labelModifiedObject";
|
||||
labelModifiedObject.Size = new Size(150, 48);
|
||||
labelModifiedObject.TabIndex = 8;
|
||||
labelModifiedObject.Text = "Продвинутый";
|
||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelModifiedObject.MouseDown += labelObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Location = new Point(389, 259);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new Size(150, 48);
|
||||
labelSimpleObject.TabIndex = 7;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSimpleObject.MouseDown += labelObject_MouseDown;
|
||||
//
|
||||
// groupBoxColors
|
||||
//
|
||||
groupBoxColors.Controls.Add(panelPurple);
|
||||
groupBoxColors.Controls.Add(panelBlack);
|
||||
groupBoxColors.Controls.Add(panelGray);
|
||||
groupBoxColors.Controls.Add(panelWhite);
|
||||
groupBoxColors.Controls.Add(panelYellow);
|
||||
groupBoxColors.Controls.Add(panelBlue);
|
||||
groupBoxColors.Controls.Add(panelGreen);
|
||||
groupBoxColors.Controls.Add(panelRed);
|
||||
groupBoxColors.Location = new Point(389, 20);
|
||||
groupBoxColors.Name = "groupBoxColors";
|
||||
groupBoxColors.Size = new Size(324, 194);
|
||||
groupBoxColors.TabIndex = 6;
|
||||
groupBoxColors.TabStop = false;
|
||||
groupBoxColors.Text = "Цвета";
|
||||
groupBoxColors.DragDrop += PanelObject_DragDrop;
|
||||
groupBoxColors.DragEnter += PanelObject_DragEnter;
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
panelPurple.BackColor = Color.Purple;
|
||||
panelPurple.Location = new Point(243, 113);
|
||||
panelPurple.Name = "panelPurple";
|
||||
panelPurple.Size = new Size(54, 54);
|
||||
panelPurple.TabIndex = 1;
|
||||
panelPurple.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
panelBlack.BackColor = Color.Black;
|
||||
panelBlack.Location = new Point(169, 113);
|
||||
panelBlack.Name = "panelBlack";
|
||||
panelBlack.Size = new Size(54, 54);
|
||||
panelBlack.TabIndex = 1;
|
||||
panelBlack.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
panelGray.BackColor = Color.Gray;
|
||||
panelGray.Location = new Point(96, 113);
|
||||
panelGray.Name = "panelGray";
|
||||
panelGray.Size = new Size(54, 54);
|
||||
panelGray.TabIndex = 1;
|
||||
panelGray.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
panelWhite.BackColor = Color.White;
|
||||
panelWhite.Location = new Point(22, 113);
|
||||
panelWhite.Name = "panelWhite";
|
||||
panelWhite.Size = new Size(54, 54);
|
||||
panelWhite.TabIndex = 1;
|
||||
panelWhite.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
panelYellow.BackColor = Color.Yellow;
|
||||
panelYellow.Location = new Point(243, 43);
|
||||
panelYellow.Name = "panelYellow";
|
||||
panelYellow.Size = new Size(54, 54);
|
||||
panelYellow.TabIndex = 1;
|
||||
panelYellow.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
panelBlue.BackColor = Color.Blue;
|
||||
panelBlue.Location = new Point(169, 43);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new Size(54, 54);
|
||||
panelBlue.TabIndex = 1;
|
||||
panelBlue.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
panelGreen.BackColor = Color.FromArgb(0, 192, 0);
|
||||
panelGreen.Location = new Point(96, 43);
|
||||
panelGreen.Name = "panelGreen";
|
||||
panelGreen.Size = new Size(54, 54);
|
||||
panelGreen.TabIndex = 1;
|
||||
panelGreen.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.BackColor = Color.Red;
|
||||
panelRed.Location = new Point(22, 43);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(54, 54);
|
||||
panelRed.TabIndex = 0;
|
||||
panelRed.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// checkBoxFuelTanks
|
||||
//
|
||||
checkBoxFuelTanks.AutoSize = true;
|
||||
checkBoxFuelTanks.Location = new Point(30, 225);
|
||||
checkBoxFuelTanks.Name = "checkBoxFuelTanks";
|
||||
checkBoxFuelTanks.Size = new Size(327, 29);
|
||||
checkBoxFuelTanks.TabIndex = 5;
|
||||
checkBoxFuelTanks.Text = "Признак наличия топливных баков";
|
||||
checkBoxFuelTanks.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxBombs
|
||||
//
|
||||
checkBoxBombs.AutoSize = true;
|
||||
checkBoxBombs.Location = new Point(30, 158);
|
||||
checkBoxBombs.Name = "checkBoxBombs";
|
||||
checkBoxBombs.Size = new Size(229, 29);
|
||||
checkBoxBombs.TabIndex = 4;
|
||||
checkBoxBombs.Text = "Признак наличия бомб";
|
||||
checkBoxBombs.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(146, 94);
|
||||
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(180, 31);
|
||||
numericUpDownWeight.TabIndex = 3;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(146, 52);
|
||||
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(180, 31);
|
||||
numericUpDownSpeed.TabIndex = 2;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
labelWeight.AutoSize = true;
|
||||
labelWeight.Location = new Point(30, 100);
|
||||
labelWeight.Name = "labelWeight";
|
||||
labelWeight.Size = new Size(39, 25);
|
||||
labelWeight.TabIndex = 1;
|
||||
labelWeight.Text = "Вес";
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
labelSpeed.AutoSize = true;
|
||||
labelSpeed.Location = new Point(30, 54);
|
||||
labelSpeed.Name = "labelSpeed";
|
||||
labelSpeed.Size = new Size(89, 25);
|
||||
labelSpeed.TabIndex = 0;
|
||||
labelSpeed.Text = "Скорость";
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(32, 61);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(358, 175);
|
||||
pictureBoxObject.TabIndex = 1;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
panelObject.AllowDrop = true;
|
||||
panelObject.Controls.Add(labelAddColor);
|
||||
panelObject.Controls.Add(labelColor);
|
||||
panelObject.Controls.Add(pictureBoxObject);
|
||||
panelObject.Location = new Point(776, 23);
|
||||
panelObject.Name = "panelObject";
|
||||
panelObject.Size = new Size(418, 253);
|
||||
panelObject.TabIndex = 2;
|
||||
panelObject.DragDrop += PanelObject_DragDrop;
|
||||
panelObject.DragEnter += PanelObject_DragEnter;
|
||||
//
|
||||
// labelAddColor
|
||||
//
|
||||
labelAddColor.AllowDrop = true;
|
||||
labelAddColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAddColor.Location = new Point(225, 9);
|
||||
labelAddColor.Name = "labelAddColor";
|
||||
labelAddColor.Size = new Size(165, 49);
|
||||
labelAddColor.TabIndex = 3;
|
||||
labelAddColor.Text = "Доп. цвет";
|
||||
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.Location = new Point(783, 291);
|
||||
buttonOk.Name = "buttonOk";
|
||||
buttonOk.Size = new Size(190, 51);
|
||||
buttonOk.TabIndex = 3;
|
||||
buttonOk.Text = "Добавить";
|
||||
buttonOk.UseVisualStyleBackColor = true;
|
||||
buttonOk.Click += buttonOk_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(992, 291);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(190, 51);
|
||||
buttonCancel.TabIndex = 4;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormPlaneConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1222, 364);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonOk);
|
||||
Controls.Add(panelObject);
|
||||
Controls.Add(groupBoxParameters);
|
||||
Name = "FormPlaneConfig";
|
||||
Text = "Создание объекта";
|
||||
groupBoxParameters.ResumeLayout(false);
|
||||
groupBoxParameters.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 groupBoxParameters;
|
||||
private CheckBox checkBoxFuelTanks;
|
||||
private CheckBox checkBoxBombs;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private Label labelModifiedObject;
|
||||
private Label labelSimpleObject;
|
||||
private GroupBox groupBoxColors;
|
||||
private Panel panelPurple;
|
||||
private Panel panelBlack;
|
||||
private Panel panelGray;
|
||||
private Panel panelWhite;
|
||||
private Panel panelYellow;
|
||||
private Panel panelBlue;
|
||||
private Panel panelGreen;
|
||||
private Panel panelRed;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Panel panelObject;
|
||||
private Label labelAddColor;
|
||||
private Label labelColor;
|
||||
private Button buttonOk;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
155
AirBomber/AirBomber/FormPlaneConfig.cs
Normal file
155
AirBomber/AirBomber/FormPlaneConfig.cs
Normal file
@ -0,0 +1,155 @@
|
||||
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 AirBomber
|
||||
{
|
||||
public partial class FormPlaneConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Переменная-выбранная машина
|
||||
/// </summary>
|
||||
DrawningAirPlane? _plane = null;
|
||||
/// <summary>
|
||||
/// Делегат для передачи объекта-автомобиля
|
||||
/// </summary>
|
||||
/// <param name="plane"></param>
|
||||
private event Action<DrawningAirPlane>? EventAddPlane;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
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;
|
||||
// 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(Action<DrawningAirPlane> 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);
|
||||
}
|
||||
|
||||
/// <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();
|
||||
}
|
||||
}
|
||||
}
|
60
AirBomber/AirBomber/FormPlaneConfig.resx
Normal file
60
AirBomber/AirBomber/FormPlaneConfig.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user