diff --git a/AirFighter/AirFighter/Direction.cs b/AirFighter/AirFighter/Direction.cs
index b4601d4..9e743fe 100644
--- a/AirFighter/AirFighter/Direction.cs
+++ b/AirFighter/AirFighter/Direction.cs
@@ -9,7 +9,7 @@ namespace AirFighter
///
/// Направление перемещения
///
- internal enum Direction
+ public enum Direction
{
None = 0,
Up = 1,
diff --git a/AirFighter/AirFighter/DrawningAirFighter.cs b/AirFighter/AirFighter/DrawningAirFighter.cs
index 12f3ab9..1675837 100644
--- a/AirFighter/AirFighter/DrawningAirFighter.cs
+++ b/AirFighter/AirFighter/DrawningAirFighter.cs
@@ -9,7 +9,7 @@ namespace AirFighter
///
/// Класс отвечающий за прорисовку и перемещение объекта-сущности
///
- internal class DrawningAirFighter
+ public class DrawningAirFighter
{
///
/// Класс-сущность
diff --git a/AirFighter/AirFighter/EntityAirFighter.cs b/AirFighter/AirFighter/EntityAirFighter.cs
index 0aa3e36..688c378 100644
--- a/AirFighter/AirFighter/EntityAirFighter.cs
+++ b/AirFighter/AirFighter/EntityAirFighter.cs
@@ -9,7 +9,7 @@ namespace AirFighter
///
/// Класс-сущность "Военный самолет"
///
- internal class EntityAirFighter
+ public class EntityAirFighter
{
///
/// Скорость
diff --git a/AirFighter/AirFighter/FormAirFighter.Designer.cs b/AirFighter/AirFighter/FormAirFighter.Designer.cs
index b5e7eda..e1176f5 100644
--- a/AirFighter/AirFighter/FormAirFighter.Designer.cs
+++ b/AirFighter/AirFighter/FormAirFighter.Designer.cs
@@ -39,6 +39,7 @@
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonUpgrade = new System.Windows.Forms.Button();
+ this.buttonSelectAirFighter = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirFighter)).BeginInit();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
@@ -154,11 +155,22 @@
this.buttonUpgrade.UseVisualStyleBackColor = true;
this.buttonUpgrade.Click += new System.EventHandler(this.ButtonUpgrade_Click);
//
+ // buttonSelectAirFighter
+ //
+ this.buttonSelectAirFighter.Location = new System.Drawing.Point(565, 379);
+ this.buttonSelectAirFighter.Name = "buttonSelectAirFighter";
+ this.buttonSelectAirFighter.Size = new System.Drawing.Size(94, 29);
+ this.buttonSelectAirFighter.TabIndex = 8;
+ this.buttonSelectAirFighter.Text = "Выбрать";
+ this.buttonSelectAirFighter.UseVisualStyleBackColor = true;
+ this.buttonSelectAirFighter.Click += new System.EventHandler(this.ButtonSelectAirFighter_Click);
+ //
// FormAirFighter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonSelectAirFighter);
this.Controls.Add(this.buttonUpgrade);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonLeft);
@@ -190,5 +202,6 @@
private Button buttonLeft;
private Button buttonRight;
private Button buttonUpgrade;
+ private Button buttonSelectAirFighter;
}
}
\ No newline at end of file
diff --git a/AirFighter/AirFighter/FormAirFighter.cs b/AirFighter/AirFighter/FormAirFighter.cs
index 60b932e..d4ecf43 100644
--- a/AirFighter/AirFighter/FormAirFighter.cs
+++ b/AirFighter/AirFighter/FormAirFighter.cs
@@ -3,6 +3,10 @@ namespace AirFighter
public partial class FormAirFighter : Form
{
private DrawningAirFighter _airFighter;
+ ///
+ ///
+ ///
+ public DrawningAirFighter SelectedAirFighter { get ; private set; }
public FormAirFighter()
{
InitializeComponent();
@@ -88,5 +92,11 @@ namespace AirFighter
SetData();
Draw();
}
+
+ private void ButtonSelectAirFighter_Click(object sender, EventArgs e)
+ {
+ SelectedAirFighter = _airFighter;
+ DialogResult = DialogResult.OK;
+ }
}
}
\ No newline at end of file
diff --git a/AirFighter/AirFighter/FormMap.Designer.cs b/AirFighter/AirFighter/FormMap.Designer.cs
deleted file mode 100644
index 26cb86a..0000000
--- a/AirFighter/AirFighter/FormMap.Designer.cs
+++ /dev/null
@@ -1,209 +0,0 @@
-namespace AirFighter
-{
- 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.pictureBoxAirFighter = 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.buttonDown = new System.Windows.Forms.Button();
- this.buttonLeft = new System.Windows.Forms.Button();
- this.buttonRight = new System.Windows.Forms.Button();
- this.buttonUpgrade = new System.Windows.Forms.Button();
- this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirFighter)).BeginInit();
- this.statusStrip.SuspendLayout();
- this.SuspendLayout();
- //
- // pictureBoxAirFighter
- //
- this.pictureBoxAirFighter.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pictureBoxAirFighter.Location = new System.Drawing.Point(0, 0);
- this.pictureBoxAirFighter.Name = "pictureBoxAirFighter";
- this.pictureBoxAirFighter.Size = new System.Drawing.Size(800, 424);
- this.pictureBoxAirFighter.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
- this.pictureBoxAirFighter.TabIndex = 0;
- this.pictureBoxAirFighter.TabStop = false;
- //
- // statusStrip
- //
- this.statusStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
- this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.toolStripStatusLabelSpeed,
- this.toolStripStatusLabelWeight,
- this.toolStripStatusLabelBodyColor});
- this.statusStrip.Location = new System.Drawing.Point(0, 424);
- this.statusStrip.Name = "statusStrip";
- this.statusStrip.Size = new System.Drawing.Size(800, 26);
- this.statusStrip.TabIndex = 1;
- //
- // toolStripStatusLabelSpeed
- //
- this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
- this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(80, 20);
- this.toolStripStatusLabelSpeed.Text = "Скорость: ";
- //
- // toolStripStatusLabelWeight
- //
- this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
- this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(40, 20);
- this.toolStripStatusLabelWeight.Text = "Вес: ";
- //
- // toolStripStatusLabelBodyColor
- //
- this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
- this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(49, 20);
- 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(39, 378);
- this.buttonCreate.Name = "buttonCreate";
- this.buttonCreate.Size = new System.Drawing.Size(94, 29);
- 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::AirFighter.Properties.Resources.Up;
- this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonUp.Location = new System.Drawing.Point(722, 341);
- 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);
- //
- // buttonDown
- //
- this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonDown.BackgroundImage = global::AirFighter.Properties.Resources.Down;
- this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonDown.Location = new System.Drawing.Point(722, 377);
- this.buttonDown.Name = "buttonDown";
- this.buttonDown.Size = new System.Drawing.Size(30, 30);
- this.buttonDown.TabIndex = 4;
- this.buttonDown.UseVisualStyleBackColor = true;
- this.buttonDown.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::AirFighter.Properties.Resources.Left;
- this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonLeft.Location = new System.Drawing.Point(686, 377);
- this.buttonLeft.Name = "buttonLeft";
- this.buttonLeft.Size = new System.Drawing.Size(30, 30);
- this.buttonLeft.TabIndex = 5;
- 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::AirFighter.Properties.Resources.Right;
- this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonRight.Location = new System.Drawing.Point(758, 378);
- this.buttonRight.Name = "buttonRight";
- this.buttonRight.Size = new System.Drawing.Size(30, 30);
- this.buttonRight.TabIndex = 6;
- this.buttonRight.UseVisualStyleBackColor = true;
- this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
- //
- // buttonUpgrade
- //
- this.buttonUpgrade.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.buttonUpgrade.Location = new System.Drawing.Point(148, 379);
- this.buttonUpgrade.Name = "buttonUpgrade";
- this.buttonUpgrade.Size = new System.Drawing.Size(127, 29);
- this.buttonUpgrade.TabIndex = 7;
- this.buttonUpgrade.Text = "Модификация";
- this.buttonUpgrade.UseVisualStyleBackColor = true;
- this.buttonUpgrade.Click += new System.EventHandler(this.ButtonUpgrade_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(151, 28);
- this.comboBoxSelectorMap.TabIndex = 8;
- this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
- //
- // FormMap
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Controls.Add(this.comboBoxSelectorMap);
- this.Controls.Add(this.buttonUpgrade);
- this.Controls.Add(this.buttonRight);
- this.Controls.Add(this.buttonLeft);
- this.Controls.Add(this.buttonDown);
- this.Controls.Add(this.buttonUp);
- this.Controls.Add(this.buttonCreate);
- this.Controls.Add(this.pictureBoxAirFighter);
- this.Controls.Add(this.statusStrip);
- this.Name = "FormMap";
- this.Text = "Карта";
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirFighter)).EndInit();
- this.statusStrip.ResumeLayout(false);
- this.statusStrip.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private PictureBox pictureBoxAirFighter;
- private StatusStrip statusStrip;
- private ToolStripStatusLabel toolStripStatusLabelSpeed;
- private ToolStripStatusLabel toolStripStatusLabelWeight;
- private ToolStripStatusLabel toolStripStatusLabelBodyColor;
- private Button buttonCreate;
- private Button buttonUp;
- private Button buttonDown;
- private Button buttonLeft;
- private Button buttonRight;
- private Button buttonUpgrade;
- private ComboBox comboBoxSelectorMap;
- }
-}
\ No newline at end of file
diff --git a/AirFighter/AirFighter/FormMap.cs b/AirFighter/AirFighter/FormMap.cs
deleted file mode 100644
index 551313c..0000000
--- a/AirFighter/AirFighter/FormMap.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace AirFighter
-{
- public partial class FormMap : Form
- {
- private AbstractMap _abstractMap;
- public FormMap()
- {
- InitializeComponent();
- _abstractMap = new SimpleMap();
- comboBoxSelectorMap.SelectedIndex = 0;
- }
- ///
- /// Заполнение информации по объекту
- ///
- private void SetData(DrawningAirFighter airFighter)
- {
-
- toolStripStatusLabelSpeed.Text = $"Скорость: {airFighter.AirFighter?.Speed}";
- toolStripStatusLabelWeight.Text = $"Вес: {airFighter.AirFighter?.Weight}";
- toolStripStatusLabelBodyColor.Text = $"Цвет: {airFighter.AirFighter?.BodyColor}";
- pictureBoxAirFighter.Image = _abstractMap.CreateMap(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height,
- new DrawningObjectAirFighter(airFighter));
- }
- ///
- /// Обработка нажатия кнопки "Создать"
- ///
- ///
- ///
- private void ButtonCreate_Click(object sender, EventArgs e)
- {
-
- Random rnd = new Random();
- var _airFighter = new DrawningAirFighter(rnd.Next(200, 500), rnd.Next(2000, 5000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- SetData(_airFighter);
- }
-
- ///
- /// Обработка нажатий кнопок перемещения
- ///
- ///
- ///
- 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;
- }
- pictureBoxAirFighter.Image = _abstractMap?.MoveObject(dir);
- }
- ///
- /// Обработка нажатия кнопки "Модификация"
- ///
- ///
- ///
- private void ButtonUpgrade_Click(object sender, EventArgs e)
- {
- Random rnd = new();
- var _airFighter = new DrawningUpgradeAirFighter(rnd.Next(300, 600), rnd.Next(2000, 5000), 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(_airFighter);
- }
- ///
- /// Изменение карты
- ///
- ///
- ///
- private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
- {
- switch (comboBoxSelectorMap.Text)
- {
- case "Простая карта":
- _abstractMap = new SimpleMap();
- break;
- case "Карта шторма":
- _abstractMap = new StormMap();
- break;
- }
- }
- }
-}
diff --git a/AirFighter/AirFighter/FormMapWithSetAirFighters.Designer.cs b/AirFighter/AirFighter/FormMapWithSetAirFighters.Designer.cs
new file mode 100644
index 0000000..d4ce11e
--- /dev/null
+++ b/AirFighter/AirFighter/FormMapWithSetAirFighters.Designer.cs
@@ -0,0 +1,212 @@
+namespace AirFighter
+{
+ partial class FormMapWithSetAirFighters
+ {
+ ///
+ /// 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.groupBox = new System.Windows.Forms.GroupBox();
+ this.buttonUp = new System.Windows.Forms.Button();
+ this.buttonDown = new System.Windows.Forms.Button();
+ this.buttonLeft = new System.Windows.Forms.Button();
+ this.buttonRight = new System.Windows.Forms.Button();
+ this.buttonShowOnMap = new System.Windows.Forms.Button();
+ this.buttonShowStorage = new System.Windows.Forms.Button();
+ this.buttonRemoveAirFighter = new System.Windows.Forms.Button();
+ this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
+ this.buttonAddAirFighter = new System.Windows.Forms.Button();
+ this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
+ this.pictureBox = new System.Windows.Forms.PictureBox();
+ this.groupBox.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
+ this.SuspendLayout();
+ //
+ // groupBox
+ //
+ this.groupBox.Controls.Add(this.buttonUp);
+ this.groupBox.Controls.Add(this.buttonDown);
+ this.groupBox.Controls.Add(this.buttonLeft);
+ this.groupBox.Controls.Add(this.buttonRight);
+ this.groupBox.Controls.Add(this.buttonShowOnMap);
+ this.groupBox.Controls.Add(this.buttonShowStorage);
+ this.groupBox.Controls.Add(this.buttonRemoveAirFighter);
+ this.groupBox.Controls.Add(this.maskedTextBoxPosition);
+ this.groupBox.Controls.Add(this.buttonAddAirFighter);
+ this.groupBox.Controls.Add(this.comboBoxSelectorMap);
+ this.groupBox.Dock = System.Windows.Forms.DockStyle.Right;
+ this.groupBox.Location = new System.Drawing.Point(550, 0);
+ this.groupBox.Name = "groupBox";
+ this.groupBox.Size = new System.Drawing.Size(250, 450);
+ this.groupBox.TabIndex = 0;
+ this.groupBox.TabStop = false;
+ this.groupBox.Text = "Инструменты";
+ //
+ // buttonUp
+ //
+ this.buttonUp.BackgroundImage = global::AirFighter.Properties.Resources.Up;
+ this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonUp.Location = new System.Drawing.Point(135, 370);
+ this.buttonUp.Name = "buttonUp";
+ this.buttonUp.Size = new System.Drawing.Size(30, 30);
+ this.buttonUp.TabIndex = 2;
+ this.buttonUp.UseVisualStyleBackColor = true;
+ this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonDown
+ //
+ this.buttonDown.BackgroundImage = global::AirFighter.Properties.Resources.Down;
+ this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonDown.Location = new System.Drawing.Point(135, 408);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(30, 30);
+ this.buttonDown.TabIndex = 3;
+ this.buttonDown.UseVisualStyleBackColor = true;
+ this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonLeft
+ //
+ this.buttonLeft.BackgroundImage = global::AirFighter.Properties.Resources.Left;
+ this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonLeft.Location = new System.Drawing.Point(99, 408);
+ 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.BackgroundImage = global::AirFighter.Properties.Resources.Right;
+ this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonRight.Location = new System.Drawing.Point(171, 408);
+ 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);
+ //
+ // buttonShowOnMap
+ //
+ this.buttonShowOnMap.Location = new System.Drawing.Point(28, 296);
+ this.buttonShowOnMap.Name = "buttonShowOnMap";
+ this.buttonShowOnMap.Size = new System.Drawing.Size(210, 29);
+ this.buttonShowOnMap.TabIndex = 5;
+ this.buttonShowOnMap.Text = "Посмотреть карту";
+ this.buttonShowOnMap.UseVisualStyleBackColor = true;
+ this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
+ //
+ // buttonShowStorage
+ //
+ this.buttonShowStorage.Location = new System.Drawing.Point(28, 252);
+ this.buttonShowStorage.Name = "buttonShowStorage";
+ this.buttonShowStorage.Size = new System.Drawing.Size(210, 29);
+ this.buttonShowStorage.TabIndex = 4;
+ this.buttonShowStorage.Text = "Посмотреть хранилище";
+ this.buttonShowStorage.UseVisualStyleBackColor = true;
+ this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
+ //
+ // buttonRemoveAirFighter
+ //
+ this.buttonRemoveAirFighter.Location = new System.Drawing.Point(28, 194);
+ this.buttonRemoveAirFighter.Name = "buttonRemoveAirFighter";
+ this.buttonRemoveAirFighter.Size = new System.Drawing.Size(210, 29);
+ this.buttonRemoveAirFighter.TabIndex = 3;
+ this.buttonRemoveAirFighter.Text = "Удалить самолет";
+ this.buttonRemoveAirFighter.UseVisualStyleBackColor = true;
+ this.buttonRemoveAirFighter.Click += new System.EventHandler(this.ButtonRemoveAirFighter_Click);
+ //
+ // maskedTextBoxPosition
+ //
+ this.maskedTextBoxPosition.Location = new System.Drawing.Point(28, 145);
+ this.maskedTextBoxPosition.Mask = "00";
+ this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ this.maskedTextBoxPosition.Size = new System.Drawing.Size(210, 27);
+ this.maskedTextBoxPosition.TabIndex = 2;
+ //
+ // buttonAddAirFighter
+ //
+ this.buttonAddAirFighter.Location = new System.Drawing.Point(28, 96);
+ this.buttonAddAirFighter.Name = "buttonAddAirFighter";
+ this.buttonAddAirFighter.Size = new System.Drawing.Size(210, 29);
+ this.buttonAddAirFighter.TabIndex = 1;
+ this.buttonAddAirFighter.Text = "Добавить самолет";
+ this.buttonAddAirFighter.UseVisualStyleBackColor = true;
+ this.buttonAddAirFighter.Click += new System.EventHandler(this.ButtonAddAirFighter_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(28, 45);
+ this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
+ this.comboBoxSelectorMap.Size = new System.Drawing.Size(210, 28);
+ 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(550, 450);
+ this.pictureBox.TabIndex = 1;
+ this.pictureBox.TabStop = false;
+ //
+ // FormMapWithSetAirFighters
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.pictureBox);
+ this.Controls.Add(this.groupBox);
+ this.Name = "FormMapWithSetAirFighters";
+ this.Text = "FormMapWithSetAirFighters";
+ this.groupBox.ResumeLayout(false);
+ this.groupBox.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private GroupBox groupBox;
+ private Button buttonShowOnMap;
+ private Button buttonShowStorage;
+ private Button buttonRemoveAirFighter;
+ private MaskedTextBox maskedTextBoxPosition;
+ private Button buttonAddAirFighter;
+ private ComboBox comboBoxSelectorMap;
+ private PictureBox pictureBox;
+ private Button buttonUp;
+ private Button buttonDown;
+ private Button buttonLeft;
+ private Button buttonRight;
+ }
+}
\ No newline at end of file
diff --git a/AirFighter/AirFighter/FormMapWithSetAirFighters.cs b/AirFighter/AirFighter/FormMapWithSetAirFighters.cs
new file mode 100644
index 0000000..0694cf9
--- /dev/null
+++ b/AirFighter/AirFighter/FormMapWithSetAirFighters.cs
@@ -0,0 +1,166 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using static System.Windows.Forms.DataFormats;
+
+namespace AirFighter
+{
+ public partial class FormMapWithSetAirFighters : Form
+ {
+ ///
+ /// Объект от класса карты с набором объектов
+ ///
+ private MapWithSetAirFightersGeneric _mapAirFightersCollectionGeneric;
+ ///
+ /// Конструктор
+ public FormMapWithSetAirFighters()
+ {
+ InitializeComponent();
+ }
+ ///
+ /// Выбор карты
+ ///
+ ///
+ ///
+ private void ComboBoxSelectorMap_SelectedIndexChanged(object sender,
+ EventArgs e)
+ {
+ AbstractMap map = null;
+ switch (comboBoxSelectorMap.Text)
+ {
+ case "Простая карта":
+ map = new SimpleMap();
+ break;
+ case "Карта шторма":
+ map = new StormMap();
+ break;
+ }
+ if (map != null)
+ {
+ _mapAirFightersCollectionGeneric = new
+ MapWithSetAirFightersGeneric(
+ pictureBox.Width, pictureBox.Height, map);
+ }
+ else
+ {
+ _mapAirFightersCollectionGeneric = null;
+ }
+ }
+ ///
+ /// Добавление объекта
+ ///
+ ///
+ ///
+ private void ButtonAddAirFighter_Click(object sender, EventArgs e)
+ {
+ if (_mapAirFightersCollectionGeneric == null)
+ {
+ return;
+ }
+ FormAirFighter form = new();
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ DrawningObjectAirFighter airFighter = new(form.SelectedAirFighter);
+ if ((_mapAirFightersCollectionGeneric + airFighter) == 0)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _mapAirFightersCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
+ }
+ ///
+ /// Удаление объекта
+ ///
+ ///
+ ///
+ private void ButtonRemoveAirFighter_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 ((_mapAirFightersCollectionGeneric - pos) != null)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBox.Image = _mapAirFightersCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+ ///
+ /// Вывод набора
+ ///
+ ///
+ ///
+ private void ButtonShowStorage_Click(object sender, EventArgs e)
+ {
+ if (_mapAirFightersCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapAirFightersCollectionGeneric.ShowSet();
+ }
+ ///
+ /// Вывод карты
+ ///
+ ///
+ ///
+ private void ButtonShowOnMap_Click(object sender, EventArgs e)
+ {
+ if (_mapAirFightersCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapAirFightersCollectionGeneric.ShowOnMap();
+ }
+ ///
+ /// Перемещение
+ ///
+ ///
+ ///
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ if (_mapAirFightersCollectionGeneric == 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 = _mapAirFightersCollectionGeneric.MoveObject(dir);
+ }
+ }
+}
diff --git a/AirFighter/AirFighter/FormMap.resx b/AirFighter/AirFighter/FormMapWithSetAirFighters.resx
similarity index 93%
rename from AirFighter/AirFighter/FormMap.resx
rename to AirFighter/AirFighter/FormMapWithSetAirFighters.resx
index 2c0949d..f298a7b 100644
--- a/AirFighter/AirFighter/FormMap.resx
+++ b/AirFighter/AirFighter/FormMapWithSetAirFighters.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/AirFighter/AirFighter/MapWithSetAirFightersGeneric.cs b/AirFighter/AirFighter/MapWithSetAirFightersGeneric.cs
index ce9e242..48f17d6 100644
--- a/AirFighter/AirFighter/MapWithSetAirFightersGeneric.cs
+++ b/AirFighter/AirFighter/MapWithSetAirFightersGeneric.cs
@@ -176,14 +176,12 @@ namespace AirFighter
///
private void DrawAirFighters(Graphics g)
{
-
- // TODO установка позиции
int currentWidth = _pictureWidth / _placeSizeWidth - 1;
int currentHeight = _pictureHeight / _placeSizeHeight - 1;
for (int i = 0; i < _setAirFighters.Count; i++)
{
- _setAirFighters.Get(i).SetObject(currentWidth * _placeSizeWidth, currentHeight * _placeSizeHeight, _pictureWidth, _pictureHeight);
+ _setAirFighters.Get(i)?.SetObject(currentWidth * _placeSizeWidth, currentHeight * _placeSizeHeight, _pictureWidth, _pictureHeight);
_setAirFighters.Get(i)?.DrawningObject(g);
if(currentWidth > 0)
diff --git a/AirFighter/AirFighter/Program.cs b/AirFighter/AirFighter/Program.cs
index b613151..f61e6a6 100644
--- a/AirFighter/AirFighter/Program.cs
+++ b/AirFighter/AirFighter/Program.cs
@@ -11,7 +11,7 @@ namespace AirFighter
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new FormMap());
+ Application.Run(new FormMapWithSetAirFighters());
}
}
}
\ No newline at end of file
diff --git a/AirFighter/AirFighter/SetAirFightersGeneric.cs b/AirFighter/AirFighter/SetAirFightersGeneric.cs
index e5c62a2..b96994a 100644
--- a/AirFighter/AirFighter/SetAirFightersGeneric.cs
+++ b/AirFighter/AirFighter/SetAirFightersGeneric.cs
@@ -57,8 +57,6 @@ namespace AirFighter
///
public int Insert(T airFighter)
{
- // TODO вставка в начало набора
-
if (!CheckNullPosition(0))
{
return -1;
@@ -91,11 +89,6 @@ namespace AirFighter
///
public int Insert(T airFighter, int position)
{
- // TODO проверка позиции
- // TODO проверка, что элемент массива по этой позиции пустой,если нет, то
- // проверка, что после вставляемого элемента в массиве есть пустой элемент
- // сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента
- // TODO вставка по позиции
if (_places[position] == null)
{
_places[position] = airFighter;
@@ -134,9 +127,6 @@ namespace AirFighter
///
public T Remove(int position)
{
- // TODO проверка позиции
- // TODO удаление объекта из массива, присовив элементу массива
- //значение null
if (position >= 0 && position < _places.Length && _places[position] != null)
{
T temp = _places[position];
@@ -153,7 +143,6 @@ namespace AirFighter
///
public T Get(int position)
{
- // TODO проверка позиции
if (_places[position] != null)
{
return _places[position];