Pibd-13 Kadyshev_M.I. LabWork05 Base #5

Closed
nezui wants to merge 3 commits from LabWork05 into LabWork04
9 changed files with 745 additions and 139 deletions

View File

@ -1,16 +0,0 @@
using ProjectAirFighter.Drawning;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAirFighter;
public class AdNum<T>
where T : DrawningAirFighter
{
public void Nothing(){
}
}

View File

@ -4,21 +4,6 @@
/// </summary>
public class EntityAirFighter : EntityWarPlane
{
/// <summary>
/// Скорость
/// </summary>
public int Speed { get; private set; }
/// <summary>
/// Вес
/// </summary>
public double Weight { get; private set; }
/// <summary>
/// Основной цвет
/// </summary>
public Color BodyColor { get; private set; }
/// <summary>
/// Дополнительный цвет
/// </summary>
@ -48,6 +33,12 @@ public class EntityAirFighter : EntityWarPlane
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="rocket">Признак наличия рокет</param>
/// <param name="additionalWing">Признак наличия дополнительных крыльев</param>
public void SetAdditionalColor(Color addirionalColor)
{
AdditionalColor = addirionalColor;
}
public EntityAirFighter(int speed, double weight, Color bodyColor, Color additionalColor, bool rocket, bool additionalWing) :base(speed, weight, bodyColor)
{

View File

@ -25,6 +25,11 @@ public class EntityWarPlane
/// </summary>
public double Step => Speed * 100 / Weight;
public void SetBodyColor(Color bodyColor)
{
BodyColor = bodyColor;
}
/// <summary>
/// Конструктор сущности
/// </summary>

View File

@ -33,7 +33,6 @@
buttonRemove = new Button();
buttonAddWarPlane = new Button();
button1 = new Button();
buttonAddAirFighter = new Button();
maskedTextBoxPosition = new MaskedTextBox();
buttonGoToCheck = new Button();
buttonCreateCompany = new Button();
@ -60,11 +59,9 @@
groupBox1.Controls.Add(panelStorage);
groupBox1.Controls.Add(comboBoxSelectorCompany);
groupBox1.Dock = DockStyle.Right;
groupBox1.Location = new Point(753, 0);
groupBox1.Margin = new Padding(3, 4, 3, 4);
groupBox1.Location = new Point(659, 0);
groupBox1.Name = "groupBox1";
groupBox1.Padding = new Padding(3, 4, 3, 4);
groupBox1.Size = new Size(199, 884);
groupBox1.Size = new Size(174, 663);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "Инструменты";
@ -74,22 +71,19 @@
panelCompanyTools.Controls.Add(buttonRemove);
panelCompanyTools.Controls.Add(buttonAddWarPlane);
panelCompanyTools.Controls.Add(button1);
panelCompanyTools.Controls.Add(buttonAddAirFighter);
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(0, 497);
panelCompanyTools.Margin = new Padding(3, 4, 3, 4);
panelCompanyTools.Location = new Point(0, 373);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(199, 371);
panelCompanyTools.Size = new Size(174, 278);
panelCompanyTools.TabIndex = 9;
//
// buttonRemove
//
buttonRemove.Location = new Point(7, 193);
buttonRemove.Margin = new Padding(3, 4, 3, 4);
buttonRemove.Location = new Point(6, 145);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(185, 59);
buttonRemove.Size = new Size(162, 44);
buttonRemove.TabIndex = 4;
buttonRemove.Text = "Удалить самолет";
buttonRemove.UseVisualStyleBackColor = true;
@ -97,10 +91,9 @@
//
// buttonAddWarPlane
//
buttonAddWarPlane.Location = new Point(7, 4);
buttonAddWarPlane.Margin = new Padding(3, 4, 3, 4);
buttonAddWarPlane.Location = new Point(6, 27);
buttonAddWarPlane.Name = "buttonAddWarPlane";
buttonAddWarPlane.Size = new Size(185, 69);
buttonAddWarPlane.Size = new Size(162, 52);
buttonAddWarPlane.TabIndex = 1;
buttonAddWarPlane.Text = "Добавление военного самолета";
buttonAddWarPlane.UseVisualStyleBackColor = true;
@ -108,42 +101,28 @@
//
// button1
//
button1.Location = new Point(7, 327);
button1.Margin = new Padding(3, 4, 3, 4);
button1.Location = new Point(6, 245);
button1.Name = "button1";
button1.Size = new Size(185, 40);
button1.Size = new Size(162, 30);
button1.TabIndex = 6;
button1.Text = "Обновить";
button1.UseVisualStyleBackColor = true;
button1.Click += ButtonRefresh_Click;
//
// buttonAddAirFighter
//
buttonAddAirFighter.Location = new Point(7, 81);
buttonAddAirFighter.Margin = new Padding(3, 4, 3, 4);
buttonAddAirFighter.Name = "buttonAddAirFighter";
buttonAddAirFighter.Size = new Size(185, 59);
buttonAddAirFighter.TabIndex = 2;
buttonAddAirFighter.Text = "Добавление истребителя";
buttonAddAirFighter.UseVisualStyleBackColor = true;
buttonAddAirFighter.Click += ButtonAddAirFighter_Click;
//
// maskedTextBoxPosition
//
maskedTextBoxPosition.Location = new Point(9, 148);
maskedTextBoxPosition.Margin = new Padding(3, 4, 3, 4);
maskedTextBoxPosition.Location = new Point(8, 111);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
maskedTextBoxPosition.Size = new Size(185, 27);
maskedTextBoxPosition.Size = new Size(162, 23);
maskedTextBoxPosition.TabIndex = 3;
maskedTextBoxPosition.ValidatingType = typeof(int);
//
// buttonGoToCheck
//
buttonGoToCheck.Location = new Point(7, 260);
buttonGoToCheck.Margin = new Padding(3, 4, 3, 4);
buttonGoToCheck.Location = new Point(6, 195);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(185, 59);
buttonGoToCheck.Size = new Size(162, 44);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Передать на тест";
buttonGoToCheck.UseVisualStyleBackColor = true;
@ -151,10 +130,9 @@
//
// buttonCreateCompany
//
buttonCreateCompany.Location = new Point(7, 459);
buttonCreateCompany.Margin = new Padding(3, 4, 3, 4);
buttonCreateCompany.Location = new Point(6, 344);
buttonCreateCompany.Name = "buttonCreateCompany";
buttonCreateCompany.Size = new Size(185, 31);
buttonCreateCompany.Size = new Size(162, 23);
buttonCreateCompany.TabIndex = 8;
buttonCreateCompany.Text = "Создать компанию";
buttonCreateCompany.UseVisualStyleBackColor = true;
@ -170,18 +148,16 @@
panelStorage.Controls.Add(textBoxCollectionName);
panelStorage.Controls.Add(labelCollectionName);
panelStorage.Dock = DockStyle.Top;
panelStorage.Location = new Point(3, 24);
panelStorage.Margin = new Padding(3, 4, 3, 4);
panelStorage.Location = new Point(3, 19);
panelStorage.Name = "panelStorage";
panelStorage.Size = new Size(193, 361);
panelStorage.Size = new Size(168, 271);
panelStorage.TabIndex = 7;
//
// buttonCollectionRemove
//
buttonCollectionRemove.Location = new Point(3, 280);
buttonCollectionRemove.Margin = new Padding(3, 4, 3, 4);
buttonCollectionRemove.Location = new Point(3, 210);
buttonCollectionRemove.Name = "buttonCollectionRemove";
buttonCollectionRemove.Size = new Size(185, 31);
buttonCollectionRemove.Size = new Size(162, 23);
buttonCollectionRemove.TabIndex = 6;
buttonCollectionRemove.Text = "Удалить коллекцию";
buttonCollectionRemove.UseVisualStyleBackColor = true;
@ -190,18 +166,17 @@
// listBoxCollection
//
listBoxCollection.FormattingEnabled = true;
listBoxCollection.Location = new Point(3, 147);
listBoxCollection.Margin = new Padding(3, 4, 3, 4);
listBoxCollection.ItemHeight = 15;
listBoxCollection.Location = new Point(3, 110);
listBoxCollection.Name = "listBoxCollection";
listBoxCollection.Size = new Size(185, 124);
listBoxCollection.Size = new Size(162, 94);
listBoxCollection.TabIndex = 5;
//
// buttonCollectionAdd
//
buttonCollectionAdd.Location = new Point(3, 108);
buttonCollectionAdd.Margin = new Padding(3, 4, 3, 4);
buttonCollectionAdd.Location = new Point(3, 81);
buttonCollectionAdd.Name = "buttonCollectionAdd";
buttonCollectionAdd.Size = new Size(185, 31);
buttonCollectionAdd.Size = new Size(162, 23);
buttonCollectionAdd.TabIndex = 4;
buttonCollectionAdd.Text = "Добавить коллекцию";
buttonCollectionAdd.UseVisualStyleBackColor = true;
@ -210,10 +185,9 @@
// radioButtonList
//
radioButtonList.AutoSize = true;
radioButtonList.Location = new Point(105, 75);
radioButtonList.Margin = new Padding(3, 4, 3, 4);
radioButtonList.Location = new Point(92, 56);
radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(80, 24);
radioButtonList.Size = new Size(66, 19);
radioButtonList.TabIndex = 3;
radioButtonList.TabStop = true;
radioButtonList.Text = "Список";
@ -222,10 +196,9 @@
// radioButtonMassive
//
radioButtonMassive.AutoSize = true;
radioButtonMassive.Location = new Point(3, 75);
radioButtonMassive.Margin = new Padding(3, 4, 3, 4);
radioButtonMassive.Location = new Point(3, 56);
radioButtonMassive.Name = "radioButtonMassive";
radioButtonMassive.Size = new Size(82, 24);
radioButtonMassive.Size = new Size(67, 19);
radioButtonMassive.TabIndex = 2;
radioButtonMassive.TabStop = true;
radioButtonMassive.Text = "Массив";
@ -233,18 +206,17 @@
//
// textBoxCollectionName
//
textBoxCollectionName.Location = new Point(3, 36);
textBoxCollectionName.Margin = new Padding(3, 4, 3, 4);
textBoxCollectionName.Location = new Point(3, 27);
textBoxCollectionName.Name = "textBoxCollectionName";
textBoxCollectionName.Size = new Size(185, 27);
textBoxCollectionName.Size = new Size(162, 23);
textBoxCollectionName.TabIndex = 1;
//
// labelCollectionName
//
labelCollectionName.AutoSize = true;
labelCollectionName.Location = new Point(24, 12);
labelCollectionName.Location = new Point(21, 9);
labelCollectionName.Name = "labelCollectionName";
labelCollectionName.Size = new Size(158, 20);
labelCollectionName.Size = new Size(125, 15);
labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции:";
//
@ -254,10 +226,9 @@
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(7, 416);
comboBoxSelectorCompany.Margin = new Padding(3, 4, 3, 4);
comboBoxSelectorCompany.Location = new Point(6, 312);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(185, 28);
comboBoxSelectorCompany.Size = new Size(162, 23);
comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
//
@ -265,21 +236,18 @@
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Margin = new Padding(3, 4, 3, 4);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(753, 884);
pictureBox.Size = new Size(659, 663);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
// FormWarPlaneCollection
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(952, 884);
ClientSize = new Size(833, 663);
Controls.Add(pictureBox);
Controls.Add(groupBox1);
Margin = new Padding(3, 4, 3, 4);
Name = "FormWarPlaneCollection";
Text = "Коллекция военных самолетов";
groupBox1.ResumeLayout(false);
@ -296,7 +264,6 @@
private GroupBox groupBox1;
private ComboBox comboBoxSelectorCompany;
private MaskedTextBox maskedTextBoxPosition;
private Button buttonAddAirFighter;
private Button buttonAddWarPlane;
private PictureBox pictureBox;
private Button buttonRemove;

View File

@ -44,28 +44,22 @@ public partial class FormWarPlaneCollection : Form
panelCompanyTools.Enabled = false;
}
private void CreateObject(string type)
private void ButtonAddWarPlane_Click(object sender, EventArgs e){
FormWarPlaneConfig form = new();
form.Show();
form.AddEvent(SetWarPlane);
}
private void SetWarPlane(DrawningWarPlane warPlane)
{
if (_company == null)
if (_company == null || warPlane == null)
{
return;
}
Random random = new();
DrawningWarPlane drawningWarPlane;
switch (type)
{
case nameof(DrawningWarPlane):
drawningWarPlane = new DrawningWarPlane(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
break;
case nameof(DrawningAirFighter):
drawningWarPlane = new DrawningAirFighter(random.Next(100, 300), random.Next(1000, 3000),
GetColor(random),GetColor(random),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break;
default:
return;
}
if (_company + drawningWarPlane != -1)
if (_company + warPlane != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@ -74,29 +68,10 @@ public partial class FormWarPlaneCollection : Form
{
MessageBox.Show("Не удалось добавить объект");
}
}
private void ButtonAddWarPlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningWarPlane));
private void ButtonAddAirFighter_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAirFighter));
/// <summary>
/// Получение цвета
/// </summary>
/// <param name="random">Генератор случайных чисел</param>
/// <returns></returns>
private static Color GetColor(Random random)
{
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0,
256), random.Next(0, 256));
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
color = dialog.Color;
}
return color;
}
private void ButtonRemove_Click(object sender, EventArgs e)
{

View File

@ -0,0 +1,380 @@
namespace ProjectAirFighter
{
partial class FormWarPlaneConfig
{
/// <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()
{
groupBoxConfig = new GroupBox();
groupBoxColor = new GroupBox();
panelPurple = new Panel();
panelYellow = new Panel();
panelBlack = new Panel();
panelGrey = new Panel();
panelBlue = new Panel();
panelWhite = new Panel();
panelGreen = new Panel();
panelRed = new Panel();
checkBoxAdditionalWing = new CheckBox();
checkBoxRocket = new CheckBox();
numericUpDownWeight = new NumericUpDown();
labelWheight = new Label();
numericUpDownSpeed = new NumericUpDown();
labelSpeed = new Label();
labelModifiedObject = new Label();
labelSimpleObject = new Label();
pictureBoxObject = new PictureBox();
buttonAdd = new Button();
buttonCancel = new Button();
PanelObject = new Panel();
labelAdditionalColor = new Label();
labelBodyColor = new Label();
groupBoxConfig.SuspendLayout();
groupBoxColor.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
PanelObject.SuspendLayout();
SuspendLayout();
//
// groupBoxConfig
//
groupBoxConfig.Controls.Add(groupBoxColor);
groupBoxConfig.Controls.Add(checkBoxAdditionalWing);
groupBoxConfig.Controls.Add(checkBoxRocket);
groupBoxConfig.Controls.Add(numericUpDownWeight);
groupBoxConfig.Controls.Add(labelWheight);
groupBoxConfig.Controls.Add(numericUpDownSpeed);
groupBoxConfig.Controls.Add(labelSpeed);
groupBoxConfig.Controls.Add(labelModifiedObject);
groupBoxConfig.Controls.Add(labelSimpleObject);
groupBoxConfig.Dock = DockStyle.Left;
groupBoxConfig.Location = new Point(0, 0);
groupBoxConfig.Margin = new Padding(3, 2, 3, 2);
groupBoxConfig.Name = "groupBoxConfig";
groupBoxConfig.Padding = new Padding(3, 2, 3, 2);
groupBoxConfig.Size = new Size(498, 264);
groupBoxConfig.TabIndex = 0;
groupBoxConfig.TabStop = false;
groupBoxConfig.Text = "Параметры";
//
// groupBoxColor
//
groupBoxColor.Controls.Add(panelPurple);
groupBoxColor.Controls.Add(panelYellow);
groupBoxColor.Controls.Add(panelBlack);
groupBoxColor.Controls.Add(panelGrey);
groupBoxColor.Controls.Add(panelBlue);
groupBoxColor.Controls.Add(panelWhite);
groupBoxColor.Controls.Add(panelGreen);
groupBoxColor.Controls.Add(panelRed);
groupBoxColor.Location = new Point(192, 9);
groupBoxColor.Margin = new Padding(3, 2, 3, 2);
groupBoxColor.Name = "groupBoxColor";
groupBoxColor.Padding = new Padding(3, 2, 3, 2);
groupBoxColor.Size = new Size(293, 123);
groupBoxColor.TabIndex = 8;
groupBoxColor.TabStop = false;
groupBoxColor.Text = "Цвета";
//
// panelPurple
//
panelPurple.BackColor = Color.Purple;
panelPurple.Location = new Point(237, 74);
panelPurple.Margin = new Padding(3, 2, 3, 2);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(51, 39);
panelPurple.TabIndex = 7;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(237, 20);
panelYellow.Margin = new Padding(3, 2, 3, 2);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(51, 39);
panelYellow.TabIndex = 3;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(154, 74);
panelBlack.Margin = new Padding(3, 2, 3, 2);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(51, 39);
panelBlack.TabIndex = 6;
//
// panelGrey
//
panelGrey.BackColor = Color.Gray;
panelGrey.Location = new Point(78, 74);
panelGrey.Margin = new Padding(3, 2, 3, 2);
panelGrey.Name = "panelGrey";
panelGrey.Size = new Size(51, 39);
panelGrey.TabIndex = 5;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(154, 20);
panelBlue.Margin = new Padding(3, 2, 3, 2);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(51, 39);
panelBlue.TabIndex = 2;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(5, 74);
panelWhite.Margin = new Padding(3, 2, 3, 2);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(51, 39);
panelWhite.TabIndex = 4;
//
// panelGreen
//
panelGreen.BackColor = Color.Green;
panelGreen.Location = new Point(78, 20);
panelGreen.Margin = new Padding(3, 2, 3, 2);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(51, 39);
panelGreen.TabIndex = 1;
//
// panelRed
//
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(5, 20);
panelRed.Margin = new Padding(3, 2, 3, 2);
panelRed.Name = "panelRed";
panelRed.Size = new Size(51, 39);
panelRed.TabIndex = 0;
//
// checkBoxAdditionalWing
//
checkBoxAdditionalWing.AutoSize = true;
checkBoxAdditionalWing.Location = new Point(6, 234);
checkBoxAdditionalWing.Margin = new Padding(3, 2, 3, 2);
checkBoxAdditionalWing.Name = "checkBoxAdditionalWing";
checkBoxAdditionalWing.Size = new Size(270, 19);
checkBoxAdditionalWing.TabIndex = 7;
checkBoxAdditionalWing.Text = "Признак наличия дополнительных крыльев";
checkBoxAdditionalWing.UseVisualStyleBackColor = true;
//
// checkBoxRocket
//
checkBoxRocket.AutoSize = true;
checkBoxRocket.Location = new Point(6, 195);
checkBoxRocket.Margin = new Padding(3, 2, 3, 2);
checkBoxRocket.Name = "checkBoxRocket";
checkBoxRocket.Size = new Size(156, 19);
checkBoxRocket.TabIndex = 6;
checkBoxRocket.Text = "Признак наличия ракет";
checkBoxRocket.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(84, 47);
numericUpDownWeight.Margin = new Padding(3, 2, 3, 2);
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(74, 23);
numericUpDownWeight.TabIndex = 5;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelWheight
//
labelWheight.AutoSize = true;
labelWheight.Location = new Point(15, 53);
labelWheight.Name = "labelWheight";
labelWheight.Size = new Size(26, 15);
labelWheight.TabIndex = 4;
labelWheight.Text = "Вес";
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(84, 20);
numericUpDownSpeed.Margin = new Padding(3, 2, 3, 2);
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(74, 23);
numericUpDownSpeed.TabIndex = 3;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(15, 18);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(59, 15);
labelSpeed.TabIndex = 2;
labelSpeed.Text = "Скорость";
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(399, 233);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(93, 18);
labelModifiedObject.TabIndex = 1;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
labelModifiedObject.MouseDown += LabelObject_MouseDown;
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(304, 233);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(84, 18);
labelSimpleObject.TabIndex = 0;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(12, 38);
pictureBoxObject.Margin = new Padding(3, 2, 3, 2);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(176, 149);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
pictureBoxObject.DragDrop += PanelObject_DragDrop;
pictureBoxObject.DragEnter += PanelObject_DragEnter;
//
// buttonAdd
//
buttonAdd.Location = new Point(517, 236);
buttonAdd.Margin = new Padding(3, 2, 3, 2);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(82, 22);
buttonAdd.TabIndex = 2;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(623, 236);
buttonCancel.Margin = new Padding(3, 2, 3, 2);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(82, 22);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отменить";
buttonCancel.UseVisualStyleBackColor = true;
//
// PanelObject
//
PanelObject.AllowDrop = true;
PanelObject.Controls.Add(labelAdditionalColor);
PanelObject.Controls.Add(labelBodyColor);
PanelObject.Controls.Add(pictureBoxObject);
PanelObject.Location = new Point(517, 9);
PanelObject.Margin = new Padding(3, 2, 3, 2);
PanelObject.Name = "PanelObject";
PanelObject.Size = new Size(197, 205);
PanelObject.TabIndex = 4;
PanelObject.DragDrop += PanelObject_DragDrop;
PanelObject.DragEnter += PanelObject_DragEnter;
//
// labelAdditionalColor
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(100, 6);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(88, 18);
labelAdditionalColor.TabIndex = 3;
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
labelAdditionalColor.DragEnter += labelAdditionalColor_DragEnter;
//
// labelBodyColor
//
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(12, 6);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(77, 18);
labelBodyColor.TabIndex = 2;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
labelBodyColor.DragEnter += labelBodyColor_DragEnter;
//
// FormWarPlaneConfig
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(717, 264);
Controls.Add(PanelObject);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(groupBoxConfig);
Margin = new Padding(3, 2, 3, 2);
Name = "FormWarPlaneConfig";
Text = "Создание объекта";
groupBoxConfig.ResumeLayout(false);
groupBoxConfig.PerformLayout();
groupBoxColor.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
PanelObject.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxConfig;
private Label labelSimpleObject;
private Label labelModifiedObject;
private Label labelSpeed;
private NumericUpDown numericUpDownSpeed;
private Label labelWheight;
private NumericUpDown numericUpDownWeight;
private CheckBox checkBoxRocket;
private CheckBox checkBoxAdditionalWing;
private GroupBox groupBoxColor;
private Panel panelRed;
private Panel panelYellow;
private Panel panelBlue;
private Panel panelGreen;
private Panel panelPurple;
private Panel panelBlack;
private Panel panelGrey;
private Panel panelWhite;
private PictureBox pictureBoxObject;
private Button buttonAdd;
private Button buttonCancel;
private Panel PanelObject;
private Label labelAdditionalColor;
private Label labelBodyColor;
}
}

View File

@ -0,0 +1,178 @@
using ProjectAirFighter.Drawning;
using ProjectAirFighter.Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectAirFighter;
/// <summary>
/// Форма конфигурации объекта
/// </summary>
public partial class FormWarPlaneConfig : Form
{
/// <summary>
/// Объект - прорисовка военного самолета
/// </summary>
private DrawningWarPlane _warPlane = null;
/// <summary>
/// Событие для передачи объекта
/// </summary>
private event Action<DrawningWarPlane>? WarPlaneDelegate;
/// <summary>
/// Конструктор
/// </summary>
public FormWarPlaneConfig()
{
InitializeComponent();
panelRed.MouseDown += Panel_MouseDown;
panelGreen.MouseDown += Panel_MouseDown;
panelWhite.MouseDown += Panel_MouseDown;
panelBlack.MouseDown += Panel_MouseDown;
panelYellow.MouseDown += Panel_MouseDown;
panelBlue.MouseDown += Panel_MouseDown;
panelGrey.MouseDown += Panel_MouseDown;
panelPurple.MouseDown += Panel_MouseDown;
//TODO привязать анонимный метод через lamda с закрытием формы
buttonCancel.Click += (sender, e) => Close();
}
/// <summary>
/// Привязка внешнего метода к событию
/// </summary>
/// <param name="warPlaneDelegate"></param>
public void AddEvent(Action<DrawningWarPlane> warPlaneDelegate)
{
if (WarPlaneDelegate == null)
{
WarPlaneDelegate = warPlaneDelegate;
}
else
{
WarPlaneDelegate += warPlaneDelegate;
}
}
/// <summary>
/// Прорисовка объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DrawObject()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_warPlane?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
_warPlane?.SetPosition(5, 5);
_warPlane?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
/// <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 ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Проверка получаемой информации (ее типа на соответствие требуемому)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : 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":
_warPlane = new DrawningWarPlane((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
break;
case "labelModifiedObject":
_warPlane = new DrawningAirFighter((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxRocket.Checked, checkBoxAdditionalWing.Checked);
break;
}
DrawObject();
}
private void Panel_MouseDown(object? sender, MouseEventArgs e)
{
//TODO
(sender as Control)?.DoDragDrop((sender as Control)?.BackColor!, DragDropEffects.Move | DragDropEffects.Copy);
}
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
{
if (_warPlane == null) return;
_warPlane.EntityWarPlane?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
DrawObject();
}
private void labelBodyColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
if (_warPlane?.EntityWarPlane is EntityAirFighter _airFighter)
{
_airFighter?.SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
}
DrawObject();
}
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{
if (_warPlane?.EntityWarPlane is EntityAirFighter _airFighter)
{
if (e.Data.GetDataPresent(typeof(Color)))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
if (_warPlane != null)
{
WarPlaneDelegate?.Invoke(_warPlane);
Close();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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>

View File

@ -0,0 +1,6 @@
using ProjectAirFighter.Drawning;
namespace ProjectAirFighter;
public delegate void WarPlaneDelegate(DrawningWarPlane warPlane);
Review

Не используется

Не используется