From 45dcef4cf96883755536f299db8501a0a3853e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Fri, 30 Sep 2022 20:20:18 +0400 Subject: [PATCH 01/12] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B8=D0=B7=203=20=D0=B1=D0=B0=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=BE=D0=B9=20=D1=87=D0=B0=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/Direction.cs | 2 +- AirBomber/AirBomber/DrawningAirplane.cs | 2 +- AirBomber/AirBomber/EntityAirplane.cs | 2 +- AirBomber/AirBomber/FormAirBomber.cs | 20 +- AirBomber/AirBomber/FormMap.Designer.cs | 208 ----------------- AirBomber/AirBomber/FormMap.cs | 96 -------- .../FormMapWithSetAirplanes.Designer.cs | 212 ++++++++++++++++++ .../AirBomber/FormMapWithSetAirplanes.cs | 153 +++++++++++++ ...mMap.resx => FormMapWithSetAirplanes.resx} | 3 - AirBomber/AirBomber/IAirplaneEngines.cs | 2 +- .../AirBomber/MapWithSetAirplanesGeneric.cs | 184 +++++++++++++++ AirBomber/AirBomber/SetAirplanesGeneric.cs | 94 ++++++++ 12 files changed, 662 insertions(+), 316 deletions(-) delete mode 100644 AirBomber/AirBomber/FormMap.Designer.cs delete mode 100644 AirBomber/AirBomber/FormMap.cs create mode 100644 AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs create mode 100644 AirBomber/AirBomber/FormMapWithSetAirplanes.cs rename AirBomber/AirBomber/{FormMap.resx => FormMapWithSetAirplanes.resx} (93%) create mode 100644 AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs create mode 100644 AirBomber/AirBomber/SetAirplanesGeneric.cs diff --git a/AirBomber/AirBomber/Direction.cs b/AirBomber/AirBomber/Direction.cs index 808d3d0..a978408 100644 --- a/AirBomber/AirBomber/Direction.cs +++ b/AirBomber/AirBomber/Direction.cs @@ -3,7 +3,7 @@ /// /// Направление перемещения /// - internal enum Direction + public enum Direction { None = 0, Up = 1, diff --git a/AirBomber/AirBomber/DrawningAirplane.cs b/AirBomber/AirBomber/DrawningAirplane.cs index cb5c3af..0279434 100644 --- a/AirBomber/AirBomber/DrawningAirplane.cs +++ b/AirBomber/AirBomber/DrawningAirplane.cs @@ -3,7 +3,7 @@ /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности /// - internal class DrawningAirplane + public class DrawningAirplane { /// /// Класс-сущность diff --git a/AirBomber/AirBomber/EntityAirplane.cs b/AirBomber/AirBomber/EntityAirplane.cs index 2869683..6ba8ec9 100644 --- a/AirBomber/AirBomber/EntityAirplane.cs +++ b/AirBomber/AirBomber/EntityAirplane.cs @@ -3,7 +3,7 @@ /// /// Класс-сущность "Самолет" /// - internal class EntityAirplane + public class EntityAirplane { /// /// Скорость diff --git a/AirBomber/AirBomber/FormAirBomber.cs b/AirBomber/AirBomber/FormAirBomber.cs index 4302b71..e7c2a25 100644 --- a/AirBomber/AirBomber/FormAirBomber.cs +++ b/AirBomber/AirBomber/FormAirBomber.cs @@ -2,8 +2,14 @@ namespace AirBomber { public partial class FormAirBomber : Form { - private DrawningAirplane _airplane; - + private DrawningAirplane _airplane; + + + /// + /// + /// + public DrawningAirplane SelectedAirplane { get; private set; } + public FormAirBomber() { InitializeComponent(); @@ -39,9 +45,13 @@ namespace AirBomber break; } Random rnd = new(); - _airplane = new DrawningAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), - Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), - typeAirplaneEngines); + Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + color = dialog.Color; + } + _airplane = new DrawningAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), color, typeAirplaneEngines); _airplane.DrawningEngines.CountEngines = (int)countEngineBox.Value; _airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxCar.Width, pictureBoxCar.Height); toolStripStatusLabelSpeed.Text = $": {_airplane.Airplane.Speed}"; diff --git a/AirBomber/AirBomber/FormMap.Designer.cs b/AirBomber/AirBomber/FormMap.Designer.cs deleted file mode 100644 index 54ebe8b..0000000 --- a/AirBomber/AirBomber/FormMap.Designer.cs +++ /dev/null @@ -1,208 +0,0 @@ -namespace AirBomber -{ - partial class FormMap - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.pictureBoxCar = new System.Windows.Forms.PictureBox(); - this.statusStrip = new System.Windows.Forms.StatusStrip(); - this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel(); - this.buttonCreate = new System.Windows.Forms.Button(); - this.buttonUp = new System.Windows.Forms.Button(); - this.buttonLeft = new System.Windows.Forms.Button(); - this.buttonRight = new System.Windows.Forms.Button(); - this.buttonDown = new System.Windows.Forms.Button(); - this.buttonCreateModif = new System.Windows.Forms.Button(); - this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit(); - this.statusStrip.SuspendLayout(); - this.SuspendLayout(); - // - // pictureBoxCar - // - this.pictureBoxCar.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBoxCar.Location = new System.Drawing.Point(0, 0); - this.pictureBoxCar.Name = "pictureBoxCar"; - this.pictureBoxCar.Size = new System.Drawing.Size(800, 428); - this.pictureBoxCar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pictureBoxCar.TabIndex = 0; - this.pictureBoxCar.TabStop = false; - // - // statusStrip - // - this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabelSpeed, - this.toolStripStatusLabelWeight, - this.toolStripStatusLabelBodyColor}); - this.statusStrip.Location = new System.Drawing.Point(0, 428); - this.statusStrip.Name = "statusStrip"; - this.statusStrip.Size = new System.Drawing.Size(800, 22); - this.statusStrip.TabIndex = 1; - // - // toolStripStatusLabelSpeed - // - this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed"; - this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17); - this.toolStripStatusLabelSpeed.Text = "Скорость:"; - // - // toolStripStatusLabelWeight - // - this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight"; - this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(29, 17); - this.toolStripStatusLabelWeight.Text = "Вес:"; - // - // toolStripStatusLabelBodyColor - // - this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor"; - this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17); - this.toolStripStatusLabelBodyColor.Text = "Цвет:"; - // - // buttonCreate - // - this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonCreate.Location = new System.Drawing.Point(12, 390); - this.buttonCreate.Name = "buttonCreate"; - this.buttonCreate.Size = new System.Drawing.Size(75, 23); - this.buttonCreate.TabIndex = 2; - this.buttonCreate.Text = "Создать"; - this.buttonCreate.UseVisualStyleBackColor = true; - this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click); - // - // buttonUp - // - 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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonUp.Location = new System.Drawing.Point(722, 350); - this.buttonUp.Name = "buttonUp"; - this.buttonUp.Size = new System.Drawing.Size(30, 30); - this.buttonUp.TabIndex = 3; - this.buttonUp.UseVisualStyleBackColor = true; - this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonLeft - // - 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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(686, 386); - this.buttonLeft.Name = "buttonLeft"; - this.buttonLeft.Size = new System.Drawing.Size(30, 30); - this.buttonLeft.TabIndex = 4; - this.buttonLeft.UseVisualStyleBackColor = true; - this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonRight - // - 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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(758, 386); - this.buttonRight.Name = "buttonRight"; - this.buttonRight.Size = new System.Drawing.Size(30, 30); - this.buttonRight.TabIndex = 5; - this.buttonRight.UseVisualStyleBackColor = true; - this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonDown - // - 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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(722, 386); - this.buttonDown.Name = "buttonDown"; - this.buttonDown.Size = new System.Drawing.Size(30, 30); - this.buttonDown.TabIndex = 6; - this.buttonDown.UseVisualStyleBackColor = true; - this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonCreateModif - // - this.buttonCreateModif.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonCreateModif.Location = new System.Drawing.Point(104, 390); - this.buttonCreateModif.Name = "buttonCreateModif"; - this.buttonCreateModif.Size = new System.Drawing.Size(110, 23); - this.buttonCreateModif.TabIndex = 7; - this.buttonCreateModif.Text = "Модификация"; - this.buttonCreateModif.UseVisualStyleBackColor = true; - this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click); - // - // 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(12, 12); - this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; - this.comboBoxSelectorMap.Size = new System.Drawing.Size(121, 23); - this.comboBoxSelectorMap.TabIndex = 8; - this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); - // - // FormMap - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Controls.Add(this.comboBoxSelectorMap); - this.Controls.Add(this.buttonCreateModif); - this.Controls.Add(this.buttonDown); - this.Controls.Add(this.buttonRight); - this.Controls.Add(this.buttonLeft); - this.Controls.Add(this.buttonUp); - this.Controls.Add(this.buttonCreate); - this.Controls.Add(this.pictureBoxCar); - this.Controls.Add(this.statusStrip); - this.Name = "FormMap"; - this.Text = "Карта"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).EndInit(); - this.statusStrip.ResumeLayout(false); - this.statusStrip.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private PictureBox pictureBoxCar; - private StatusStrip statusStrip; - private ToolStripStatusLabel toolStripStatusLabelSpeed; - private ToolStripStatusLabel toolStripStatusLabelWeight; - private ToolStripStatusLabel toolStripStatusLabelBodyColor; - private Button buttonCreate; - private Button buttonUp; - private Button buttonLeft; - private Button buttonRight; - private Button buttonDown; - private Button buttonCreateModif; - private ComboBox comboBoxSelectorMap; - } -} \ No newline at end of file diff --git a/AirBomber/AirBomber/FormMap.cs b/AirBomber/AirBomber/FormMap.cs deleted file mode 100644 index c311927..0000000 --- a/AirBomber/AirBomber/FormMap.cs +++ /dev/null @@ -1,96 +0,0 @@ -using AirBomber; - -namespace AirBomber -{ - public partial class FormMap : Form - { - private AbstractMap _abstractMap; - - public FormMap() - { - InitializeComponent(); - _abstractMap = new SimpleMap(); - } - /// - /// Заполнение информации по объекту - /// - /// - private void SetData(DrawningAirplane car) - { - toolStripStatusLabelSpeed.Text = $"Скорость: {car.Airplane.Speed}"; - toolStripStatusLabelWeight.Text = $"Вес: {car.Airplane.Weight}"; - toolStripStatusLabelBodyColor.Text = $"Цвет: {car.Airplane.BodyColor.Name}"; - pictureBoxCar.Image = _abstractMap.CreateMap(pictureBoxCar.Width, pictureBoxCar.Height, - new DrawningObject(car)); - } - /// - /// Обработка нажатия кнопки "Создать" - /// - /// - /// - private void ButtonCreate_Click(object sender, EventArgs e) - { - Random rnd = new(); - var car = new DrawningAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); - SetData(car); - } - /// - /// Изменение размеров формы - /// - /// - /// - private void ButtonMove_Click(object sender, EventArgs e) - { - //получаем имя кнопки - string name = ((Button)sender)?.Name ?? string.Empty; - Direction dir = Direction.None; - switch (name) - { - case "buttonUp": - dir = Direction.Up; - break; - case "buttonDown": - dir = Direction.Down; - break; - case "buttonLeft": - dir = Direction.Left; - break; - case "buttonRight": - dir = Direction.Right; - break; - } - pictureBoxCar.Image = _abstractMap?.MoveObject(dir); - } - /// - /// Обработка нажатия кнопки "Модификация" - /// - /// - /// - private void ButtonCreateModif_Click(object sender, EventArgs e) - { - Random rnd = new(); - var car = new DrawningAirBomber(rnd.Next(100, 300), rnd.Next(1000, 2000), - Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), - Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), - Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); - SetData(car); - } - /// - /// Смена карты - /// - /// - /// - private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) - { - switch (comboBoxSelectorMap.Text) - { - case "Простая карта": - _abstractMap = new SimpleMap(); - break; - case "Карта со стенами": - _abstractMap = new WallMap(); - break; - } - } - } -} diff --git a/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs b/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs new file mode 100644 index 0000000..8d581aa --- /dev/null +++ b/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs @@ -0,0 +1,212 @@ +namespace AirBomber +{ + partial class FormMapWithSetAirplanes + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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.buttonDown = new System.Windows.Forms.Button(); + this.buttonRight = new System.Windows.Forms.Button(); + this.buttonLeft = new System.Windows.Forms.Button(); + this.buttonUp = new System.Windows.Forms.Button(); + this.buttonShowOnMap = new System.Windows.Forms.Button(); + this.buttonAddAirplane = new System.Windows.Forms.Button(); + this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); + this.pictureBox = new System.Windows.Forms.PictureBox(); + this.groupBoxTools.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + this.SuspendLayout(); + // + // groupBoxTools + // + this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition); + this.groupBoxTools.Controls.Add(this.buttonRemoveAirplane); + this.groupBoxTools.Controls.Add(this.buttonShowStorage); + this.groupBoxTools.Controls.Add(this.buttonDown); + this.groupBoxTools.Controls.Add(this.buttonRight); + this.groupBoxTools.Controls.Add(this.buttonLeft); + this.groupBoxTools.Controls.Add(this.buttonUp); + this.groupBoxTools.Controls.Add(this.buttonShowOnMap); + this.groupBoxTools.Controls.Add(this.buttonAddAirplane); + this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap); + this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; + this.groupBoxTools.Location = new System.Drawing.Point(811, 0); + this.groupBoxTools.Name = "groupBoxTools"; + this.groupBoxTools.Size = new System.Drawing.Size(204, 554); + this.groupBoxTools.TabIndex = 0; + this.groupBoxTools.TabStop = false; + this.groupBoxTools.Text = "Инструменты"; + // + // maskedTextBoxPosition + // + this.maskedTextBoxPosition.Location = new System.Drawing.Point(17, 166); + this.maskedTextBoxPosition.Mask = "00"; + this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; + this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23); + this.maskedTextBoxPosition.TabIndex = 2; + this.maskedTextBoxPosition.ValidatingType = typeof(int); + // + // buttonRemoveAirplane + // + this.buttonRemoveAirplane.Location = new System.Drawing.Point(17, 195); + this.buttonRemoveAirplane.Name = "buttonRemoveAirplane"; + this.buttonRemoveAirplane.Size = new System.Drawing.Size(175, 35); + this.buttonRemoveAirplane.TabIndex = 3; + this.buttonRemoveAirplane.Text = "Удалить самолет"; + this.buttonRemoveAirplane.UseVisualStyleBackColor = true; + this.buttonRemoveAirplane.Click += new System.EventHandler(this.ButtonRemoveAirplane_Click); + // + // buttonShowStorage + // + this.buttonShowStorage.Location = new System.Drawing.Point(17, 287); + this.buttonShowStorage.Name = "buttonShowStorage"; + this.buttonShowStorage.Size = new System.Drawing.Size(175, 35); + this.buttonShowStorage.TabIndex = 4; + this.buttonShowStorage.Text = "Посмотреть хранилище"; + this.buttonShowStorage.UseVisualStyleBackColor = true; + this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click); + // + // buttonDown + // + 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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonDown.Location = new System.Drawing.Point(91, 504); + this.buttonDown.Name = "buttonDown"; + this.buttonDown.Size = new System.Drawing.Size(30, 30); + this.buttonDown.TabIndex = 10; + this.buttonDown.UseVisualStyleBackColor = true; + // + // buttonRight + // + 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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonRight.Location = new System.Drawing.Point(127, 504); + this.buttonRight.Name = "buttonRight"; + this.buttonRight.Size = new System.Drawing.Size(30, 30); + this.buttonRight.TabIndex = 9; + this.buttonRight.UseVisualStyleBackColor = true; + // + // buttonLeft + // + 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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonLeft.Location = new System.Drawing.Point(55, 504); + this.buttonLeft.Name = "buttonLeft"; + this.buttonLeft.Size = new System.Drawing.Size(30, 30); + this.buttonLeft.TabIndex = 8; + this.buttonLeft.UseVisualStyleBackColor = true; + // + // buttonUp + // + 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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonUp.Location = new System.Drawing.Point(91, 468); + this.buttonUp.Name = "buttonUp"; + this.buttonUp.Size = new System.Drawing.Size(30, 30); + this.buttonUp.TabIndex = 7; + this.buttonUp.UseVisualStyleBackColor = true; + // + // buttonShowOnMap + // + this.buttonShowOnMap.Location = new System.Drawing.Point(17, 391); + this.buttonShowOnMap.Name = "buttonShowOnMap"; + this.buttonShowOnMap.Size = new System.Drawing.Size(175, 35); + this.buttonShowOnMap.TabIndex = 5; + this.buttonShowOnMap.Text = "Посмотреть карту"; + this.buttonShowOnMap.UseVisualStyleBackColor = true; + this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click); + // + // buttonAddAirplane + // + this.buttonAddAirplane.Location = new System.Drawing.Point(17, 106); + this.buttonAddAirplane.Name = "buttonAddAirplane"; + this.buttonAddAirplane.Size = new System.Drawing.Size(175, 35); + this.buttonAddAirplane.TabIndex = 1; + this.buttonAddAirplane.Text = "Добавить самолет"; + this.buttonAddAirplane.UseVisualStyleBackColor = true; + this.buttonAddAirplane.Click += new System.EventHandler(this.ButtonAddAirplane_Click); + // + // 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, 32); + 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 + // + this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBox.Location = new System.Drawing.Point(0, 0); + this.pictureBox.Name = "pictureBox"; + this.pictureBox.Size = new System.Drawing.Size(811, 554); + this.pictureBox.TabIndex = 1; + this.pictureBox.TabStop = false; + // + // FormMapWithSetAirplanes + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1015, 554); + this.Controls.Add(this.pictureBox); + this.Controls.Add(this.groupBoxTools); + this.Name = "FormMapWithSetAirplanes"; + this.Text = "Карта с набором объектов"; + this.groupBoxTools.ResumeLayout(false); + this.groupBoxTools.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBoxTools; + private PictureBox pictureBox; + private ComboBox comboBoxSelectorMap; + private Button buttonShowOnMap; + private Button buttonAddAirplane; + private Button buttonDown; + private Button buttonRight; + private Button buttonLeft; + private Button buttonUp; + private Button buttonShowStorage; + private Button buttonRemoveAirplane; + private MaskedTextBox maskedTextBoxPosition; + } +} \ No newline at end of file diff --git a/AirBomber/AirBomber/FormMapWithSetAirplanes.cs b/AirBomber/AirBomber/FormMapWithSetAirplanes.cs new file mode 100644 index 0000000..def5d4e --- /dev/null +++ b/AirBomber/AirBomber/FormMapWithSetAirplanes.cs @@ -0,0 +1,153 @@ +namespace AirBomber +{ + public partial class FormMapWithSetAirplanes : Form + { + /// + /// Объект от класса карты с набором объектов + /// + private MapWithSetAirplanesGeneric _mapAirplanesCollectionGeneric; + /// + /// Конструктор + /// + public FormMapWithSetAirplanes() + { + InitializeComponent(); + } + /// + /// Выбор карты + /// + /// + /// + private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) + { + AbstractMap map = null; + switch (comboBoxSelectorMap.Text) + { + case "Простая карта": + map = new SimpleMap(); + break; + case "Карта со стенами": + map = new WallMap(); + break; + } + if (map != null) + { + _mapAirplanesCollectionGeneric = new MapWithSetAirplanesGeneric( + pictureBox.Width, pictureBox.Height, map); + } + else + { + _mapAirplanesCollectionGeneric = null; + } + } + /// + /// Добавление объекта + /// + /// + /// + private void ButtonAddAirplane_Click(object sender, EventArgs e) + { + if(_mapAirplanesCollectionGeneric == null) + { + return; + } + FormAirBomber form = new(); + if (form.ShowDialog() == DialogResult.OK) + { + DrawningObject airplane = new(form.SelectedAirplane); + if (form.SelectedAirplane == null || !(_mapAirplanesCollectionGeneric + airplane)) + { + MessageBox.Show("Не удалось добавить объект"); + } + else + { + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet(); + } + } + } + /// + /// Удаление объекта + /// + /// + /// + 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("Не удалось удалить объект"); + } + } + /// + /// Вывод набора + /// + /// + /// + private void ButtonShowStorage_Click(object sender, EventArgs e) + { + if (_mapAirplanesCollectionGeneric == null) + { + return; + } + pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet(); + } + /// + /// Вывод карты + /// + /// + /// + private void ButtonShowOnMap_Click(object sender, EventArgs e) + { + if (_mapAirplanesCollectionGeneric == null) + { + return; + } + pictureBox.Image = _mapAirplanesCollectionGeneric.ShowOnMap(); + } + /// + /// Перемещение + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_mapAirplanesCollectionGeneric == null) + { + return; + } + //получаем имя кнопки + string name = ((Button)sender)?.Name ?? string.Empty; + Direction dir = Direction.None; + switch (name) + { + case "buttonUp": + dir = Direction.Up; + break; + case "buttonDown": + dir = Direction.Down; + break; + case "buttonLeft": + dir = Direction.Left; + break; + case "buttonRight": + dir = Direction.Right; + break; + } + pictureBox.Image = _mapAirplanesCollectionGeneric.MoveObject(dir); + } + } +} \ No newline at end of file diff --git a/AirBomber/AirBomber/FormMap.resx b/AirBomber/AirBomber/FormMapWithSetAirplanes.resx similarity index 93% rename from AirBomber/AirBomber/FormMap.resx rename to AirBomber/AirBomber/FormMapWithSetAirplanes.resx index 2c0949d..f298a7b 100644 --- a/AirBomber/AirBomber/FormMap.resx +++ b/AirBomber/AirBomber/FormMapWithSetAirplanes.resx @@ -57,7 +57,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - \ No newline at end of file diff --git a/AirBomber/AirBomber/IAirplaneEngines.cs b/AirBomber/AirBomber/IAirplaneEngines.cs index ccbc860..958a9c6 100644 --- a/AirBomber/AirBomber/IAirplaneEngines.cs +++ b/AirBomber/AirBomber/IAirplaneEngines.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace AirBomber { - internal interface IAirplaneEngines + public interface IAirplaneEngines { /// Получение действительного количества двигателей или установка поддерживаемого числа двигателей /// The count engines. diff --git a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs new file mode 100644 index 0000000..f1b5c96 --- /dev/null +++ b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs @@ -0,0 +1,184 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirBomber +{ + internal class MapWithSetAirplanesGeneric + where T : class, IDrawningObject + where U : AbstractMap + { + /// + /// Ширина окна отрисовки + /// + private readonly int _pictureWidth; + /// + /// Высота окна отрисовки + /// + private readonly int _pictureHeight; + /// + /// Размер занимаемого объектом места (ширина) + /// + private readonly int _placeSizeWidth = 210; + /// + /// Размер занимаемого объектом места (высота) + /// + private readonly int _placeSizeHeight = 190; + /// + /// Набор объектов + /// + private readonly SetAirplanesGeneric _setAirplanes; + /// + /// Карта + /// + private readonly U _map; + /// + /// Конструктор + /// + /// + /// + /// + public MapWithSetAirplanesGeneric(int picWidth, int picHeight, U map) + { + int width = picWidth / _placeSizeWidth; + int height = picHeight / _placeSizeHeight; + _setAirplanes = new SetAirplanesGeneric(width * height); + _pictureWidth = picWidth; + _pictureHeight = picHeight; + _map = map; + } + /// + /// Перегрузка оператора сложения + /// + /// + /// + /// + public static bool operator +(MapWithSetAirplanesGeneric map, T airplane) + { + return map._setAirplanes.Insert(airplane); + } + /// + /// Перегрузка оператора вычитания + /// + /// + /// + /// + public static bool operator -(MapWithSetAirplanesGeneric map, int position) + { + return map._setAirplanes.Remove(position); + } + /// + /// Вывод всего набора объектов + /// + /// + public Bitmap ShowSet() + { + Bitmap bmp = new(_pictureWidth, _pictureHeight); + Graphics gr = Graphics.FromImage(bmp); + DrawBackground(gr); + DrawAirplanes(gr); + return bmp; + } + /// + /// Просмотр объекта на карте + /// + /// + public Bitmap ShowOnMap() + { + Shaking(); + for (int i = 0; i < _setAirplanes.Count; i++) + { + var airplane = _setAirplanes.Get(i); + if (airplane != null) + { + return _map.CreateMap(_pictureWidth, _pictureHeight, airplane); + } + } + return new(_pictureWidth, _pictureHeight); + } + /// + /// Перемещение объекта по крате + /// + /// + /// + public Bitmap MoveObject(Direction direction) + { + if (_map != null) + { + return _map.MoveObject(direction); + } + return new(_pictureWidth, _pictureHeight); + } + /// + /// "Взбалтываем" набор, чтобы все элементы оказались в начале + /// + private void Shaking() + { + int j = _setAirplanes.Count - 1; + for (int i = 0; i < _setAirplanes.Count; i++) + { + if (_setAirplanes.Get(i) == null) + { + for (; j > i; j--) + { + var airplane = _setAirplanes.Get(j); + if (airplane != null) + { + _setAirplanes.Insert(airplane, i); + _setAirplanes.Remove(j); + break; + } + } + if (j <= i) + { + return; + } + } + } + } + /// + /// Метод отрисовки фона + /// + /// + private void DrawBackground(Graphics g) + { + Pen pen = new(Color.Black, 3); + for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) + { + for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; j++) + { + DrawHangar(g, pen, new RectangleF(i * _placeSizeWidth, j * _placeSizeHeight, _placeSizeWidth / 1.8F, _placeSizeHeight / 1.6F)); + // g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight); + } + } + } + + private void DrawHangar(Graphics g, Pen pen, RectangleF rect) + { + g.DrawLine(pen, rect.Left , rect.Top , rect.Right, rect.Top ); + g.DrawLine(pen, rect.Right, rect.Top , rect.Right, rect.Bottom); + g.DrawLine(pen, rect.Right, rect.Bottom, rect.Left , rect.Bottom); + + // Края ворот ангара + g.DrawLine(pen, rect.Left, rect.Top , rect.Left, rect.Top + rect.Height / 10); + g.DrawLine(pen, rect.Left, rect.Bottom, rect.Left, rect.Bottom - rect.Height / 10); + } + /// + /// Метод прорисовки объектов + /// + /// + private void DrawAirplanes(Graphics g) + { + int countInLine = _pictureWidth / _placeSizeWidth; + int maxLeft = (countInLine - 1) * _placeSizeWidth; + for (int i = 0; i < _setAirplanes.Count; i++) + { + var airplane = _setAirplanes.Get(i); + airplane?.SetObject(maxLeft - i % countInLine * _placeSizeWidth, i / countInLine * _placeSizeHeight + 3, _pictureWidth, _pictureHeight); + airplane?.DrawningObject(g); + } + } + } +} diff --git a/AirBomber/AirBomber/SetAirplanesGeneric.cs b/AirBomber/AirBomber/SetAirplanesGeneric.cs new file mode 100644 index 0000000..178d798 --- /dev/null +++ b/AirBomber/AirBomber/SetAirplanesGeneric.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirBomber +{ + /// + /// Параметризованный набор объектов + /// + /// + internal class SetAirplanesGeneric + where T : class + { + /// + /// Массив объектов, которые храним + /// + private readonly T[] _places; + /// + /// Количество объектов в массиве + /// + public int Count => _places.Length; + /// + /// Конструктор + /// + /// + public SetAirplanesGeneric(int count) + { + _places = new T[count]; + } + /// + /// Добавление объекта в набор + /// + /// Добавляемый самолет + /// + public bool Insert(T airplane) + { + return Insert(airplane, 0); + } + + private bool isCorrectPosition(int position) + { + return 0 <= position && position < Count; + } + /// + /// Добавление объекта в набор на конкретную позицию + /// + /// Добавляемый самолет + /// Позиция + /// + public bool Insert(T airplane, int position) + { + int positionNullElement = position; + while (Get(positionNullElement) != null) + { + positionNullElement++; + } + // Если изначальная позиция была некорректной или пустых элементов справа не оказалось возвращаем false + if (!isCorrectPosition(positionNullElement)) + { + return false; + } + while (positionNullElement != position) // Смещение вправо + { + _places[positionNullElement] = _places[positionNullElement - 1]; + positionNullElement--; + } + _places[position] = airplane; + return true; + } + /// + /// Удаление объекта из набора с конкретной позиции + /// + /// + /// + public bool Remove(int position) + { + if (!isCorrectPosition(position)) + return false; + _places[position] = null; + return true; + } + /// + /// Получение объекта из набора по позиции + /// + /// + /// + public T Get(int position) + { + return isCorrectPosition(position) ? _places[position] : null; + } + } +} -- 2.25.1 From 3d0fd13bec79d95c7752efbdd350482023e638d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Fri, 30 Sep 2022 21:16:33 +0400 Subject: [PATCH 02/12] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20-=20=D0=B3?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=82=D0=BE=D1=80=20=D1=81=D0=B0?= =?UTF-8?q?=D0=BC=D0=BE=D0=BB=D0=B5=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/DrawningAirplane.cs | 6 +- AirBomber/AirBomber/GeneratorAirplane.cs | 72 ++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 AirBomber/AirBomber/GeneratorAirplane.cs diff --git a/AirBomber/AirBomber/DrawningAirplane.cs b/AirBomber/AirBomber/DrawningAirplane.cs index 0279434..8893c06 100644 --- a/AirBomber/AirBomber/DrawningAirplane.cs +++ b/AirBomber/AirBomber/DrawningAirplane.cs @@ -47,7 +47,11 @@ Airplane = new EntityAirplane(speed, weight, bodyColor); DrawningEngines = typeAirplaneEngines; } - + public DrawningAirplane(EntityAirplane entityAirplane, IAirplaneEngines? typeAirplaneEngines = null) + { + Airplane = entityAirplane; + DrawningEngines = typeAirplaneEngines; + } /// /// Инициализация свойств /// diff --git a/AirBomber/AirBomber/GeneratorAirplane.cs b/AirBomber/AirBomber/GeneratorAirplane.cs new file mode 100644 index 0000000..de39540 --- /dev/null +++ b/AirBomber/AirBomber/GeneratorAirplane.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirBomber +{ + /// + /// Класс, который генирирует самолет из разнообразного количества сущностей и типа двигателей + /// + /// Класс Сущность самолет + /// Класс двигателя самолета + internal class GeneratorAirplane + where T : EntityAirplane + where U : class, IAirplaneEngines + { + private readonly T[] typesOfEntity; + private readonly U[] typesOfEngines; + + public int NumTypesOfEntity { get; private set; } + public int NumTypesOfEngines { get; private set; } + + public GeneratorAirplane(int countTypesOfEntity, int countTypesOfEngines) + { + typesOfEntity = new T[countTypesOfEntity]; + typesOfEngines = new U[countTypesOfEngines]; + } + /// + /// Добавляет возможный тип сущности при генерации самолета + /// + /// тип + /// Успешно ли проведена операция + public bool AddTypeOfEntity(T type) + { + if (NumTypesOfEntity >= typesOfEntity.Length) + { + return false; + } + typesOfEntity[NumTypesOfEntity++] = type; + return true; + } + /// + /// Добавляет возможный тип двигателей при генерации самолета + /// + /// тип + /// Успешно ли проведена операция + public bool AddTypeOfEngines(U type) + { + if (NumTypesOfEngines >= typesOfEngines.Length) + { + return false; + } + typesOfEngines[NumTypesOfEngines++] = type; + return true; + } + /// + /// Генерирует объект отрисовки + /// + /// Возвращает объект отрисовки, либо null, если не были добавлены типы для выборки + public DrawningObject? Generate() + { + if (NumTypesOfEngines == 0 || NumTypesOfEntity == 0) + { + return null; + } + var rnd = new Random(); + var airplane = new DrawningAirplane(typesOfEntity[rnd.Next() % NumTypesOfEntity], typesOfEngines[rnd.Next() % NumTypesOfEngines]); + return new DrawningObject(airplane); + } + } +} -- 2.25.1 From 7259d846ede0e6898d4d8eb0e80cf4235ee1605c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Fri, 30 Sep 2022 23:23:02 +0400 Subject: [PATCH 03/12] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0?= =?UTF-8?q?=20=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?=D1=81=D0=B0=D0=BC=D0=BE=D0=BB=D0=B5=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...r.cs => FormGeneratorAirplane.Designer.cs} | 176 +++++++++++------- AirBomber/AirBomber/FormGeneratorAirplane.cs | 119 ++++++++++++ ...planes.resx => FormGeneratorAirplane.resx} | 0 .../AirBomber/FormMapWithSetAirplanes.cs | 153 --------------- AirBomber/AirBomber/GeneratorAirplane.cs | 4 +- AirBomber/AirBomber/Program.cs | 2 +- 6 files changed, 234 insertions(+), 220 deletions(-) rename AirBomber/AirBomber/{FormMapWithSetAirplanes.Designer.cs => FormGeneratorAirplane.Designer.cs} (52%) create mode 100644 AirBomber/AirBomber/FormGeneratorAirplane.cs rename AirBomber/AirBomber/{FormMapWithSetAirplanes.resx => FormGeneratorAirplane.resx} (100%) delete mode 100644 AirBomber/AirBomber/FormMapWithSetAirplanes.cs diff --git a/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs b/AirBomber/AirBomber/FormGeneratorAirplane.Designer.cs similarity index 52% rename from AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs rename to AirBomber/AirBomber/FormGeneratorAirplane.Designer.cs index 8d581aa..5d85129 100644 --- a/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs +++ b/AirBomber/AirBomber/FormGeneratorAirplane.Designer.cs @@ -1,6 +1,6 @@ namespace AirBomber { - partial class FormMapWithSetAirplanes + partial class FormGeneratorAirplane { /// /// Required designer variable. @@ -29,32 +29,43 @@ private void InitializeComponent() { 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.labelSpeed = new System.Windows.Forms.Label(); + 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.btnAddCountEngines = new System.Windows.Forms.Button(); + this.buttonAddTypeOfEntity = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button(); this.buttonRight = new System.Windows.Forms.Button(); this.buttonLeft = new System.Windows.Forms.Button(); this.buttonUp = new System.Windows.Forms.Button(); - this.buttonShowOnMap = new System.Windows.Forms.Button(); - this.buttonAddAirplane = new System.Windows.Forms.Button(); this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); this.pictureBox = new System.Windows.Forms.PictureBox(); this.groupBoxTools.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericSpeed)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericWeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownEngines)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); this.SuspendLayout(); // // groupBoxTools // - this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition); - this.groupBoxTools.Controls.Add(this.buttonRemoveAirplane); - this.groupBoxTools.Controls.Add(this.buttonShowStorage); + this.groupBoxTools.Controls.Add(this.labelSpeed); + this.groupBoxTools.Controls.Add(this.numericSpeed); + this.groupBoxTools.Controls.Add(this.labelWeight); + this.groupBoxTools.Controls.Add(this.numericWeight); + this.groupBoxTools.Controls.Add(this.btnGenerateAirplane); + this.groupBoxTools.Controls.Add(this.labelCountEngines); + this.groupBoxTools.Controls.Add(this.numericUpDownEngines); + this.groupBoxTools.Controls.Add(this.btnAddCountEngines); + this.groupBoxTools.Controls.Add(this.buttonAddTypeOfEntity); this.groupBoxTools.Controls.Add(this.buttonDown); this.groupBoxTools.Controls.Add(this.buttonRight); this.groupBoxTools.Controls.Add(this.buttonLeft); this.groupBoxTools.Controls.Add(this.buttonUp); - this.groupBoxTools.Controls.Add(this.buttonShowOnMap); - this.groupBoxTools.Controls.Add(this.buttonAddAirplane); this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap); this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; this.groupBoxTools.Location = new System.Drawing.Point(811, 0); @@ -64,34 +75,83 @@ this.groupBoxTools.TabStop = false; this.groupBoxTools.Text = "Инструменты"; // - // maskedTextBoxPosition + // labelSpeed // - this.maskedTextBoxPosition.Location = new System.Drawing.Point(17, 166); - this.maskedTextBoxPosition.Mask = "00"; - this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; - this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23); - this.maskedTextBoxPosition.TabIndex = 2; - this.maskedTextBoxPosition.ValidatingType = typeof(int); + this.labelSpeed.AutoSize = true; + this.labelSpeed.Location = new System.Drawing.Point(17, 58); + this.labelSpeed.Name = "labelSpeed"; + this.labelSpeed.Size = new System.Drawing.Size(117, 15); + this.labelSpeed.TabIndex = 19; + this.labelSpeed.Text = "Скорость самолета:"; // - // buttonRemoveAirplane + // numericSpeed // - this.buttonRemoveAirplane.Location = new System.Drawing.Point(17, 195); - this.buttonRemoveAirplane.Name = "buttonRemoveAirplane"; - this.buttonRemoveAirplane.Size = new System.Drawing.Size(175, 35); - this.buttonRemoveAirplane.TabIndex = 3; - this.buttonRemoveAirplane.Text = "Удалить самолет"; - this.buttonRemoveAirplane.UseVisualStyleBackColor = true; - this.buttonRemoveAirplane.Click += new System.EventHandler(this.ButtonRemoveAirplane_Click); + this.numericSpeed.Location = new System.Drawing.Point(136, 56); + this.numericSpeed.Name = "numericSpeed"; + this.numericSpeed.Size = new System.Drawing.Size(56, 23); + this.numericSpeed.TabIndex = 18; // - // buttonShowStorage + // labelWeight // - this.buttonShowStorage.Location = new System.Drawing.Point(17, 287); - this.buttonShowStorage.Name = "buttonShowStorage"; - this.buttonShowStorage.Size = new System.Drawing.Size(175, 35); - this.buttonShowStorage.TabIndex = 4; - this.buttonShowStorage.Text = "Посмотреть хранилище"; - this.buttonShowStorage.UseVisualStyleBackColor = true; - this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click); + this.labelWeight.AutoSize = true; + this.labelWeight.Location = new System.Drawing.Point(17, 83); + this.labelWeight.Name = "labelWeight"; + this.labelWeight.Size = new System.Drawing.Size(100, 15); + this.labelWeight.TabIndex = 17; + this.labelWeight.Text = "Масса самолета:"; + // + // numericWeight + // + this.numericWeight.Location = new System.Drawing.Point(136, 81); + this.numericWeight.Name = "numericWeight"; + this.numericWeight.Size = new System.Drawing.Size(56, 23); + this.numericWeight.TabIndex = 16; + // + // btnGenerateAirplane + // + this.btnGenerateAirplane.Location = new System.Drawing.Point(17, 233); + 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); + // + // labelCountEngines + // + this.labelCountEngines.AutoSize = true; + this.labelCountEngines.Location = new System.Drawing.Point(17, 157); + this.labelCountEngines.Name = "labelCountEngines"; + this.labelCountEngines.Size = new System.Drawing.Size(113, 15); + this.labelCountEngines.TabIndex = 14; + this.labelCountEngines.Text = "Кол-во двигателей:"; + // + // numericUpDownEngines + // + this.numericUpDownEngines.Location = new System.Drawing.Point(136, 155); + this.numericUpDownEngines.Name = "numericUpDownEngines"; + this.numericUpDownEngines.Size = new System.Drawing.Size(56, 23); + this.numericUpDownEngines.TabIndex = 13; + // + // btnAddCountEngines + // + this.btnAddCountEngines.Location = new System.Drawing.Point(17, 184); + this.btnAddCountEngines.Name = "btnAddCountEngines"; + this.btnAddCountEngines.Size = new System.Drawing.Size(175, 43); + this.btnAddCountEngines.TabIndex = 12; + this.btnAddCountEngines.Text = "Добавить кол-во двигателей для генерации"; + this.btnAddCountEngines.UseVisualStyleBackColor = true; + this.btnAddCountEngines.Click += new System.EventHandler(this.btnAddCountEngines_Click); + // + // buttonAddTypeOfEntity + // + this.buttonAddTypeOfEntity.Location = new System.Drawing.Point(17, 110); + this.buttonAddTypeOfEntity.Name = "buttonAddTypeOfEntity"; + this.buttonAddTypeOfEntity.Size = new System.Drawing.Size(175, 39); + this.buttonAddTypeOfEntity.TabIndex = 11; + this.buttonAddTypeOfEntity.Text = "Добавить свойства для генерации"; + this.buttonAddTypeOfEntity.UseVisualStyleBackColor = true; + this.buttonAddTypeOfEntity.Click += new System.EventHandler(this.buttonAddTypeOfEntity_Click); // // buttonDown // @@ -137,33 +197,14 @@ this.buttonUp.TabIndex = 7; this.buttonUp.UseVisualStyleBackColor = true; // - // buttonShowOnMap - // - this.buttonShowOnMap.Location = new System.Drawing.Point(17, 391); - this.buttonShowOnMap.Name = "buttonShowOnMap"; - this.buttonShowOnMap.Size = new System.Drawing.Size(175, 35); - this.buttonShowOnMap.TabIndex = 5; - this.buttonShowOnMap.Text = "Посмотреть карту"; - this.buttonShowOnMap.UseVisualStyleBackColor = true; - this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click); - // - // buttonAddAirplane - // - this.buttonAddAirplane.Location = new System.Drawing.Point(17, 106); - this.buttonAddAirplane.Name = "buttonAddAirplane"; - this.buttonAddAirplane.Size = new System.Drawing.Size(175, 35); - this.buttonAddAirplane.TabIndex = 1; - this.buttonAddAirplane.Text = "Добавить самолет"; - this.buttonAddAirplane.UseVisualStyleBackColor = true; - this.buttonAddAirplane.Click += new System.EventHandler(this.ButtonAddAirplane_Click); - // // 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, 32); + "Простая карта", + "Карта со стенами"}); + 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; @@ -178,17 +219,20 @@ this.pictureBox.TabIndex = 1; this.pictureBox.TabStop = false; // - // FormMapWithSetAirplanes + // FormGeneratorAirplane // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1015, 554); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBoxTools); - this.Name = "FormMapWithSetAirplanes"; - this.Text = "Карта с набором объектов"; + this.Name = "FormGeneratorAirplane"; + this.Text = "Генератор самолетов"; this.groupBoxTools.ResumeLayout(false); this.groupBoxTools.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericSpeed)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericWeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownEngines)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); this.ResumeLayout(false); @@ -199,14 +243,18 @@ private GroupBox groupBoxTools; private PictureBox pictureBox; private ComboBox comboBoxSelectorMap; - private Button buttonShowOnMap; - private Button buttonAddAirplane; private Button buttonDown; private Button buttonRight; private Button buttonLeft; private Button buttonUp; - private Button buttonShowStorage; - private Button buttonRemoveAirplane; - private MaskedTextBox maskedTextBoxPosition; + private Button btnAddCountEngines; + private Button buttonAddTypeOfEntity; + private Label labelCountEngines; + private NumericUpDown numericUpDownEngines; + private Button btnGenerateAirplane; + private Label labelSpeed; + private NumericUpDown numericSpeed; + private Label labelWeight; + private NumericUpDown numericWeight; } } \ No newline at end of file diff --git a/AirBomber/AirBomber/FormGeneratorAirplane.cs b/AirBomber/AirBomber/FormGeneratorAirplane.cs new file mode 100644 index 0000000..ca4b529 --- /dev/null +++ b/AirBomber/AirBomber/FormGeneratorAirplane.cs @@ -0,0 +1,119 @@ +namespace AirBomber +{ + public partial class FormGeneratorAirplane : Form + { + /// + /// Объект от класса карты с набором объектов + /// + private GeneratorAirplane _generatorAirplane; + private IDrawningObject? _airplane; + private AbstractMap? _map; + /// + /// Конструктор + /// + public FormGeneratorAirplane() + { + _generatorAirplane = new(100, 100); + InitializeComponent(); + } + /// + /// Выбор карты + /// + /// + /// + private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) + { + switch (comboBoxSelectorMap.Text) + { + case "Простая карта": + _map = new SimpleMap(); + break; + case "Карта со стенами": + _map = new WallMap(); + break; + } + if (_map != null) + { + pictureBox.Image = _map.CreateMap(pictureBox.Width, pictureBox.Height, _airplane); + } + } + /// + /// Перемещение + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + //получаем имя кнопки + string name = ((Button)sender)?.Name ?? string.Empty; + Direction dir = Direction.None; + switch (name) + { + case "buttonUp": + dir = Direction.Up; + break; + case "buttonDown": + dir = Direction.Down; + break; + case "buttonLeft": + dir = Direction.Left; + break; + case "buttonRight": + dir = Direction.Right; + break; + } + pictureBox.Image = _map?.MoveObject(dir) ?? pictureBox.Image; + } + + private void buttonAddTypeOfEntity_Click(object sender, EventArgs e) + { + Random rnd = new(); + Color colorBody = Color.FromArgb(rnd.Next() % 256, rnd.Next() % 256, rnd.Next() % 256); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + colorBody = dialog.Color; + } + var entity = new EntityAirplane((int)numericSpeed.Value, (int)numericWeight.Value, colorBody); + _generatorAirplane.AddTypeOfEntity(entity); + MessageBox.Show($"Добавлены свойства самолета:\n" + + $"Вес: {entity.Weight}\n" + + $"Скорость: {entity.Speed}\n" + + $"Цвет: {colorBody.Name}", + "Успешно добавлены свойства"); + } + + private void btnGenerateAirplane_Click(object sender, EventArgs e) + { + var airplane = _generatorAirplane.Generate(); + if (airplane == null) + { + MessageBox.Show("Не удалось сгенерировать самолет. Добавьте хотя бы по одному количество двигателей и свойств для генерации" + , "Генерация самолета"); + return; + } + _airplane = 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); + } + } + + private void btnAddCountEngines_Click(object sender, EventArgs e) + { + IAirplaneEngines engines = new DrawningAirplaneEngines(); + engines.CountEngines = (int)numericUpDownEngines.Value; + _generatorAirplane.AddTypeOfEngines(engines); + } + } +} \ No newline at end of file diff --git a/AirBomber/AirBomber/FormMapWithSetAirplanes.resx b/AirBomber/AirBomber/FormGeneratorAirplane.resx similarity index 100% rename from AirBomber/AirBomber/FormMapWithSetAirplanes.resx rename to AirBomber/AirBomber/FormGeneratorAirplane.resx diff --git a/AirBomber/AirBomber/FormMapWithSetAirplanes.cs b/AirBomber/AirBomber/FormMapWithSetAirplanes.cs deleted file mode 100644 index def5d4e..0000000 --- a/AirBomber/AirBomber/FormMapWithSetAirplanes.cs +++ /dev/null @@ -1,153 +0,0 @@ -namespace AirBomber -{ - public partial class FormMapWithSetAirplanes : Form - { - /// - /// Объект от класса карты с набором объектов - /// - private MapWithSetAirplanesGeneric _mapAirplanesCollectionGeneric; - /// - /// Конструктор - /// - public FormMapWithSetAirplanes() - { - InitializeComponent(); - } - /// - /// Выбор карты - /// - /// - /// - private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) - { - AbstractMap map = null; - switch (comboBoxSelectorMap.Text) - { - case "Простая карта": - map = new SimpleMap(); - break; - case "Карта со стенами": - map = new WallMap(); - break; - } - if (map != null) - { - _mapAirplanesCollectionGeneric = new MapWithSetAirplanesGeneric( - pictureBox.Width, pictureBox.Height, map); - } - else - { - _mapAirplanesCollectionGeneric = null; - } - } - /// - /// Добавление объекта - /// - /// - /// - private void ButtonAddAirplane_Click(object sender, EventArgs e) - { - if(_mapAirplanesCollectionGeneric == null) - { - return; - } - FormAirBomber form = new(); - if (form.ShowDialog() == DialogResult.OK) - { - DrawningObject airplane = new(form.SelectedAirplane); - if (form.SelectedAirplane == null || !(_mapAirplanesCollectionGeneric + airplane)) - { - MessageBox.Show("Не удалось добавить объект"); - } - else - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet(); - } - } - } - /// - /// Удаление объекта - /// - /// - /// - 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("Не удалось удалить объект"); - } - } - /// - /// Вывод набора - /// - /// - /// - private void ButtonShowStorage_Click(object sender, EventArgs e) - { - if (_mapAirplanesCollectionGeneric == null) - { - return; - } - pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet(); - } - /// - /// Вывод карты - /// - /// - /// - private void ButtonShowOnMap_Click(object sender, EventArgs e) - { - if (_mapAirplanesCollectionGeneric == null) - { - return; - } - pictureBox.Image = _mapAirplanesCollectionGeneric.ShowOnMap(); - } - /// - /// Перемещение - /// - /// - /// - private void ButtonMove_Click(object sender, EventArgs e) - { - if (_mapAirplanesCollectionGeneric == null) - { - return; - } - //получаем имя кнопки - string name = ((Button)sender)?.Name ?? string.Empty; - Direction dir = Direction.None; - switch (name) - { - case "buttonUp": - dir = Direction.Up; - break; - case "buttonDown": - dir = Direction.Down; - break; - case "buttonLeft": - dir = Direction.Left; - break; - case "buttonRight": - dir = Direction.Right; - break; - } - pictureBox.Image = _mapAirplanesCollectionGeneric.MoveObject(dir); - } - } -} \ No newline at end of file diff --git a/AirBomber/AirBomber/GeneratorAirplane.cs b/AirBomber/AirBomber/GeneratorAirplane.cs index de39540..8bf1d6e 100644 --- a/AirBomber/AirBomber/GeneratorAirplane.cs +++ b/AirBomber/AirBomber/GeneratorAirplane.cs @@ -31,7 +31,7 @@ namespace AirBomber /// /// тип /// Успешно ли проведена операция - public bool AddTypeOfEntity(T type) + public virtual bool AddTypeOfEntity(T type) { if (NumTypesOfEntity >= typesOfEntity.Length) { @@ -45,7 +45,7 @@ namespace AirBomber /// /// тип /// Успешно ли проведена операция - public bool AddTypeOfEngines(U type) + public virtual bool AddTypeOfEngines(U type) { if (NumTypesOfEngines >= typesOfEngines.Length) { diff --git a/AirBomber/AirBomber/Program.cs b/AirBomber/AirBomber/Program.cs index 76b85fe..f84a0f2 100644 --- a/AirBomber/AirBomber/Program.cs +++ b/AirBomber/AirBomber/Program.cs @@ -11,7 +11,7 @@ namespace AirBomber // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormAirBomber()); + Application.Run(new FormGeneratorAirplane()); } } } \ No newline at end of file -- 2.25.1 From 52c040d55bdbdb5e1de56833567933415b157cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Fri, 30 Sep 2022 23:31:09 +0400 Subject: [PATCH 04/12] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D1=82=D1=8C=20=D1=80=D0=B0=D0=B7=D0=BB=D0=B8=D1=87=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5=20=D1=82=D0=B8=D0=BF=D1=8B=20=D0=B4=D0=B2=D0=B8?= =?UTF-8?q?=D0=B3=D0=B0=D1=82=D0=B5=D0=BB=D1=8F=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormGeneratorAirplane.Designer.cs | 44 +++++++++++++------ AirBomber/AirBomber/FormGeneratorAirplane.cs | 20 +++++++-- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/AirBomber/AirBomber/FormGeneratorAirplane.Designer.cs b/AirBomber/AirBomber/FormGeneratorAirplane.Designer.cs index 5d85129..047d8b1 100644 --- a/AirBomber/AirBomber/FormGeneratorAirplane.Designer.cs +++ b/AirBomber/AirBomber/FormGeneratorAirplane.Designer.cs @@ -28,6 +28,7 @@ /// private void InitializeComponent() { + this.comboTypeEngines = new System.Windows.Forms.ComboBox(); this.groupBoxTools = new System.Windows.Forms.GroupBox(); this.labelSpeed = new System.Windows.Forms.Label(); this.numericSpeed = new System.Windows.Forms.NumericUpDown(); @@ -36,7 +37,7 @@ this.btnGenerateAirplane = new System.Windows.Forms.Button(); this.labelCountEngines = new System.Windows.Forms.Label(); this.numericUpDownEngines = new System.Windows.Forms.NumericUpDown(); - this.btnAddCountEngines = new System.Windows.Forms.Button(); + this.btnAddTypeOfEngines = new System.Windows.Forms.Button(); this.buttonAddTypeOfEntity = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button(); this.buttonRight = new System.Windows.Forms.Button(); @@ -51,8 +52,22 @@ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); this.SuspendLayout(); // + // comboTypeEngines + // + this.comboTypeEngines.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.comboTypeEngines.FormattingEnabled = true; + this.comboTypeEngines.Items.AddRange(new object[] { + "Закругленный", + "Квадратный", + "Стрелка"}); + this.comboTypeEngines.Location = new System.Drawing.Point(17, 155); + this.comboTypeEngines.Name = "comboTypeEngines"; + this.comboTypeEngines.Size = new System.Drawing.Size(175, 23); + this.comboTypeEngines.TabIndex = 9; + // // groupBoxTools // + this.groupBoxTools.Controls.Add(this.comboTypeEngines); this.groupBoxTools.Controls.Add(this.labelSpeed); this.groupBoxTools.Controls.Add(this.numericSpeed); this.groupBoxTools.Controls.Add(this.labelWeight); @@ -60,7 +75,7 @@ this.groupBoxTools.Controls.Add(this.btnGenerateAirplane); this.groupBoxTools.Controls.Add(this.labelCountEngines); this.groupBoxTools.Controls.Add(this.numericUpDownEngines); - this.groupBoxTools.Controls.Add(this.btnAddCountEngines); + this.groupBoxTools.Controls.Add(this.btnAddTypeOfEngines); this.groupBoxTools.Controls.Add(this.buttonAddTypeOfEntity); this.groupBoxTools.Controls.Add(this.buttonDown); this.groupBoxTools.Controls.Add(this.buttonRight); @@ -109,7 +124,7 @@ // // btnGenerateAirplane // - this.btnGenerateAirplane.Location = new System.Drawing.Point(17, 233); + this.btnGenerateAirplane.Location = new System.Drawing.Point(17, 263); this.btnGenerateAirplane.Name = "btnGenerateAirplane"; this.btnGenerateAirplane.Size = new System.Drawing.Size(175, 23); this.btnGenerateAirplane.TabIndex = 15; @@ -120,7 +135,7 @@ // labelCountEngines // this.labelCountEngines.AutoSize = true; - this.labelCountEngines.Location = new System.Drawing.Point(17, 157); + this.labelCountEngines.Location = new System.Drawing.Point(17, 187); this.labelCountEngines.Name = "labelCountEngines"; this.labelCountEngines.Size = new System.Drawing.Size(113, 15); this.labelCountEngines.TabIndex = 14; @@ -128,20 +143,20 @@ // // numericUpDownEngines // - this.numericUpDownEngines.Location = new System.Drawing.Point(136, 155); + this.numericUpDownEngines.Location = new System.Drawing.Point(136, 185); this.numericUpDownEngines.Name = "numericUpDownEngines"; this.numericUpDownEngines.Size = new System.Drawing.Size(56, 23); this.numericUpDownEngines.TabIndex = 13; // - // btnAddCountEngines + // btnAddTypeOfEngines // - this.btnAddCountEngines.Location = new System.Drawing.Point(17, 184); - this.btnAddCountEngines.Name = "btnAddCountEngines"; - this.btnAddCountEngines.Size = new System.Drawing.Size(175, 43); - this.btnAddCountEngines.TabIndex = 12; - this.btnAddCountEngines.Text = "Добавить кол-во двигателей для генерации"; - this.btnAddCountEngines.UseVisualStyleBackColor = true; - this.btnAddCountEngines.Click += new System.EventHandler(this.btnAddCountEngines_Click); + this.btnAddTypeOfEngines.Location = new System.Drawing.Point(17, 214); + this.btnAddTypeOfEngines.Name = "btnAddTypeOfEngines"; + this.btnAddTypeOfEngines.Size = new System.Drawing.Size(175, 43); + this.btnAddTypeOfEngines.TabIndex = 12; + this.btnAddTypeOfEngines.Text = "Добавить тип двигателя и их кол-во для генерации"; + this.btnAddTypeOfEngines.UseVisualStyleBackColor = true; + this.btnAddTypeOfEngines.Click += new System.EventHandler(this.btnAddTypeOfEngines_Click); // // buttonAddTypeOfEntity // @@ -240,6 +255,7 @@ #endregion + private ComboBox comboTypeEngines; private GroupBox groupBoxTools; private PictureBox pictureBox; private ComboBox comboBoxSelectorMap; @@ -247,7 +263,7 @@ private Button buttonRight; private Button buttonLeft; private Button buttonUp; - private Button btnAddCountEngines; + private Button btnAddTypeOfEngines; private Button buttonAddTypeOfEntity; private Label labelCountEngines; private NumericUpDown numericUpDownEngines; diff --git a/AirBomber/AirBomber/FormGeneratorAirplane.cs b/AirBomber/AirBomber/FormGeneratorAirplane.cs index ca4b529..779264f 100644 --- a/AirBomber/AirBomber/FormGeneratorAirplane.cs +++ b/AirBomber/AirBomber/FormGeneratorAirplane.cs @@ -109,11 +109,23 @@ } } - private void btnAddCountEngines_Click(object sender, EventArgs e) + private void btnAddTypeOfEngines_Click(object sender, EventArgs e) { - IAirplaneEngines engines = new DrawningAirplaneEngines(); - engines.CountEngines = (int)numericUpDownEngines.Value; - _generatorAirplane.AddTypeOfEngines(engines); + IAirplaneEngines? typeAirplaneEngines = null; + switch (comboTypeEngines.Text) + { + case "Квадратный": + typeAirplaneEngines = new AirplaneRectEngines(); + break; + case "Стрелка": + typeAirplaneEngines = new AirplaneArrowEngines(); + break; + default: + typeAirplaneEngines = new DrawningAirplaneEngines(); + break; + } + typeAirplaneEngines.CountEngines = (int)numericUpDownEngines.Value; + _generatorAirplane.AddTypeOfEngines(typeAirplaneEngines); } } } \ No newline at end of file -- 2.25.1 From 6a090aee45e6f023f13e48435acfba360c7267c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Sat, 1 Oct 2022 02:59:35 +0400 Subject: [PATCH 05/12] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=B0=D0=BD=D0=B3=D0=B0=D1=80=D1=8B,=20?= =?UTF-8?q?=D0=B8=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BA=20=D0=BD=D0=B8=D0=BC=20=D1=81=D0=B0=D0=BC=D0=BE?= =?UTF-8?q?=D0=BB=D0=B5=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/FormAirBomber.Designer.cs | 14 + AirBomber/AirBomber/FormAirBomber.cs | 6 + .../FormGeneratorAirplane.Designer.cs | 257 ++++++++++++------ AirBomber/AirBomber/FormGeneratorAirplane.cs | 142 ++++++++-- 4 files changed, 307 insertions(+), 112 deletions(-) diff --git a/AirBomber/AirBomber/FormAirBomber.Designer.cs b/AirBomber/AirBomber/FormAirBomber.Designer.cs index e140578..d1c6a5b 100644 --- a/AirBomber/AirBomber/FormAirBomber.Designer.cs +++ b/AirBomber/AirBomber/FormAirBomber.Designer.cs @@ -42,6 +42,7 @@ this.countEngineBox = new System.Windows.Forms.NumericUpDown(); this.labelInformCountEngines = new System.Windows.Forms.Label(); this.comboTypeEngines = new System.Windows.Forms.ComboBox(); + this.buttonSelectAirplane = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit(); this.statusStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.countEngineBox)).BeginInit(); @@ -189,11 +190,23 @@ this.comboTypeEngines.Size = new System.Drawing.Size(143, 23); 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 // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.buttonSelectAirplane); this.Controls.Add(this.comboTypeEngines); this.Controls.Add(this.labelInformCountEngines); this.Controls.Add(this.countEngineBox); @@ -231,5 +244,6 @@ private Label labelInformCountEngines; private ToolStripStatusLabel toolStripStatusCountEngines; private ComboBox comboTypeEngines; + private Button buttonSelectAirplane; } } \ No newline at end of file diff --git a/AirBomber/AirBomber/FormAirBomber.cs b/AirBomber/AirBomber/FormAirBomber.cs index e7c2a25..757fbd9 100644 --- a/AirBomber/AirBomber/FormAirBomber.cs +++ b/AirBomber/AirBomber/FormAirBomber.cs @@ -96,5 +96,11 @@ namespace AirBomber _airplane?.ChangeBorders(pictureBoxCar.Width, pictureBoxCar.Height); Draw(); } + + private void buttonSelectAirplane_Click(object sender, EventArgs e) + { + SelectedAirplane = _airplane; + DialogResult = DialogResult.OK; + } } } \ No newline at end of file diff --git a/AirBomber/AirBomber/FormGeneratorAirplane.Designer.cs b/AirBomber/AirBomber/FormGeneratorAirplane.Designer.cs index 047d8b1..1b78b1f 100644 --- a/AirBomber/AirBomber/FormGeneratorAirplane.Designer.cs +++ b/AirBomber/AirBomber/FormGeneratorAirplane.Designer.cs @@ -30,25 +30,32 @@ { this.comboTypeEngines = new System.Windows.Forms.ComboBox(); 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.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.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.buttonRight = new System.Windows.Forms.Button(); + this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); this.buttonLeft = 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.groupBoxTools.SuspendLayout(); + this.groupBoxGenerate.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericSpeed)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericWeight)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownEngines)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericWeight)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); 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.Size = new System.Drawing.Size(175, 23); this.comboTypeEngines.TabIndex = 9; // // groupBoxTools // - this.groupBoxTools.Controls.Add(this.comboTypeEngines); - this.groupBoxTools.Controls.Add(this.labelSpeed); - this.groupBoxTools.Controls.Add(this.numericSpeed); - this.groupBoxTools.Controls.Add(this.labelWeight); - this.groupBoxTools.Controls.Add(this.numericWeight); - this.groupBoxTools.Controls.Add(this.btnGenerateAirplane); - 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.maskedTextBoxPosition); + this.groupBoxTools.Controls.Add(this.buttonRemoveAirplane); + this.groupBoxTools.Controls.Add(this.buttonShowStorage); + this.groupBoxTools.Controls.Add(this.buttonShowOnMap); + this.groupBoxTools.Controls.Add(this.buttonAddAirplane); + this.groupBoxTools.Controls.Add(this.groupBoxGenerate); this.groupBoxTools.Controls.Add(this.buttonDown); this.groupBoxTools.Controls.Add(this.buttonRight); + this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap); this.groupBoxTools.Controls.Add(this.buttonLeft); this.groupBoxTools.Controls.Add(this.buttonUp); - this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap); this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; this.groupBoxTools.Location = new System.Drawing.Point(811, 0); 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.TabStop = false; this.groupBoxTools.Text = "Инструменты"; // - // labelSpeed + // maskedTextBoxPosition // - this.labelSpeed.AutoSize = true; - this.labelSpeed.Location = new System.Drawing.Point(17, 58); - this.labelSpeed.Name = "labelSpeed"; - this.labelSpeed.Size = new System.Drawing.Size(117, 15); - this.labelSpeed.TabIndex = 19; - this.labelSpeed.Text = "Скорость самолета:"; + this.maskedTextBoxPosition.Location = new System.Drawing.Point(23, 317); + this.maskedTextBoxPosition.Mask = "00"; + this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; + this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23); + this.maskedTextBoxPosition.TabIndex = 22; + this.maskedTextBoxPosition.ValidatingType = typeof(int); // - // numericSpeed + // buttonRemoveAirplane // - this.numericSpeed.Location = new System.Drawing.Point(136, 56); - this.numericSpeed.Name = "numericSpeed"; - this.numericSpeed.Size = new System.Drawing.Size(56, 23); - this.numericSpeed.TabIndex = 18; + this.buttonRemoveAirplane.Location = new System.Drawing.Point(23, 346); + this.buttonRemoveAirplane.Name = "buttonRemoveAirplane"; + this.buttonRemoveAirplane.Size = new System.Drawing.Size(175, 35); + 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.labelWeight.Location = new System.Drawing.Point(17, 83); - this.labelWeight.Name = "labelWeight"; - this.labelWeight.Size = new System.Drawing.Size(100, 15); - this.labelWeight.TabIndex = 17; - this.labelWeight.Text = "Масса самолета:"; + this.buttonShowStorage.Location = new System.Drawing.Point(23, 387); + this.buttonShowStorage.Name = "buttonShowStorage"; + this.buttonShowStorage.Size = new System.Drawing.Size(175, 35); + this.buttonShowStorage.TabIndex = 24; + this.buttonShowStorage.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.numericWeight.Name = "numericWeight"; - this.numericWeight.Size = new System.Drawing.Size(56, 23); - this.numericWeight.TabIndex = 16; + this.buttonShowOnMap.Location = new System.Drawing.Point(23, 424); + this.buttonShowOnMap.Name = "buttonShowOnMap"; + this.buttonShowOnMap.Size = new System.Drawing.Size(175, 35); + 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.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); + this.buttonAddAirplane.Location = new System.Drawing.Point(23, 273); + this.buttonAddAirplane.Name = "buttonAddAirplane"; + this.buttonAddAirplane.Size = new System.Drawing.Size(175, 35); + this.buttonAddAirplane.TabIndex = 21; + this.buttonAddAirplane.Text = "Добавить самолет вручную"; + this.buttonAddAirplane.UseVisualStyleBackColor = true; + this.buttonAddAirplane.Click += new System.EventHandler(this.ButtonAddAirplane_Click); // - // labelCountEngines + // groupBoxGenerate // - this.labelCountEngines.AutoSize = true; - this.labelCountEngines.Location = new System.Drawing.Point(17, 187); - this.labelCountEngines.Name = "labelCountEngines"; - this.labelCountEngines.Size = new System.Drawing.Size(113, 15); - this.labelCountEngines.TabIndex = 14; - this.labelCountEngines.Text = "Кол-во двигателей:"; - // - // numericUpDownEngines - // - this.numericUpDownEngines.Location = new System.Drawing.Point(136, 185); - this.numericUpDownEngines.Name = "numericUpDownEngines"; - this.numericUpDownEngines.Size = new System.Drawing.Size(56, 23); - this.numericUpDownEngines.TabIndex = 13; + this.groupBoxGenerate.Controls.Add(this.comboTypeEngines); + this.groupBoxGenerate.Controls.Add(this.btnAddTypeOfEngines); + this.groupBoxGenerate.Controls.Add(this.labelSpeed); + this.groupBoxGenerate.Controls.Add(this.numericSpeed); + this.groupBoxGenerate.Controls.Add(this.buttonAddTypeOfEntity); + this.groupBoxGenerate.Controls.Add(this.labelWeight); + this.groupBoxGenerate.Controls.Add(this.numericUpDownEngines); + this.groupBoxGenerate.Controls.Add(this.numericWeight); + this.groupBoxGenerate.Controls.Add(this.labelCountEngines); + this.groupBoxGenerate.Controls.Add(this.btnGenerateAirplane); + this.groupBoxGenerate.Location = new System.Drawing.Point(6, 14); + this.groupBoxGenerate.Name = "groupBoxGenerate"; + this.groupBoxGenerate.Size = new System.Drawing.Size(200, 253); + this.groupBoxGenerate.TabIndex = 20; + this.groupBoxGenerate.TabStop = false; + this.groupBoxGenerate.Text = "Генерация"; // // 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.Size = new System.Drawing.Size(175, 43); this.btnAddTypeOfEngines.TabIndex = 12; @@ -158,9 +171,25 @@ this.btnAddTypeOfEngines.UseVisualStyleBackColor = true; 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 // - this.buttonAddTypeOfEntity.Location = new System.Drawing.Point(17, 110); + this.buttonAddTypeOfEntity.Location = new System.Drawing.Point(17, 71); this.buttonAddTypeOfEntity.Name = "buttonAddTypeOfEntity"; this.buttonAddTypeOfEntity.Size = new System.Drawing.Size(175, 39); this.buttonAddTypeOfEntity.TabIndex = 11; @@ -168,12 +197,54 @@ this.buttonAddTypeOfEntity.UseVisualStyleBackColor = true; 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 // 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.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.Size = new System.Drawing.Size(30, 30); 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.BackgroundImage = global::AirBomber.Properties.Resources.arrowRight; 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.Size = new System.Drawing.Size(30, 30); this.buttonRight.TabIndex = 9; 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 // 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.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.Size = new System.Drawing.Size(30, 30); 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.BackgroundImage = global::AirBomber.Properties.Resources.arrowUp; 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.Size = new System.Drawing.Size(30, 30); this.buttonUp.TabIndex = 7; 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 // this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBox.Location = new System.Drawing.Point(0, 0); 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.TabStop = false; // @@ -238,16 +309,18 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); 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.groupBoxTools); this.Name = "FormGeneratorAirplane"; this.Text = "Генератор самолетов"; this.groupBoxTools.ResumeLayout(false); this.groupBoxTools.PerformLayout(); + this.groupBoxGenerate.ResumeLayout(false); + this.groupBoxGenerate.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericSpeed)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericWeight)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownEngines)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericWeight)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); this.ResumeLayout(false); @@ -272,5 +345,11 @@ private NumericUpDown numericSpeed; private Label labelWeight; private NumericUpDown numericWeight; + private GroupBox groupBoxGenerate; + private MaskedTextBox maskedTextBoxPosition; + private Button buttonRemoveAirplane; + private Button buttonShowStorage; + private Button buttonShowOnMap; + private Button buttonAddAirplane; } } \ No newline at end of file diff --git a/AirBomber/AirBomber/FormGeneratorAirplane.cs b/AirBomber/AirBomber/FormGeneratorAirplane.cs index 779264f..4dc0c67 100644 --- a/AirBomber/AirBomber/FormGeneratorAirplane.cs +++ b/AirBomber/AirBomber/FormGeneratorAirplane.cs @@ -1,12 +1,14 @@ -namespace AirBomber +using System.Windows.Forms; + +namespace AirBomber { public partial class FormGeneratorAirplane : Form { /// /// Объект от класса карты с набором объектов /// + private MapWithSetAirplanesGeneric _mapAirplanesCollectionGeneric; private GeneratorAirplane _generatorAirplane; - private IDrawningObject? _airplane; private AbstractMap? _map; /// /// Конструктор @@ -17,24 +19,46 @@ InitializeComponent(); } /// + /// Добавление самолета на карту + /// + /// самолет. + private void AddAirplaneInMap(DrawningObject airplane) + { + if (airplane == null || !(_mapAirplanesCollectionGeneric + airplane)) + { + MessageBox.Show("Не удалось добавить объект"); + } + else + { + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet(); + } + } + /// /// Выбор карты /// /// /// private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) { + AbstractMap map = null; switch (comboBoxSelectorMap.Text) { case "Простая карта": - _map = new SimpleMap(); + map = new SimpleMap(); break; case "Карта со стенами": - _map = new WallMap(); + map = new WallMap(); break; } - if (_map != null) + if (map != null) { - pictureBox.Image = _map.CreateMap(pictureBox.Width, pictureBox.Height, _airplane); + _mapAirplanesCollectionGeneric = new MapWithSetAirplanesGeneric( + pictureBox.Width, pictureBox.Height, map); + } + else + { + _mapAirplanesCollectionGeneric = null; } } /// @@ -64,7 +88,11 @@ } pictureBox.Image = _map?.MoveObject(dir) ?? pictureBox.Image; } - + /// + /// Добавления типа двигателя и его количество в генератор + /// + /// + /// private void buttonAddTypeOfEntity_Click(object sender, EventArgs e) { Random rnd = new(); @@ -82,9 +110,17 @@ $"Цвет: {colorBody.Name}", "Успешно добавлены свойства"); } - + /// + /// Генерация самолета + /// + /// + /// private void btnGenerateAirplane_Click(object sender, EventArgs e) { + if (_mapAirplanesCollectionGeneric == null) + { + return; + } var airplane = _generatorAirplane.Generate(); if (airplane == null) { @@ -92,23 +128,14 @@ , "Генерация самолета"); 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); - } } - + /// + /// Добавления сущности в генератор + /// + /// + /// private void btnAddTypeOfEngines_Click(object sender, EventArgs e) { IAirplaneEngines? typeAirplaneEngines = null; @@ -127,5 +154,74 @@ typeAirplaneEngines.CountEngines = (int)numericUpDownEngines.Value; _generatorAirplane.AddTypeOfEngines(typeAirplaneEngines); } + /// + /// Добавление объекта + /// + /// + /// + 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)); + } + } + /// + /// Удаление объекта + /// + /// + /// + 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("Не удалось удалить объект"); + } + } + /// + /// Вывод набора + /// + /// + /// + private void ButtonShowStorage_Click(object sender, EventArgs e) + { + if (_mapAirplanesCollectionGeneric == null) + { + return; + } + pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet(); + } + /// + /// Вывод карты + /// + /// + /// + private void ButtonShowOnMap_Click(object sender, EventArgs e) + { + if (_mapAirplanesCollectionGeneric == null) + { + return; + } + pictureBox.Image = _mapAirplanesCollectionGeneric.ShowOnMap(); + } } } \ No newline at end of file -- 2.25.1 From e46d5da5911711a732fca25d31274f74e70e163c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Sat, 1 Oct 2022 03:08:40 +0400 Subject: [PATCH 06/12] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B8=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80?= =?UTF-8?q?=D0=BC=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rplane.Designer.cs => FormMapWithSetAirplanes.Designer.cs} | 2 +- .../{FormGeneratorAirplane.cs => FormMapWithSetAirplanes.cs} | 4 ++-- ...ormGeneratorAirplane.resx => FormMapWithSetAirplanes.resx} | 0 AirBomber/AirBomber/Program.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename AirBomber/AirBomber/{FormGeneratorAirplane.Designer.cs => FormMapWithSetAirplanes.Designer.cs} (99%) rename AirBomber/AirBomber/{FormGeneratorAirplane.cs => FormMapWithSetAirplanes.cs} (98%) rename AirBomber/AirBomber/{FormGeneratorAirplane.resx => FormMapWithSetAirplanes.resx} (100%) diff --git a/AirBomber/AirBomber/FormGeneratorAirplane.Designer.cs b/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs similarity index 99% rename from AirBomber/AirBomber/FormGeneratorAirplane.Designer.cs rename to AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs index 1b78b1f..a62de35 100644 --- a/AirBomber/AirBomber/FormGeneratorAirplane.Designer.cs +++ b/AirBomber/AirBomber/FormMapWithSetAirplanes.Designer.cs @@ -1,6 +1,6 @@ namespace AirBomber { - partial class FormGeneratorAirplane + partial class FormMapWithSetAirplanes { /// /// Required designer variable. diff --git a/AirBomber/AirBomber/FormGeneratorAirplane.cs b/AirBomber/AirBomber/FormMapWithSetAirplanes.cs similarity index 98% rename from AirBomber/AirBomber/FormGeneratorAirplane.cs rename to AirBomber/AirBomber/FormMapWithSetAirplanes.cs index 4dc0c67..7b45a8d 100644 --- a/AirBomber/AirBomber/FormGeneratorAirplane.cs +++ b/AirBomber/AirBomber/FormMapWithSetAirplanes.cs @@ -2,7 +2,7 @@ namespace AirBomber { - public partial class FormGeneratorAirplane : Form + public partial class FormMapWithSetAirplanes : Form { /// /// Объект от класса карты с набором объектов @@ -13,7 +13,7 @@ namespace AirBomber /// /// Конструктор /// - public FormGeneratorAirplane() + public FormMapWithSetAirplanes() { _generatorAirplane = new(100, 100); InitializeComponent(); diff --git a/AirBomber/AirBomber/FormGeneratorAirplane.resx b/AirBomber/AirBomber/FormMapWithSetAirplanes.resx similarity index 100% rename from AirBomber/AirBomber/FormGeneratorAirplane.resx rename to AirBomber/AirBomber/FormMapWithSetAirplanes.resx diff --git a/AirBomber/AirBomber/Program.cs b/AirBomber/AirBomber/Program.cs index f84a0f2..5325330 100644 --- a/AirBomber/AirBomber/Program.cs +++ b/AirBomber/AirBomber/Program.cs @@ -11,7 +11,7 @@ namespace AirBomber // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormGeneratorAirplane()); + Application.Run(new FormMapWithSetAirplanes()); } } } \ No newline at end of file -- 2.25.1 From 5aa2c32f02b8d68fae5d136188bf4a948d0f72d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Sat, 1 Oct 2022 03:22:42 +0400 Subject: [PATCH 07/12] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BD=D0=B5=D0=BD=D1=83=D0=B6=D0=BD=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=80=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/FormMapWithSetAirplanes.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AirBomber/AirBomber/FormMapWithSetAirplanes.cs b/AirBomber/AirBomber/FormMapWithSetAirplanes.cs index 7b45a8d..3082e34 100644 --- a/AirBomber/AirBomber/FormMapWithSetAirplanes.cs +++ b/AirBomber/AirBomber/FormMapWithSetAirplanes.cs @@ -9,7 +9,6 @@ namespace AirBomber /// private MapWithSetAirplanesGeneric _mapAirplanesCollectionGeneric; private GeneratorAirplane _generatorAirplane; - private AbstractMap? _map; /// /// Конструктор /// @@ -86,7 +85,7 @@ namespace AirBomber dir = Direction.Right; break; } - pictureBox.Image = _map?.MoveObject(dir) ?? pictureBox.Image; + pictureBox.Image = _mapAirplanesCollectionGeneric?.MoveObject(dir) ?? pictureBox.Image; } /// /// Добавления типа двигателя и его количество в генератор -- 2.25.1 From a9ba63977f37cab18512a5b1ca2c4303681250e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Sat, 1 Oct 2022 05:29:09 +0400 Subject: [PATCH 08/12] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B8=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/AbstractMap.cs | 2 +- AirBomber/AirBomber/DrawningObject.cs | 2 +- AirBomber/AirBomber/IDrawningObject.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AirBomber/AirBomber/AbstractMap.cs b/AirBomber/AirBomber/AbstractMap.cs index 78425d8..8cc655f 100644 --- a/AirBomber/AirBomber/AbstractMap.cs +++ b/AirBomber/AirBomber/AbstractMap.cs @@ -162,7 +162,7 @@ namespace AirBomber DrawMap(); if (_staticBitMap != null) gr.DrawImage(_staticBitMap, 0, 0); - _drawningObject.DrawningObject(gr); + _drawningObject.DrawObject(gr); return bmp; } diff --git a/AirBomber/AirBomber/DrawningObject.cs b/AirBomber/AirBomber/DrawningObject.cs index 3b12ec9..e1eedfb 100644 --- a/AirBomber/AirBomber/DrawningObject.cs +++ b/AirBomber/AirBomber/DrawningObject.cs @@ -32,7 +32,7 @@ namespace AirBomber _airplane.SetPosition(x, y, width, height); } - void IDrawningObject.DrawningObject(Graphics g) + public void DrawObject(Graphics g) { _airplane.DrawTransport(g); } diff --git a/AirBomber/AirBomber/IDrawningObject.cs b/AirBomber/AirBomber/IDrawningObject.cs index 6077012..a2afce7 100644 --- a/AirBomber/AirBomber/IDrawningObject.cs +++ b/AirBomber/AirBomber/IDrawningObject.cs @@ -33,7 +33,7 @@ namespace AirBomber /// Отрисовка объекта /// /// - void DrawningObject(Graphics g); + void DrawObject(Graphics g); /// /// Получение текущей позиции объекта /// -- 2.25.1 From 552cc1f93fef5e70a836310a7498ec6d834fc634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Sat, 1 Oct 2022 05:53:37 +0400 Subject: [PATCH 09/12] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B8=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=20=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs index f1b5c96..cc2bb2f 100644 --- a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs +++ b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs @@ -177,7 +177,7 @@ namespace AirBomber { var airplane = _setAirplanes.Get(i); airplane?.SetObject(maxLeft - i % countInLine * _placeSizeWidth, i / countInLine * _placeSizeHeight + 3, _pictureWidth, _pictureHeight); - airplane?.DrawningObject(g); + airplane?.DrawObject(g); } } } -- 2.25.1 From 3a5fa25ce4a39e7c4de5c7a4c2a9ee513a079d86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Wed, 5 Oct 2022 01:15:54 +0400 Subject: [PATCH 10/12] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BE=D1=82=D1=80=D0=B8=D1=81=D0=BE=D0=B2=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=83=D1=87=D0=B0=D1=81=D1=82=D0=BA=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=80=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/SimpleMap.cs | 4 ++-- AirBomber/AirBomber/WallMap.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AirBomber/AirBomber/SimpleMap.cs b/AirBomber/AirBomber/SimpleMap.cs index 63bb878..f5f9a69 100644 --- a/AirBomber/AirBomber/SimpleMap.cs +++ b/AirBomber/AirBomber/SimpleMap.cs @@ -16,11 +16,11 @@ protected override void DrawBarrierPart(Graphics g, int i, int j) { - g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1)); + g.FillRectangle(barrierColor, i * _size_x, j * _size_y, _size_x, _size_y); } protected override void DrawRoadPart(Graphics g, int i, int j) { - g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1)); + g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _size_y); } protected override void GenerateMap() { diff --git a/AirBomber/AirBomber/WallMap.cs b/AirBomber/AirBomber/WallMap.cs index 8cb7989..59273aa 100644 --- a/AirBomber/AirBomber/WallMap.cs +++ b/AirBomber/AirBomber/WallMap.cs @@ -31,7 +31,7 @@ namespace AirBomber protected override void DrawRoadPart(Graphics g, int i, int j) { - g.FillRectangle(roadColor, i * _size_x, j * _size_y, (i + 1) * _size_x, (j + 1) * _size_y); + g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _size_y); } protected override void GenerateMap() -- 2.25.1 From ca0967fdcec9b61101ade006bb3388402a0b3823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Thu, 13 Oct 2022 14:57:11 +0400 Subject: [PATCH 11/12] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=20=D1=82=D0=B8=D0=BF=20=D0=B2=D0=BE=D0=B7?= =?UTF-8?q?=D0=B2=D1=80=D0=B0=D1=89=D0=B0=D0=B5=D0=BC=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AirBomber/MapWithSetAirplanesGeneric.cs | 8 +++---- AirBomber/AirBomber/SetAirplanesGeneric.cs | 23 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs index cc2bb2f..11636db 100644 --- a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs +++ b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs @@ -54,8 +54,8 @@ namespace AirBomber /// /// /// - /// - public static bool operator +(MapWithSetAirplanesGeneric map, T airplane) + /// Возвращает позицию вставленого объекта либо -1, если не получилось его добавить + public static int operator +(MapWithSetAirplanesGeneric map, T airplane) { return map._setAirplanes.Insert(airplane); } @@ -64,8 +64,8 @@ namespace AirBomber /// /// /// - /// - public static bool operator -(MapWithSetAirplanesGeneric map, int position) + /// Возвращает удаленный объект, либо null если его не удалось удалить + public static T operator -(MapWithSetAirplanesGeneric map, int position) { return map._setAirplanes.Remove(position); } diff --git a/AirBomber/AirBomber/SetAirplanesGeneric.cs b/AirBomber/AirBomber/SetAirplanesGeneric.cs index 178d798..a3b0011 100644 --- a/AirBomber/AirBomber/SetAirplanesGeneric.cs +++ b/AirBomber/AirBomber/SetAirplanesGeneric.cs @@ -33,8 +33,8 @@ namespace AirBomber /// Добавление объекта в набор /// /// Добавляемый самолет - /// - public bool Insert(T airplane) + /// Возвращает позицию вставленого объекта либо -1, если не получилось его добавить + public int Insert(T airplane) { return Insert(airplane, 0); } @@ -48,8 +48,8 @@ namespace AirBomber /// /// Добавляемый самолет /// Позиция - /// - public bool Insert(T airplane, int position) + /// Возвращает позицию вставленого объекта либо -1, если не получилось его добавить + public int Insert(T airplane, int position) { int positionNullElement = position; while (Get(positionNullElement) != null) @@ -57,9 +57,9 @@ namespace AirBomber positionNullElement++; } // Если изначальная позиция была некорректной или пустых элементов справа не оказалось возвращаем false - if (!isCorrectPosition(positionNullElement)) + if (!isCorrectPosition(positionNullElement)) { - return false; + return -1; } while (positionNullElement != position) // Смещение вправо { @@ -67,19 +67,20 @@ namespace AirBomber positionNullElement--; } _places[position] = airplane; - return true; + return position; } /// /// Удаление объекта из набора с конкретной позиции /// /// - /// - public bool Remove(int position) + /// Возвращает удаленный объект, либо null если его не удалось удалить + public T Remove(int position) { if (!isCorrectPosition(position)) - return false; + return null; + var result = _places[position]; _places[position] = null; - return true; + return result; } /// /// Получение объекта из набора по позиции -- 2.25.1 From a20390f707fc4edbaed42a7be72e25c81461efb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Thu, 13 Oct 2022 15:00:02 +0400 Subject: [PATCH 12/12] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0?= =?UTF-8?q?=20=D1=81=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=D0=BC=20/=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=D0=BC=20=D1=81=D0=B0=D0=BC=D0=BE=D0=BB=D0=B5=D1=82?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/FormMapWithSetAirplanes.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AirBomber/AirBomber/FormMapWithSetAirplanes.cs b/AirBomber/AirBomber/FormMapWithSetAirplanes.cs index 3082e34..722c7cb 100644 --- a/AirBomber/AirBomber/FormMapWithSetAirplanes.cs +++ b/AirBomber/AirBomber/FormMapWithSetAirplanes.cs @@ -23,7 +23,7 @@ namespace AirBomber /// самолет. private void AddAirplaneInMap(DrawningObject airplane) { - if (airplane == null || !(_mapAirplanesCollectionGeneric + airplane)) + if (airplane == null || (_mapAirplanesCollectionGeneric + airplane) == -1) { MessageBox.Show("Не удалось добавить объект"); } @@ -186,7 +186,7 @@ namespace AirBomber return; } int pos = Convert.ToInt32(maskedTextBoxPosition.Text); - if (_mapAirplanesCollectionGeneric - pos) + if (_mapAirplanesCollectionGeneric - pos != null) { MessageBox.Show("Объект удален"); pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet(); -- 2.25.1