diff --git a/AirBomber/AirBomber/FormAirplaneConfig.Designer.cs b/AirBomber/AirBomber/FormAirplaneConfig.Designer.cs index 6308062..4297b43 100644 --- a/AirBomber/AirBomber/FormAirplaneConfig.Designer.cs +++ b/AirBomber/AirBomber/FormAirplaneConfig.Designer.cs @@ -29,6 +29,12 @@ private void InitializeComponent() { this.groupBoxConfig = new System.Windows.Forms.GroupBox(); + this.TypesOfEngines = new System.Windows.Forms.GroupBox(); + this.labelRoundedEngines = new System.Windows.Forms.Label(); + this.labelRectEngines = new System.Windows.Forms.Label(); + this.labelArrowEngines = new System.Windows.Forms.Label(); + this.numericUpDownCountEngines = new System.Windows.Forms.NumericUpDown(); + this.labelCountEngines = new System.Windows.Forms.Label(); this.labelModifiedObject = new System.Windows.Forms.Label(); this.labelSimpleObject = new System.Windows.Forms.Label(); this.groupBoxColors = new System.Windows.Forms.GroupBox(); @@ -47,12 +53,15 @@ this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); this.labelSpeed = new System.Windows.Forms.Label(); this.panelObject = new System.Windows.Forms.Panel(); + this.labelTypesOfEngines = new System.Windows.Forms.Label(); this.labelDopColor = new System.Windows.Forms.Label(); this.labelBaseColor = new System.Windows.Forms.Label(); this.pictureBoxObject = new System.Windows.Forms.PictureBox(); this.buttonCancel = new System.Windows.Forms.Button(); this.buttonOk = new System.Windows.Forms.Button(); this.groupBoxConfig.SuspendLayout(); + this.TypesOfEngines.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCountEngines)).BeginInit(); this.groupBoxColors.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); @@ -62,6 +71,9 @@ // // groupBoxConfig // + this.groupBoxConfig.Controls.Add(this.TypesOfEngines); + this.groupBoxConfig.Controls.Add(this.numericUpDownCountEngines); + this.groupBoxConfig.Controls.Add(this.labelCountEngines); this.groupBoxConfig.Controls.Add(this.labelModifiedObject); this.groupBoxConfig.Controls.Add(this.labelSimpleObject); this.groupBoxConfig.Controls.Add(this.groupBoxColors); @@ -73,17 +85,88 @@ this.groupBoxConfig.Controls.Add(this.labelSpeed); this.groupBoxConfig.Location = new System.Drawing.Point(12, 12); this.groupBoxConfig.Name = "groupBoxConfig"; - this.groupBoxConfig.Size = new System.Drawing.Size(520, 220); + this.groupBoxConfig.Size = new System.Drawing.Size(700, 253); this.groupBoxConfig.TabIndex = 0; this.groupBoxConfig.TabStop = false; this.groupBoxConfig.Text = "Параметры"; // + // TypesOfEngines + // + this.TypesOfEngines.Controls.Add(this.labelRoundedEngines); + this.TypesOfEngines.Controls.Add(this.labelRectEngines); + this.TypesOfEngines.Controls.Add(this.labelArrowEngines); + this.TypesOfEngines.Location = new System.Drawing.Point(514, 22); + this.TypesOfEngines.Name = "TypesOfEngines"; + this.TypesOfEngines.Size = new System.Drawing.Size(180, 225); + this.TypesOfEngines.TabIndex = 19; + this.TypesOfEngines.TabStop = false; + this.TypesOfEngines.Text = "Типы двигателей"; + // + // labelRoundedEngines + // + this.labelRoundedEngines.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelRoundedEngines.Location = new System.Drawing.Point(6, 23); + this.labelRoundedEngines.Name = "labelRoundedEngines"; + this.labelRoundedEngines.Size = new System.Drawing.Size(168, 52); + this.labelRoundedEngines.TabIndex = 24; + this.labelRoundedEngines.Text = "Закругленный"; + this.labelRoundedEngines.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelRoundedEngines.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelTypesOfEngines_MouseDown); + // + // labelRectEngines + // + this.labelRectEngines.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelRectEngines.Location = new System.Drawing.Point(6, 96); + this.labelRectEngines.Name = "labelRectEngines"; + this.labelRectEngines.Size = new System.Drawing.Size(168, 52); + this.labelRectEngines.TabIndex = 23; + this.labelRectEngines.Text = "Квадратный"; + this.labelRectEngines.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelRectEngines.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelTypesOfEngines_MouseDown); + // + // labelArrowEngines + // + this.labelArrowEngines.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelArrowEngines.Location = new System.Drawing.Point(6, 165); + this.labelArrowEngines.Name = "labelArrowEngines"; + this.labelArrowEngines.Size = new System.Drawing.Size(168, 52); + this.labelArrowEngines.TabIndex = 22; + this.labelArrowEngines.Text = "Стрелка"; + this.labelArrowEngines.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelArrowEngines.MouseDown += new System.Windows.Forms.MouseEventHandler(this.labelTypesOfEngines_MouseDown); + // + // numericUpDownCountEngines + // + this.numericUpDownCountEngines.Location = new System.Drawing.Point(151, 118); + this.numericUpDownCountEngines.Maximum = new decimal(new int[] { + 9, + 0, + 0, + 0}); + this.numericUpDownCountEngines.Name = "numericUpDownCountEngines"; + this.numericUpDownCountEngines.Size = new System.Drawing.Size(79, 23); + this.numericUpDownCountEngines.TabIndex = 18; + this.numericUpDownCountEngines.Value = new decimal(new int[] { + 9, + 0, + 0, + 0}); + // + // labelCountEngines + // + this.labelCountEngines.AutoSize = true; + this.labelCountEngines.Location = new System.Drawing.Point(6, 120); + this.labelCountEngines.Name = "labelCountEngines"; + this.labelCountEngines.Size = new System.Drawing.Size(139, 15); + this.labelCountEngines.TabIndex = 17; + this.labelCountEngines.Text = "Количество двигателей:"; + // // labelModifiedObject // this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelModifiedObject.Location = new System.Drawing.Point(394, 162); + this.labelModifiedObject.Location = new System.Drawing.Point(279, 201); this.labelModifiedObject.Name = "labelModifiedObject"; - this.labelModifiedObject.Size = new System.Drawing.Size(97, 38); + this.labelModifiedObject.Size = new System.Drawing.Size(212, 38); this.labelModifiedObject.TabIndex = 16; this.labelModifiedObject.Text = "Продвинутый"; this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -92,9 +175,9 @@ // labelSimpleObject // this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelSimpleObject.Location = new System.Drawing.Point(282, 162); + this.labelSimpleObject.Location = new System.Drawing.Point(279, 151); this.labelSimpleObject.Name = "labelSimpleObject"; - this.labelSimpleObject.Size = new System.Drawing.Size(97, 38); + this.labelSimpleObject.Size = new System.Drawing.Size(212, 38); this.labelSimpleObject.TabIndex = 15; this.labelSimpleObject.Text = "Простой"; this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -184,7 +267,7 @@ // checkBoxHasFuelTanks // this.checkBoxHasFuelTanks.AutoSize = true; - this.checkBoxHasFuelTanks.Location = new System.Drawing.Point(22, 165); + this.checkBoxHasFuelTanks.Location = new System.Drawing.Point(22, 201); this.checkBoxHasFuelTanks.Name = "checkBoxHasFuelTanks"; this.checkBoxHasFuelTanks.RightToLeft = System.Windows.Forms.RightToLeft.No; this.checkBoxHasFuelTanks.Size = new System.Drawing.Size(222, 19); @@ -195,7 +278,7 @@ // checkBoxHasBombs // this.checkBoxHasBombs.AutoSize = true; - this.checkBoxHasBombs.Location = new System.Drawing.Point(22, 130); + this.checkBoxHasBombs.Location = new System.Drawing.Point(22, 162); this.checkBoxHasBombs.Name = "checkBoxHasBombs"; this.checkBoxHasBombs.Size = new System.Drawing.Size(156, 19); this.checkBoxHasBombs.TabIndex = 11; @@ -204,7 +287,7 @@ // // numericUpDownWeight // - this.numericUpDownWeight.Location = new System.Drawing.Point(90, 72); + this.numericUpDownWeight.Location = new System.Drawing.Point(151, 74); this.numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, @@ -227,7 +310,7 @@ // labelWeight // this.labelWeight.AutoSize = true; - this.labelWeight.Location = new System.Drawing.Point(22, 74); + this.labelWeight.Location = new System.Drawing.Point(6, 76); this.labelWeight.Name = "labelWeight"; this.labelWeight.Size = new System.Drawing.Size(29, 15); this.labelWeight.TabIndex = 9; @@ -235,7 +318,7 @@ // // numericUpDownSpeed // - this.numericUpDownSpeed.Location = new System.Drawing.Point(90, 30); + this.numericUpDownSpeed.Location = new System.Drawing.Point(151, 32); this.numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, @@ -258,7 +341,7 @@ // labelSpeed // this.labelSpeed.AutoSize = true; - this.labelSpeed.Location = new System.Drawing.Point(22, 32); + this.labelSpeed.Location = new System.Drawing.Point(6, 34); this.labelSpeed.Name = "labelSpeed"; this.labelSpeed.Size = new System.Drawing.Size(62, 15); this.labelSpeed.TabIndex = 7; @@ -267,16 +350,28 @@ // panelObject // this.panelObject.AllowDrop = true; + this.panelObject.Controls.Add(this.labelTypesOfEngines); this.panelObject.Controls.Add(this.labelDopColor); this.panelObject.Controls.Add(this.labelBaseColor); this.panelObject.Controls.Add(this.pictureBoxObject); - this.panelObject.Location = new System.Drawing.Point(538, 12); + this.panelObject.Location = new System.Drawing.Point(718, 12); this.panelObject.Name = "panelObject"; - this.panelObject.Size = new System.Drawing.Size(262, 184); + this.panelObject.Size = new System.Drawing.Size(262, 220); this.panelObject.TabIndex = 2; this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop); this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter); // + // labelTypesOfEngines + // + this.labelTypesOfEngines.AllowDrop = true; + this.labelTypesOfEngines.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelTypesOfEngines.Location = new System.Drawing.Point(20, 52); + this.labelTypesOfEngines.Name = "labelTypesOfEngines"; + this.labelTypesOfEngines.Size = new System.Drawing.Size(225, 32); + this.labelTypesOfEngines.TabIndex = 3; + this.labelTypesOfEngines.Text = "Тип двигателей"; + this.labelTypesOfEngines.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // // labelDopColor // this.labelDopColor.AllowDrop = true; @@ -305,7 +400,7 @@ // // pictureBoxObject // - this.pictureBoxObject.Location = new System.Drawing.Point(20, 44); + this.pictureBoxObject.Location = new System.Drawing.Point(20, 89); this.pictureBoxObject.Name = "pictureBoxObject"; this.pictureBoxObject.Size = new System.Drawing.Size(225, 125); this.pictureBoxObject.TabIndex = 0; @@ -313,7 +408,7 @@ // // buttonCancel // - this.buttonCancel.Location = new System.Drawing.Point(679, 202); + this.buttonCancel.Location = new System.Drawing.Point(859, 235); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(104, 30); this.buttonCancel.TabIndex = 5; @@ -322,7 +417,7 @@ // // buttonOk // - this.buttonOk.Location = new System.Drawing.Point(558, 202); + this.buttonOk.Location = new System.Drawing.Point(738, 235); this.buttonOk.Name = "buttonOk"; this.buttonOk.Size = new System.Drawing.Size(104, 30); this.buttonOk.TabIndex = 4; @@ -334,7 +429,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(810, 242); + this.ClientSize = new System.Drawing.Size(987, 277); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonOk); this.Controls.Add(this.panelObject); @@ -343,6 +438,8 @@ this.Text = "Создание объекта"; this.groupBoxConfig.ResumeLayout(false); this.groupBoxConfig.PerformLayout(); + this.TypesOfEngines.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCountEngines)).EndInit(); this.groupBoxColors.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); @@ -378,5 +475,12 @@ private PictureBox pictureBoxObject; private Button buttonCancel; private Button buttonOk; + private NumericUpDown numericUpDownCountEngines; + private Label labelCountEngines; + private GroupBox TypesOfEngines; + private Label labelTypesOfEngines; + private Label labelRoundedEngines; + private Label labelRectEngines; + private Label labelArrowEngines; } } \ No newline at end of file diff --git a/AirBomber/AirBomber/FormAirplaneConfig.cs b/AirBomber/AirBomber/FormAirplaneConfig.cs index 4a088ad..8df327d 100644 --- a/AirBomber/AirBomber/FormAirplaneConfig.cs +++ b/AirBomber/AirBomber/FormAirplaneConfig.cs @@ -1,4 +1,6 @@ -namespace AirBomber +using System.Xml.Linq; + +namespace AirBomber { /// /// Форма создания объекта @@ -91,13 +93,15 @@ switch (e.Data.GetData(DataFormats.Text).ToString()) { case "labelSimpleObject": - _airplane = new DrawningAirplane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White); + _airplane = new DrawningAirplane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, + new DrawningAirplaneEngines()); break; case "labelModifiedObject": _airplane = new DrawningAirBomber((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, - checkBoxHasBombs.Checked, checkBoxHasFuelTanks.Checked); + checkBoxHasBombs.Checked, checkBoxHasFuelTanks.Checked, new DrawningAirplaneEngines()); break; } + _airplane.DrawningEngines.CountEngines = (int)numericUpDownCountEngines.Value; DrawAirplane(); } /// @@ -144,11 +148,11 @@ if (_airplane is DrawningAirBomber) { var a = (EntityAirBomber)_airplane.Airplane; - _airplane = new DrawningAirBomber(a.Speed, a.Weight, color, a.DopColor, a.HasBombs, a.HasFuelTanks); + _airplane = new DrawningAirBomber(a.Speed, a.Weight, color, a.DopColor, a.HasBombs, a.HasFuelTanks, _airplane.DrawningEngines); } else if (_airplane is DrawningAirplane) { - _airplane = new DrawningAirplane(_airplane.Airplane.Speed, _airplane.Airplane.Weight, color); + _airplane = new DrawningAirplane(_airplane.Airplane.Speed, _airplane.Airplane.Weight, color, _airplane.DrawningEngines); } DrawAirplane(); } @@ -163,7 +167,7 @@ if (_airplane is DrawningAirBomber) { var a = (EntityAirBomber)_airplane.Airplane; - _airplane = new DrawningAirBomber(a.Speed, a.Weight, a.BodyColor, color, a.HasBombs, a.HasFuelTanks); + _airplane = new DrawningAirBomber(a.Speed, a.Weight, a.BodyColor, color, a.HasBombs, a.HasFuelTanks, _airplane.DrawningEngines); } DrawAirplane(); } @@ -177,5 +181,26 @@ EventAddAirplane?.Invoke(_airplane); Close(); } + + private void labelTypesOfEngines_MouseDown(object sender, MouseEventArgs e) + { + string text = ((Label)sender)?.Text ?? string.Empty; + IAirplaneEngines typesOfEngines; + switch (text) + { + case "Закругленный": + typesOfEngines = new DrawningAirplaneEngines(); + break; + case "Квадратный": + typesOfEngines = new AirplaneRectEngines(); + break; + case "Стрелка": + typesOfEngines = new AirplaneArrowEngines(); + break; + default: + return; + } + (sender as Label).DoDragDrop(typesOfEngines, DragDropEffects.Move | DragDropEffects.Copy); + } } } \ No newline at end of file