Добавлены ангары, и возможность добавлять к ним самолеты

This commit is contained in:
Данияр Аглиуллов 2022-10-01 02:59:35 +04:00
parent 52c040d55b
commit 6a090aee45
4 changed files with 307 additions and 112 deletions

View File

@ -42,6 +42,7 @@
this.countEngineBox = new System.Windows.Forms.NumericUpDown(); this.countEngineBox = new System.Windows.Forms.NumericUpDown();
this.labelInformCountEngines = new System.Windows.Forms.Label(); this.labelInformCountEngines = new System.Windows.Forms.Label();
this.comboTypeEngines = new System.Windows.Forms.ComboBox(); this.comboTypeEngines = new System.Windows.Forms.ComboBox();
this.buttonSelectAirplane = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit();
this.statusStrip.SuspendLayout(); this.statusStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.countEngineBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.countEngineBox)).BeginInit();
@ -189,11 +190,23 @@
this.comboTypeEngines.Size = new System.Drawing.Size(143, 23); this.comboTypeEngines.Size = new System.Drawing.Size(143, 23);
this.comboTypeEngines.TabIndex = 9; this.comboTypeEngines.TabIndex = 9;
// //
// buttonSelectAirplane
//
this.buttonSelectAirplane.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonSelectAirplane.Location = new System.Drawing.Point(593, 390);
this.buttonSelectAirplane.Name = "buttonSelectAirplane";
this.buttonSelectAirplane.Size = new System.Drawing.Size(75, 23);
this.buttonSelectAirplane.TabIndex = 10;
this.buttonSelectAirplane.Text = "Выбрать";
this.buttonSelectAirplane.UseVisualStyleBackColor = true;
this.buttonSelectAirplane.Click += new System.EventHandler(this.buttonSelectAirplane_Click);
//
// FormAirBomber // FormAirBomber
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.buttonSelectAirplane);
this.Controls.Add(this.comboTypeEngines); this.Controls.Add(this.comboTypeEngines);
this.Controls.Add(this.labelInformCountEngines); this.Controls.Add(this.labelInformCountEngines);
this.Controls.Add(this.countEngineBox); this.Controls.Add(this.countEngineBox);
@ -231,5 +244,6 @@
private Label labelInformCountEngines; private Label labelInformCountEngines;
private ToolStripStatusLabel toolStripStatusCountEngines; private ToolStripStatusLabel toolStripStatusCountEngines;
private ComboBox comboTypeEngines; private ComboBox comboTypeEngines;
private Button buttonSelectAirplane;
} }
} }

View File

@ -96,5 +96,11 @@ namespace AirBomber
_airplane?.ChangeBorders(pictureBoxCar.Width, pictureBoxCar.Height); _airplane?.ChangeBorders(pictureBoxCar.Width, pictureBoxCar.Height);
Draw(); Draw();
} }
private void buttonSelectAirplane_Click(object sender, EventArgs e)
{
SelectedAirplane = _airplane;
DialogResult = DialogResult.OK;
}
} }
} }

View File

@ -30,25 +30,32 @@
{ {
this.comboTypeEngines = new System.Windows.Forms.ComboBox(); this.comboTypeEngines = new System.Windows.Forms.ComboBox();
this.groupBoxTools = new System.Windows.Forms.GroupBox(); this.groupBoxTools = new System.Windows.Forms.GroupBox();
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
this.buttonRemoveAirplane = new System.Windows.Forms.Button();
this.buttonShowStorage = new System.Windows.Forms.Button();
this.buttonShowOnMap = new System.Windows.Forms.Button();
this.buttonAddAirplane = new System.Windows.Forms.Button();
this.groupBoxGenerate = new System.Windows.Forms.GroupBox();
this.btnAddTypeOfEngines = new System.Windows.Forms.Button();
this.labelSpeed = new System.Windows.Forms.Label(); this.labelSpeed = new System.Windows.Forms.Label();
this.numericSpeed = new System.Windows.Forms.NumericUpDown(); this.numericSpeed = new System.Windows.Forms.NumericUpDown();
this.labelWeight = new System.Windows.Forms.Label();
this.numericWeight = new System.Windows.Forms.NumericUpDown();
this.btnGenerateAirplane = new System.Windows.Forms.Button();
this.labelCountEngines = new System.Windows.Forms.Label();
this.numericUpDownEngines = new System.Windows.Forms.NumericUpDown();
this.btnAddTypeOfEngines = new System.Windows.Forms.Button();
this.buttonAddTypeOfEntity = new System.Windows.Forms.Button(); this.buttonAddTypeOfEntity = new System.Windows.Forms.Button();
this.labelWeight = new System.Windows.Forms.Label();
this.numericUpDownEngines = new System.Windows.Forms.NumericUpDown();
this.numericWeight = new System.Windows.Forms.NumericUpDown();
this.labelCountEngines = new System.Windows.Forms.Label();
this.btnGenerateAirplane = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button(); this.buttonRight = new System.Windows.Forms.Button();
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
this.buttonLeft = new System.Windows.Forms.Button(); this.buttonLeft = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button(); this.buttonUp = new System.Windows.Forms.Button();
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
this.pictureBox = new System.Windows.Forms.PictureBox(); this.pictureBox = new System.Windows.Forms.PictureBox();
this.groupBoxTools.SuspendLayout(); this.groupBoxTools.SuspendLayout();
this.groupBoxGenerate.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericSpeed)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericSpeed)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownEngines)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownEngines)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -60,97 +67,103 @@
"Закругленный", "Закругленный",
"Квадратный", "Квадратный",
"Стрелка"}); "Стрелка"});
this.comboTypeEngines.Location = new System.Drawing.Point(17, 155); this.comboTypeEngines.Location = new System.Drawing.Point(19, 116);
this.comboTypeEngines.Name = "comboTypeEngines"; this.comboTypeEngines.Name = "comboTypeEngines";
this.comboTypeEngines.Size = new System.Drawing.Size(175, 23); this.comboTypeEngines.Size = new System.Drawing.Size(175, 23);
this.comboTypeEngines.TabIndex = 9; this.comboTypeEngines.TabIndex = 9;
// //
// groupBoxTools // groupBoxTools
// //
this.groupBoxTools.Controls.Add(this.comboTypeEngines); this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
this.groupBoxTools.Controls.Add(this.labelSpeed); this.groupBoxTools.Controls.Add(this.buttonRemoveAirplane);
this.groupBoxTools.Controls.Add(this.numericSpeed); this.groupBoxTools.Controls.Add(this.buttonShowStorage);
this.groupBoxTools.Controls.Add(this.labelWeight); this.groupBoxTools.Controls.Add(this.buttonShowOnMap);
this.groupBoxTools.Controls.Add(this.numericWeight); this.groupBoxTools.Controls.Add(this.buttonAddAirplane);
this.groupBoxTools.Controls.Add(this.btnGenerateAirplane); this.groupBoxTools.Controls.Add(this.groupBoxGenerate);
this.groupBoxTools.Controls.Add(this.labelCountEngines);
this.groupBoxTools.Controls.Add(this.numericUpDownEngines);
this.groupBoxTools.Controls.Add(this.btnAddTypeOfEngines);
this.groupBoxTools.Controls.Add(this.buttonAddTypeOfEntity);
this.groupBoxTools.Controls.Add(this.buttonDown); this.groupBoxTools.Controls.Add(this.buttonDown);
this.groupBoxTools.Controls.Add(this.buttonRight); this.groupBoxTools.Controls.Add(this.buttonRight);
this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap);
this.groupBoxTools.Controls.Add(this.buttonLeft); this.groupBoxTools.Controls.Add(this.buttonLeft);
this.groupBoxTools.Controls.Add(this.buttonUp); this.groupBoxTools.Controls.Add(this.buttonUp);
this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap);
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
this.groupBoxTools.Location = new System.Drawing.Point(811, 0); this.groupBoxTools.Location = new System.Drawing.Point(811, 0);
this.groupBoxTools.Name = "groupBoxTools"; this.groupBoxTools.Name = "groupBoxTools";
this.groupBoxTools.Size = new System.Drawing.Size(204, 554); this.groupBoxTools.Size = new System.Drawing.Size(204, 594);
this.groupBoxTools.TabIndex = 0; this.groupBoxTools.TabIndex = 0;
this.groupBoxTools.TabStop = false; this.groupBoxTools.TabStop = false;
this.groupBoxTools.Text = "Инструменты"; this.groupBoxTools.Text = "Инструменты";
// //
// labelSpeed // maskedTextBoxPosition
// //
this.labelSpeed.AutoSize = true; this.maskedTextBoxPosition.Location = new System.Drawing.Point(23, 317);
this.labelSpeed.Location = new System.Drawing.Point(17, 58); this.maskedTextBoxPosition.Mask = "00";
this.labelSpeed.Name = "labelSpeed"; this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
this.labelSpeed.Size = new System.Drawing.Size(117, 15); this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23);
this.labelSpeed.TabIndex = 19; this.maskedTextBoxPosition.TabIndex = 22;
this.labelSpeed.Text = "Скорость самолета:"; this.maskedTextBoxPosition.ValidatingType = typeof(int);
// //
// numericSpeed // buttonRemoveAirplane
// //
this.numericSpeed.Location = new System.Drawing.Point(136, 56); this.buttonRemoveAirplane.Location = new System.Drawing.Point(23, 346);
this.numericSpeed.Name = "numericSpeed"; this.buttonRemoveAirplane.Name = "buttonRemoveAirplane";
this.numericSpeed.Size = new System.Drawing.Size(56, 23); this.buttonRemoveAirplane.Size = new System.Drawing.Size(175, 35);
this.numericSpeed.TabIndex = 18; this.buttonRemoveAirplane.TabIndex = 23;
this.buttonRemoveAirplane.Text = "Удалить самолет";
this.buttonRemoveAirplane.UseVisualStyleBackColor = true;
this.buttonRemoveAirplane.Click += new System.EventHandler(this.ButtonRemoveAirplane_Click);
// //
// labelWeight // buttonShowStorage
// //
this.labelWeight.AutoSize = true; this.buttonShowStorage.Location = new System.Drawing.Point(23, 387);
this.labelWeight.Location = new System.Drawing.Point(17, 83); this.buttonShowStorage.Name = "buttonShowStorage";
this.labelWeight.Name = "labelWeight"; this.buttonShowStorage.Size = new System.Drawing.Size(175, 35);
this.labelWeight.Size = new System.Drawing.Size(100, 15); this.buttonShowStorage.TabIndex = 24;
this.labelWeight.TabIndex = 17; this.buttonShowStorage.Text = "Посмотреть хранилище";
this.labelWeight.Text = "Масса самолета:"; this.buttonShowStorage.UseVisualStyleBackColor = true;
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
// //
// numericWeight // buttonShowOnMap
// //
this.numericWeight.Location = new System.Drawing.Point(136, 81); this.buttonShowOnMap.Location = new System.Drawing.Point(23, 424);
this.numericWeight.Name = "numericWeight"; this.buttonShowOnMap.Name = "buttonShowOnMap";
this.numericWeight.Size = new System.Drawing.Size(56, 23); this.buttonShowOnMap.Size = new System.Drawing.Size(175, 35);
this.numericWeight.TabIndex = 16; this.buttonShowOnMap.TabIndex = 25;
this.buttonShowOnMap.Text = "Посмотреть карту";
this.buttonShowOnMap.UseVisualStyleBackColor = true;
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
// //
// btnGenerateAirplane // buttonAddAirplane
// //
this.btnGenerateAirplane.Location = new System.Drawing.Point(17, 263); this.buttonAddAirplane.Location = new System.Drawing.Point(23, 273);
this.btnGenerateAirplane.Name = "btnGenerateAirplane"; this.buttonAddAirplane.Name = "buttonAddAirplane";
this.btnGenerateAirplane.Size = new System.Drawing.Size(175, 23); this.buttonAddAirplane.Size = new System.Drawing.Size(175, 35);
this.btnGenerateAirplane.TabIndex = 15; this.buttonAddAirplane.TabIndex = 21;
this.btnGenerateAirplane.Text = "Сгенерировать самолет"; this.buttonAddAirplane.Text = "Добавить самолет вручную";
this.btnGenerateAirplane.UseVisualStyleBackColor = true; this.buttonAddAirplane.UseVisualStyleBackColor = true;
this.btnGenerateAirplane.Click += new System.EventHandler(this.btnGenerateAirplane_Click); this.buttonAddAirplane.Click += new System.EventHandler(this.ButtonAddAirplane_Click);
// //
// labelCountEngines // groupBoxGenerate
// //
this.labelCountEngines.AutoSize = true; this.groupBoxGenerate.Controls.Add(this.comboTypeEngines);
this.labelCountEngines.Location = new System.Drawing.Point(17, 187); this.groupBoxGenerate.Controls.Add(this.btnAddTypeOfEngines);
this.labelCountEngines.Name = "labelCountEngines"; this.groupBoxGenerate.Controls.Add(this.labelSpeed);
this.labelCountEngines.Size = new System.Drawing.Size(113, 15); this.groupBoxGenerate.Controls.Add(this.numericSpeed);
this.labelCountEngines.TabIndex = 14; this.groupBoxGenerate.Controls.Add(this.buttonAddTypeOfEntity);
this.labelCountEngines.Text = "Кол-во двигателей:"; this.groupBoxGenerate.Controls.Add(this.labelWeight);
// this.groupBoxGenerate.Controls.Add(this.numericUpDownEngines);
// numericUpDownEngines this.groupBoxGenerate.Controls.Add(this.numericWeight);
// this.groupBoxGenerate.Controls.Add(this.labelCountEngines);
this.numericUpDownEngines.Location = new System.Drawing.Point(136, 185); this.groupBoxGenerate.Controls.Add(this.btnGenerateAirplane);
this.numericUpDownEngines.Name = "numericUpDownEngines"; this.groupBoxGenerate.Location = new System.Drawing.Point(6, 14);
this.numericUpDownEngines.Size = new System.Drawing.Size(56, 23); this.groupBoxGenerate.Name = "groupBoxGenerate";
this.numericUpDownEngines.TabIndex = 13; this.groupBoxGenerate.Size = new System.Drawing.Size(200, 253);
this.groupBoxGenerate.TabIndex = 20;
this.groupBoxGenerate.TabStop = false;
this.groupBoxGenerate.Text = "Генерация";
// //
// btnAddTypeOfEngines // btnAddTypeOfEngines
// //
this.btnAddTypeOfEngines.Location = new System.Drawing.Point(17, 214); this.btnAddTypeOfEngines.Location = new System.Drawing.Point(17, 175);
this.btnAddTypeOfEngines.Name = "btnAddTypeOfEngines"; this.btnAddTypeOfEngines.Name = "btnAddTypeOfEngines";
this.btnAddTypeOfEngines.Size = new System.Drawing.Size(175, 43); this.btnAddTypeOfEngines.Size = new System.Drawing.Size(175, 43);
this.btnAddTypeOfEngines.TabIndex = 12; this.btnAddTypeOfEngines.TabIndex = 12;
@ -158,9 +171,25 @@
this.btnAddTypeOfEngines.UseVisualStyleBackColor = true; this.btnAddTypeOfEngines.UseVisualStyleBackColor = true;
this.btnAddTypeOfEngines.Click += new System.EventHandler(this.btnAddTypeOfEngines_Click); this.btnAddTypeOfEngines.Click += new System.EventHandler(this.btnAddTypeOfEngines_Click);
// //
// labelSpeed
//
this.labelSpeed.AutoSize = true;
this.labelSpeed.Location = new System.Drawing.Point(17, 19);
this.labelSpeed.Name = "labelSpeed";
this.labelSpeed.Size = new System.Drawing.Size(117, 15);
this.labelSpeed.TabIndex = 19;
this.labelSpeed.Text = "Скорость самолета:";
//
// numericSpeed
//
this.numericSpeed.Location = new System.Drawing.Point(136, 17);
this.numericSpeed.Name = "numericSpeed";
this.numericSpeed.Size = new System.Drawing.Size(56, 23);
this.numericSpeed.TabIndex = 18;
//
// buttonAddTypeOfEntity // buttonAddTypeOfEntity
// //
this.buttonAddTypeOfEntity.Location = new System.Drawing.Point(17, 110); this.buttonAddTypeOfEntity.Location = new System.Drawing.Point(17, 71);
this.buttonAddTypeOfEntity.Name = "buttonAddTypeOfEntity"; this.buttonAddTypeOfEntity.Name = "buttonAddTypeOfEntity";
this.buttonAddTypeOfEntity.Size = new System.Drawing.Size(175, 39); this.buttonAddTypeOfEntity.Size = new System.Drawing.Size(175, 39);
this.buttonAddTypeOfEntity.TabIndex = 11; this.buttonAddTypeOfEntity.TabIndex = 11;
@ -168,12 +197,54 @@
this.buttonAddTypeOfEntity.UseVisualStyleBackColor = true; this.buttonAddTypeOfEntity.UseVisualStyleBackColor = true;
this.buttonAddTypeOfEntity.Click += new System.EventHandler(this.buttonAddTypeOfEntity_Click); this.buttonAddTypeOfEntity.Click += new System.EventHandler(this.buttonAddTypeOfEntity_Click);
// //
// labelWeight
//
this.labelWeight.AutoSize = true;
this.labelWeight.Location = new System.Drawing.Point(17, 44);
this.labelWeight.Name = "labelWeight";
this.labelWeight.Size = new System.Drawing.Size(100, 15);
this.labelWeight.TabIndex = 17;
this.labelWeight.Text = "Масса самолета:";
//
// numericUpDownEngines
//
this.numericUpDownEngines.Location = new System.Drawing.Point(136, 146);
this.numericUpDownEngines.Name = "numericUpDownEngines";
this.numericUpDownEngines.Size = new System.Drawing.Size(56, 23);
this.numericUpDownEngines.TabIndex = 13;
//
// numericWeight
//
this.numericWeight.Location = new System.Drawing.Point(136, 42);
this.numericWeight.Name = "numericWeight";
this.numericWeight.Size = new System.Drawing.Size(56, 23);
this.numericWeight.TabIndex = 16;
//
// labelCountEngines
//
this.labelCountEngines.AutoSize = true;
this.labelCountEngines.Location = new System.Drawing.Point(17, 148);
this.labelCountEngines.Name = "labelCountEngines";
this.labelCountEngines.Size = new System.Drawing.Size(113, 15);
this.labelCountEngines.TabIndex = 14;
this.labelCountEngines.Text = "Кол-во двигателей:";
//
// btnGenerateAirplane
//
this.btnGenerateAirplane.Location = new System.Drawing.Point(17, 224);
this.btnGenerateAirplane.Name = "btnGenerateAirplane";
this.btnGenerateAirplane.Size = new System.Drawing.Size(175, 23);
this.btnGenerateAirplane.TabIndex = 15;
this.btnGenerateAirplane.Text = "Сгенерировать самолет";
this.btnGenerateAirplane.UseVisualStyleBackColor = true;
this.btnGenerateAirplane.Click += new System.EventHandler(this.btnGenerateAirplane_Click);
//
// buttonDown // buttonDown
// //
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.BackgroundImage = global::AirBomber.Properties.Resources.arrowDown; this.buttonDown.BackgroundImage = global::AirBomber.Properties.Resources.arrowDown;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(91, 504); this.buttonDown.Location = new System.Drawing.Point(91, 544);
this.buttonDown.Name = "buttonDown"; this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(30, 30); this.buttonDown.Size = new System.Drawing.Size(30, 30);
this.buttonDown.TabIndex = 10; this.buttonDown.TabIndex = 10;
@ -184,18 +255,31 @@
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRight.BackgroundImage = global::AirBomber.Properties.Resources.arrowRight; this.buttonRight.BackgroundImage = global::AirBomber.Properties.Resources.arrowRight;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(127, 504); this.buttonRight.Location = new System.Drawing.Point(127, 544);
this.buttonRight.Name = "buttonRight"; this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(30, 30); this.buttonRight.Size = new System.Drawing.Size(30, 30);
this.buttonRight.TabIndex = 9; this.buttonRight.TabIndex = 9;
this.buttonRight.UseVisualStyleBackColor = true; this.buttonRight.UseVisualStyleBackColor = true;
// //
// comboBoxSelectorMap
//
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Простая карта",
"Карта со стенами"});
this.comboBoxSelectorMap.Location = new System.Drawing.Point(23, 465);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
this.comboBoxSelectorMap.TabIndex = 0;
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
//
// buttonLeft // buttonLeft
// //
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.BackgroundImage = global::AirBomber.Properties.Resources.arrowLeft; this.buttonLeft.BackgroundImage = global::AirBomber.Properties.Resources.arrowLeft;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(55, 504); this.buttonLeft.Location = new System.Drawing.Point(55, 544);
this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(30, 30); this.buttonLeft.Size = new System.Drawing.Size(30, 30);
this.buttonLeft.TabIndex = 8; this.buttonLeft.TabIndex = 8;
@ -206,31 +290,18 @@
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.BackgroundImage = global::AirBomber.Properties.Resources.arrowUp; this.buttonUp.BackgroundImage = global::AirBomber.Properties.Resources.arrowUp;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(91, 468); this.buttonUp.Location = new System.Drawing.Point(91, 508);
this.buttonUp.Name = "buttonUp"; this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(30, 30); this.buttonUp.Size = new System.Drawing.Size(30, 30);
this.buttonUp.TabIndex = 7; this.buttonUp.TabIndex = 7;
this.buttonUp.UseVisualStyleBackColor = true; this.buttonUp.UseVisualStyleBackColor = true;
// //
// comboBoxSelectorMap
//
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Простая карта",
"Карта со стенами"});
this.comboBoxSelectorMap.Location = new System.Drawing.Point(17, 27);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
this.comboBoxSelectorMap.TabIndex = 0;
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
//
// pictureBox // pictureBox
// //
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox.Location = new System.Drawing.Point(0, 0); this.pictureBox.Location = new System.Drawing.Point(0, 0);
this.pictureBox.Name = "pictureBox"; this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(811, 554); this.pictureBox.Size = new System.Drawing.Size(811, 594);
this.pictureBox.TabIndex = 1; this.pictureBox.TabIndex = 1;
this.pictureBox.TabStop = false; this.pictureBox.TabStop = false;
// //
@ -238,16 +309,18 @@
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1015, 554); this.ClientSize = new System.Drawing.Size(1015, 594);
this.Controls.Add(this.pictureBox); this.Controls.Add(this.pictureBox);
this.Controls.Add(this.groupBoxTools); this.Controls.Add(this.groupBoxTools);
this.Name = "FormGeneratorAirplane"; this.Name = "FormGeneratorAirplane";
this.Text = "Генератор самолетов"; this.Text = "Генератор самолетов";
this.groupBoxTools.ResumeLayout(false); this.groupBoxTools.ResumeLayout(false);
this.groupBoxTools.PerformLayout(); this.groupBoxTools.PerformLayout();
this.groupBoxGenerate.ResumeLayout(false);
this.groupBoxGenerate.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericSpeed)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericSpeed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownEngines)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownEngines)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
@ -272,5 +345,11 @@
private NumericUpDown numericSpeed; private NumericUpDown numericSpeed;
private Label labelWeight; private Label labelWeight;
private NumericUpDown numericWeight; private NumericUpDown numericWeight;
private GroupBox groupBoxGenerate;
private MaskedTextBox maskedTextBoxPosition;
private Button buttonRemoveAirplane;
private Button buttonShowStorage;
private Button buttonShowOnMap;
private Button buttonAddAirplane;
} }
} }

View File

@ -1,12 +1,14 @@
namespace AirBomber using System.Windows.Forms;
namespace AirBomber
{ {
public partial class FormGeneratorAirplane : Form public partial class FormGeneratorAirplane : Form
{ {
/// <summary> /// <summary>
/// Объект от класса карты с набором объектов /// Объект от класса карты с набором объектов
/// </summary> /// </summary>
private MapWithSetAirplanesGeneric<DrawningObject, AbstractMap> _mapAirplanesCollectionGeneric;
private GeneratorAirplane<EntityAirplane, IAirplaneEngines> _generatorAirplane; private GeneratorAirplane<EntityAirplane, IAirplaneEngines> _generatorAirplane;
private IDrawningObject? _airplane;
private AbstractMap? _map; private AbstractMap? _map;
/// <summary> /// <summary>
/// Конструктор /// Конструктор
@ -17,24 +19,46 @@
InitializeComponent(); InitializeComponent();
} }
/// <summary> /// <summary>
/// Добавление самолета на карту
/// </summary>
/// <param name="airplane">самолет.</param>
private void AddAirplaneInMap(DrawningObject airplane)
{
if (airplane == null || !(_mapAirplanesCollectionGeneric + airplane))
{
MessageBox.Show("Не удалось добавить объект");
}
else
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet();
}
}
/// <summary>
/// Выбор карты /// Выбор карты
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
{ {
AbstractMap map = null;
switch (comboBoxSelectorMap.Text) switch (comboBoxSelectorMap.Text)
{ {
case "Простая карта": case "Простая карта":
_map = new SimpleMap(); map = new SimpleMap();
break; break;
case "Карта со стенами": case "Карта со стенами":
_map = new WallMap(); map = new WallMap();
break; break;
} }
if (_map != null) if (map != null)
{ {
pictureBox.Image = _map.CreateMap(pictureBox.Width, pictureBox.Height, _airplane); _mapAirplanesCollectionGeneric = new MapWithSetAirplanesGeneric<DrawningObject, AbstractMap>(
pictureBox.Width, pictureBox.Height, map);
}
else
{
_mapAirplanesCollectionGeneric = null;
} }
} }
/// <summary> /// <summary>
@ -64,7 +88,11 @@
} }
pictureBox.Image = _map?.MoveObject(dir) ?? pictureBox.Image; pictureBox.Image = _map?.MoveObject(dir) ?? pictureBox.Image;
} }
/// <summary>
/// Добавления типа двигателя и его количество в генератор
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonAddTypeOfEntity_Click(object sender, EventArgs e) private void buttonAddTypeOfEntity_Click(object sender, EventArgs e)
{ {
Random rnd = new(); Random rnd = new();
@ -82,9 +110,17 @@
$"Цвет: {colorBody.Name}", $"Цвет: {colorBody.Name}",
"Успешно добавлены свойства"); "Успешно добавлены свойства");
} }
/// <summary>
/// Генерация самолета
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnGenerateAirplane_Click(object sender, EventArgs e) private void btnGenerateAirplane_Click(object sender, EventArgs e)
{ {
if (_mapAirplanesCollectionGeneric == null)
{
return;
}
var airplane = _generatorAirplane.Generate(); var airplane = _generatorAirplane.Generate();
if (airplane == null) if (airplane == null)
{ {
@ -92,23 +128,14 @@
, "Генерация самолета"); , "Генерация самолета");
return; return;
} }
_airplane = airplane; AddAirplaneInMap(airplane);
// Если есть карта отрисовываем объект на карте иначе на пустом фоне
if (_map != null)
{
pictureBox.Image = _map.CreateMap(pictureBox.Width, pictureBox.Height, _airplane);
}
else if (_airplane != null)
{
var rnd = new Random();
pictureBox.Image = new Bitmap(pictureBox.Width, pictureBox.Height);
var g = Graphics.FromImage(pictureBox.Image);
_airplane.SetObject(rnd.Next() % 256, rnd.Next() % 256, pictureBox.Image.Width, pictureBox.Image.Height);
_airplane.DrawningObject(g);
}
} }
/// <summary>
/// Добавления сущности в генератор
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnAddTypeOfEngines_Click(object sender, EventArgs e) private void btnAddTypeOfEngines_Click(object sender, EventArgs e)
{ {
IAirplaneEngines? typeAirplaneEngines = null; IAirplaneEngines? typeAirplaneEngines = null;
@ -127,5 +154,74 @@
typeAirplaneEngines.CountEngines = (int)numericUpDownEngines.Value; typeAirplaneEngines.CountEngines = (int)numericUpDownEngines.Value;
_generatorAirplane.AddTypeOfEngines(typeAirplaneEngines); _generatorAirplane.AddTypeOfEngines(typeAirplaneEngines);
} }
/// <summary>
/// Добавление объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddAirplane_Click(object sender, EventArgs e)
{
if (_mapAirplanesCollectionGeneric == null)
{
return;
}
FormAirBomber form = new();
if (form.ShowDialog() == DialogResult.OK && form.SelectedAirplane != null)
{
AddAirplaneInMap(new(form.SelectedAirplane));
}
}
/// <summary>
/// Удаление объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonRemoveAirplane_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
{
return;
}
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if (_mapAirplanesCollectionGeneric - pos)
{
MessageBox.Show("Объект удален");
pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
/// <summary>
/// Вывод набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonShowStorage_Click(object sender, EventArgs e)
{
if (_mapAirplanesCollectionGeneric == null)
{
return;
}
pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet();
}
/// <summary>
/// Вывод карты
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonShowOnMap_Click(object sender, EventArgs e)
{
if (_mapAirplanesCollectionGeneric == null)
{
return;
}
pictureBox.Image = _mapAirplanesCollectionGeneric.ShowOnMap();
}
} }
} }