From ecc16501923a38568b20c734ee5b5c0e46c94405 Mon Sep 17 00:00:00 2001 From: "Nikolaeva_Y.A" Date: Tue, 8 Nov 2022 10:13:46 +0400 Subject: [PATCH] Changes forms. --- Airbus/Airbus/Direction.cs | 2 +- Airbus/Airbus/DrawningAirbus.cs | 2 +- Airbus/Airbus/EntityAirbus.cs | 2 +- Airbus/Airbus/FormAirbus.Designer.cs | 13 ++ Airbus/Airbus/FormAirbus.cs | 8 + Airbus/Airbus/FormMap.Designer.cs | 221 ------------------ Airbus/Airbus/FormMap.cs | 91 -------- .../Airbus/FormMapWithSetPlanes.Designer.cs | 213 +++++++++++++++++ Airbus/Airbus/FormMapWithSetPlanes.cs | 152 ++++++++++++ ...FormMap.resx => FormMapWithSetPlanes.resx} | 3 - Airbus/Airbus/Program.cs | 2 +- 11 files changed, 390 insertions(+), 319 deletions(-) delete mode 100644 Airbus/Airbus/FormMap.Designer.cs delete mode 100644 Airbus/Airbus/FormMap.cs create mode 100644 Airbus/Airbus/FormMapWithSetPlanes.Designer.cs create mode 100644 Airbus/Airbus/FormMapWithSetPlanes.cs rename Airbus/Airbus/{FormMap.resx => FormMapWithSetPlanes.resx} (93%) diff --git a/Airbus/Airbus/Direction.cs b/Airbus/Airbus/Direction.cs index 64adcd1..9abf9bb 100644 --- a/Airbus/Airbus/Direction.cs +++ b/Airbus/Airbus/Direction.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Airbus { - internal enum Direction + public enum Direction { Up = 1, Down = 2, diff --git a/Airbus/Airbus/DrawningAirbus.cs b/Airbus/Airbus/DrawningAirbus.cs index f457f5a..a983dd7 100644 --- a/Airbus/Airbus/DrawningAirbus.cs +++ b/Airbus/Airbus/DrawningAirbus.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Airbus { //класс, отвечающий за прорисовку и перемещение объект - internal class DrawningAirbus + public class DrawningAirbus { public EntityAirbus Airbus { get; protected set; } //класс-сущность diff --git a/Airbus/Airbus/EntityAirbus.cs b/Airbus/Airbus/EntityAirbus.cs index 303458d..c9fb4d2 100644 --- a/Airbus/Airbus/EntityAirbus.cs +++ b/Airbus/Airbus/EntityAirbus.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Airbus { - internal class EntityAirbus + public class EntityAirbus { public int Speed { get; private set; } //скорость public float Weight { get; private set; } //вес diff --git a/Airbus/Airbus/FormAirbus.Designer.cs b/Airbus/Airbus/FormAirbus.Designer.cs index 6a3a792..299eb03 100644 --- a/Airbus/Airbus/FormAirbus.Designer.cs +++ b/Airbus/Airbus/FormAirbus.Designer.cs @@ -39,6 +39,7 @@ this.buttonLeft = new System.Windows.Forms.Button(); this.buttonUp = new System.Windows.Forms.Button(); this.buttonCreateModif = new System.Windows.Forms.Button(); + this.buttonSelectPlane = new System.Windows.Forms.Button(); this.statusStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirbus)).BeginInit(); this.SuspendLayout(); @@ -155,11 +156,22 @@ this.buttonCreateModif.UseVisualStyleBackColor = true; this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click); // + // buttonSelectPlane + // + this.buttonSelectPlane.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSelectPlane.Location = new System.Drawing.Point(654, 401); + this.buttonSelectPlane.Name = "buttonSelectPlane"; + this.buttonSelectPlane.Size = new System.Drawing.Size(85, 23); + this.buttonSelectPlane.TabIndex = 8; + this.buttonSelectPlane.Text = "Выбрать"; + this.buttonSelectPlane.UseVisualStyleBackColor = true; + // // FormAirbus // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(884, 461); + this.Controls.Add(this.buttonSelectPlane); this.Controls.Add(this.buttonCreateModif); this.Controls.Add(this.buttonUp); this.Controls.Add(this.buttonLeft); @@ -192,5 +204,6 @@ private Button buttonLeft; private Button buttonUp; private Button buttonCreateModif; + private Button buttonSelectPlane; } } \ No newline at end of file diff --git a/Airbus/Airbus/FormAirbus.cs b/Airbus/Airbus/FormAirbus.cs index fe088f2..4653d19 100644 --- a/Airbus/Airbus/FormAirbus.cs +++ b/Airbus/Airbus/FormAirbus.cs @@ -13,6 +13,9 @@ namespace Airbus public partial class FormAirbus : Form { private DrawningAirbus _airbus; + + // + public DrawningAirbus SelectedPlane { get; set; } public FormAirbus() { InitializeComponent(); @@ -84,5 +87,10 @@ namespace Airbus SetData(); Draw(); } + private void buttonSelectPlane_Click(object sender, EventArgs e) + { + SelectedPlane = _airbus; + DialogResult = DialogResult.OK; + } } } \ No newline at end of file diff --git a/Airbus/Airbus/FormMap.Designer.cs b/Airbus/Airbus/FormMap.Designer.cs deleted file mode 100644 index 473c6d9..0000000 --- a/Airbus/Airbus/FormMap.Designer.cs +++ /dev/null @@ -1,221 +0,0 @@ -namespace Airbus -{ - 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.pictureBoxAirbus = new System.Windows.Forms.PictureBox(); - this.statusStrip1 = new System.Windows.Forms.StatusStrip(); - this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabelCorpusColor = 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.buttonDown = new System.Windows.Forms.Button(); - this.buttonRight = new System.Windows.Forms.Button(); - this.buttonCreateModif = new System.Windows.Forms.Button(); - this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirbus)).BeginInit(); - this.statusStrip1.SuspendLayout(); - this.SuspendLayout(); - // - // pictureBoxAirbus - // - this.pictureBoxAirbus.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBoxAirbus.Location = new System.Drawing.Point(0, 0); - this.pictureBoxAirbus.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.pictureBoxAirbus.Name = "pictureBoxAirbus"; - this.pictureBoxAirbus.Size = new System.Drawing.Size(700, 316); - this.pictureBoxAirbus.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pictureBoxAirbus.TabIndex = 0; - this.pictureBoxAirbus.TabStop = false; - // - // statusStrip1 - // - this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); - this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabelSpeed, - this.toolStripStatusLabelWeight, - this.toolStripStatusLabelCorpusColor}); - this.statusStrip1.Location = new System.Drawing.Point(0, 316); - this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 12, 0); - this.statusStrip1.Size = new System.Drawing.Size(700, 22); - this.statusStrip1.TabIndex = 1; - this.statusStrip1.Text = "statusStrip1"; - // - // 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 = "Вес:"; - // - // toolStripStatusLabelCorpusColor - // - this.toolStripStatusLabelCorpusColor.Name = "toolStripStatusLabelCorpusColor"; - this.toolStripStatusLabelCorpusColor.Size = new System.Drawing.Size(36, 17); - this.toolStripStatusLabelCorpusColor.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(9, 282); - this.buttonCreate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonCreate.Name = "buttonCreate"; - this.buttonCreate.Size = new System.Drawing.Size(83, 22); - 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::Airbus.Properties.Resources.up; - this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonUp.Location = new System.Drawing.Point(622, 244); - this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - 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::Airbus.Properties.Resources.left; - this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonLeft.Location = new System.Drawing.Point(586, 278); - this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - 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); - // - // buttonDown - // - this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDown.BackgroundImage = global::Airbus.Properties.Resources.down; - this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonDown.Location = new System.Drawing.Point(622, 278); - this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonDown.Name = "buttonDown"; - this.buttonDown.Size = new System.Drawing.Size(30, 30); - this.buttonDown.TabIndex = 5; - this.buttonDown.UseVisualStyleBackColor = true; - this.buttonDown.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::Airbus.Properties.Resources.right; - this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonRight.Location = new System.Drawing.Point(658, 278); - this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - 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); - // - // 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(98, 282); - this.buttonCreateModif.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonCreateModif.Name = "buttonCreateModif"; - this.buttonCreateModif.Size = new System.Drawing.Size(105, 22); - 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(10, 9); - this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; - this.comboBoxSelectorMap.Size = new System.Drawing.Size(133, 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(700, 338); - this.Controls.Add(this.comboBoxSelectorMap); - this.Controls.Add(this.buttonCreateModif); - this.Controls.Add(this.buttonRight); - this.Controls.Add(this.buttonDown); - this.Controls.Add(this.buttonLeft); - this.Controls.Add(this.buttonUp); - this.Controls.Add(this.buttonCreate); - this.Controls.Add(this.pictureBoxAirbus); - this.Controls.Add(this.statusStrip1); - this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.Name = "FormMap"; - this.Text = "Карта"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirbus)).EndInit(); - this.statusStrip1.ResumeLayout(false); - this.statusStrip1.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private PictureBox pictureBoxAirbus; - private StatusStrip statusStrip1; - private ToolStripStatusLabel toolStripStatusLabelSpeed; - private ToolStripStatusLabel toolStripStatusLabelWeight; - private ToolStripStatusLabel toolStripStatusLabelCorpusColor; - private Button buttonCreate; - private Button buttonUp; - private Button buttonLeft; - private Button buttonDown; - private Button buttonRight; - private Button buttonCreateModif; - private ComboBox comboBoxSelectorMap; - } -} \ No newline at end of file diff --git a/Airbus/Airbus/FormMap.cs b/Airbus/Airbus/FormMap.cs deleted file mode 100644 index d3787a9..0000000 --- a/Airbus/Airbus/FormMap.cs +++ /dev/null @@ -1,91 +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 Airbus -{ - public partial class FormMap : Form - { - private AbstractMap _abstractMap; - public FormMap() - { - InitializeComponent(); - _abstractMap = new SimpleMap(); - } - //заполнение информации по объекту - private void SetData(DrawningAirbus airbus) - { - toolStripStatusLabelSpeed.Text = $"Скорость: {airbus.Airbus?.Speed}"; - toolStripStatusLabelWeight.Text = $"Вес: {airbus.Airbus?.Weight}"; - toolStripStatusLabelCorpusColor.Text = $"Цвет: {airbus.Airbus?.CorpusColor.Name}"; - pictureBoxAirbus.Image = _abstractMap.CreateMap(pictureBoxAirbus.Width, pictureBoxAirbus.Height, - new DrawningObjectPlane(airbus)); - } - - //обработка нажатия кнопки "Создать" - private void ButtonCreate_Click(object sender, EventArgs e) - { - Random rnd = new(); - var airbus = new DrawningAirbus(rnd.Next(100, 300), rnd.Next(1000, 2000), - Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); - SetData(airbus); - } - - 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; - } - pictureBoxAirbus.Image = _abstractMap?.MoveObject(dir); - } - - //обработка нажития кнопки "Модификация" - private void ButtonCreateModif_Click(object sender, EventArgs e) - { - Random rnd = new(); - var airbus = new DrawningSuperAirbus(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(airbus); - } - - private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) - { - switch (comboBoxSelectorMap.Text) - { - case "Простая карта": - _abstractMap = new SimpleMap(); - break; - case "Пустыня": - _abstractMap = new DesertMap(); - break; - case "Космос": - - _abstractMap = new SpaceMap(); - break; - } - } - } -} diff --git a/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs b/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs new file mode 100644 index 0000000..85d8ea3 --- /dev/null +++ b/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs @@ -0,0 +1,213 @@ +namespace Airbus +{ + partial class FormMapWithSetPlanes + { + /// + /// 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.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); + this.maskedTextBoxPosition = new System.Windows.Forms.TextBox(); + this.buttonAddPlane = new System.Windows.Forms.Button(); + this.buttonRemovePlane = new System.Windows.Forms.Button(); + this.buttonShowStorage = new System.Windows.Forms.Button(); + this.buttonShowOnMap = new System.Windows.Forms.Button(); + this.buttonLeft = new System.Windows.Forms.Button(); + this.buttonDown = new System.Windows.Forms.Button(); + this.buttonRight = new System.Windows.Forms.Button(); + this.buttonUp = new System.Windows.Forms.Button(); + this.pictureBox = new System.Windows.Forms.PictureBox(); + this.groupBoxTools.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + this.SuspendLayout(); + // + // groupBoxTools + // + this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap); + this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition); + this.groupBoxTools.Controls.Add(this.buttonAddPlane); + this.groupBoxTools.Controls.Add(this.buttonRemovePlane); + this.groupBoxTools.Controls.Add(this.buttonShowStorage); + this.groupBoxTools.Controls.Add(this.buttonShowOnMap); + this.groupBoxTools.Controls.Add(this.buttonLeft); + this.groupBoxTools.Controls.Add(this.buttonDown); + this.groupBoxTools.Controls.Add(this.buttonRight); + this.groupBoxTools.Controls.Add(this.buttonUp); + this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; + this.groupBoxTools.Location = new System.Drawing.Point(600, 0); + this.groupBoxTools.Name = "groupBoxTools"; + this.groupBoxTools.Size = new System.Drawing.Size(200, 450); + this.groupBoxTools.TabIndex = 0; + this.groupBoxTools.TabStop = false; + this.groupBoxTools.Text = "Инструменты"; + // + // 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(21, 31); + this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; + this.comboBoxSelectorMap.Size = new System.Drawing.Size(167, 23); + this.comboBoxSelectorMap.TabIndex = 9; + this.comboBoxSelectorMap.Click += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); + // + // maskedTextBoxPosition + // + this.maskedTextBoxPosition.Location = new System.Drawing.Point(21, 203); + this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; + this.maskedTextBoxPosition.Size = new System.Drawing.Size(167, 23); + this.maskedTextBoxPosition.TabIndex = 8; + // + // buttonAddPlane + // + this.buttonAddPlane.Location = new System.Drawing.Point(21, 85); + this.buttonAddPlane.Name = "buttonAddPlane"; + this.buttonAddPlane.Size = new System.Drawing.Size(167, 25); + this.buttonAddPlane.TabIndex = 7; + this.buttonAddPlane.Text = "Добавить самолёт"; + this.buttonAddPlane.UseVisualStyleBackColor = true; + this.buttonAddPlane.Click += new System.EventHandler(this.ButtonAddPlane_Click); + // + // buttonRemovePlane + // + this.buttonRemovePlane.Location = new System.Drawing.Point(21, 151); + this.buttonRemovePlane.Name = "buttonRemovePlane"; + this.buttonRemovePlane.Size = new System.Drawing.Size(167, 25); + this.buttonRemovePlane.TabIndex = 6; + this.buttonRemovePlane.Text = "Удалить самолёт"; + this.buttonRemovePlane.UseVisualStyleBackColor = true; + this.buttonRemovePlane.Click += new System.EventHandler(this.ButtonRemovePlane_Click); + // + // buttonShowStorage + // + this.buttonShowStorage.Location = new System.Drawing.Point(21, 239); + this.buttonShowStorage.Name = "buttonShowStorage"; + this.buttonShowStorage.Size = new System.Drawing.Size(167, 25); + this.buttonShowStorage.TabIndex = 5; + this.buttonShowStorage.Text = "Посмотреть хранилище"; + this.buttonShowStorage.UseVisualStyleBackColor = true; + this.buttonShowStorage.Click += new System.EventHandler(this.buttonShowStorage_Click); + // + // buttonShowOnMap + // + this.buttonShowOnMap.Location = new System.Drawing.Point(21, 306); + this.buttonShowOnMap.Name = "buttonShowOnMap"; + this.buttonShowOnMap.Size = new System.Drawing.Size(167, 25); + this.buttonShowOnMap.TabIndex = 4; + this.buttonShowOnMap.Text = "Посмотреть карту"; + this.buttonShowOnMap.UseVisualStyleBackColor = true; + this.buttonShowOnMap.Click += new System.EventHandler(this.buttonShowOnMap_Click); + // + // buttonLeft + // + this.buttonLeft.BackgroundImage = global::Airbus.Properties.Resources.left; + this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonLeft.Location = new System.Drawing.Point(45, 405); + this.buttonLeft.Name = "buttonLeft"; + this.buttonLeft.Size = new System.Drawing.Size(37, 33); + this.buttonLeft.TabIndex = 3; + this.buttonLeft.UseVisualStyleBackColor = true; + this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonDown + // + this.buttonDown.BackgroundImage = global::Airbus.Properties.Resources.down; + this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonDown.Location = new System.Drawing.Point(88, 405); + this.buttonDown.Name = "buttonDown"; + this.buttonDown.Size = new System.Drawing.Size(37, 33); + this.buttonDown.TabIndex = 2; + this.buttonDown.UseVisualStyleBackColor = true; + this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonRight + // + this.buttonRight.BackgroundImage = global::Airbus.Properties.Resources.right; + this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonRight.Location = new System.Drawing.Point(131, 405); + this.buttonRight.Name = "buttonRight"; + this.buttonRight.Size = new System.Drawing.Size(37, 33); + this.buttonRight.TabIndex = 1; + this.buttonRight.UseVisualStyleBackColor = true; + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonUp + // + this.buttonUp.BackgroundImage = global::Airbus.Properties.Resources.up; + this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonUp.Location = new System.Drawing.Point(88, 366); + this.buttonUp.Name = "buttonUp"; + this.buttonUp.Size = new System.Drawing.Size(37, 33); + this.buttonUp.TabIndex = 0; + this.buttonUp.UseVisualStyleBackColor = true; + this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); + // + // 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(600, 450); + this.pictureBox.TabIndex = 1; + this.pictureBox.TabStop = false; + // + // FormMapWithSetPlanes + // + 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.pictureBox); + this.Controls.Add(this.groupBoxTools); + this.Name = "FormMapWithSetPlanes"; + this.Text = "FormMapWithSetPlanes"; + this.groupBoxTools.ResumeLayout(false); + this.groupBoxTools.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBoxTools; + private Button buttonLeft; + private Button buttonDown; + private Button buttonRight; + private Button buttonUp; + private PictureBox pictureBox; + private TextBox maskedTextBoxPosition; + private Button buttonAddPlane; + private Button buttonRemovePlane; + private Button buttonShowStorage; + private Button buttonShowOnMap; + private ComboBox comboBoxSelectorMap; + } +} \ No newline at end of file diff --git a/Airbus/Airbus/FormMapWithSetPlanes.cs b/Airbus/Airbus/FormMapWithSetPlanes.cs new file mode 100644 index 0000000..2a30ca5 --- /dev/null +++ b/Airbus/Airbus/FormMapWithSetPlanes.cs @@ -0,0 +1,152 @@ +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 Airbus +{ + public partial class FormMapWithSetPlanes : Form + { + //объект от класса карты с набором объектов + private MapWithSetPlanesGeneric _mapPlanesCollectionGeneric; + + public FormMapWithSetPlanes() + { + InitializeComponent(); + } + + //выбор карты + private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) + { + AbstractMap map = null; + + switch (comboBoxSelectorMap.Text) + { + case "Простая карта": + map = new SimpleMap(); + break; + } + + if (map != null) + { + _mapPlanesCollectionGeneric = new MapWithSetPlanesGeneric( + pictureBox.Width, pictureBox.Height, map); + } + else + { + _mapPlanesCollectionGeneric = null; + } + } + + //добавление объекта + private void ButtonAddPlane_Click(object sender, EventArgs e) + { + if (_mapPlanesCollectionGeneric == null) + { + return; + } + + FormAirbus form = new(); + + if (form.ShowDialog() == DialogResult.OK) + { + DrawningObjectPlane plane = new(form.SelectedPlane); + + if (_mapPlanesCollectionGeneric + plane) + { + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapPlanesCollectionGeneric.ShowSet(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } + } + + private void ButtonRemovePlane_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 (_mapPlanesCollectionGeneric - pos) + { + MessageBox.Show("Объект удалён"); + pictureBox.Image = _mapPlanesCollectionGeneric.ShowSet(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + } + } + + //вывод набора + private void buttonShowStorage_Click(object sender, EventArgs e) + { + if (_mapPlanesCollectionGeneric == null) + { + return; + } + + pictureBox.Image = _mapPlanesCollectionGeneric.ShowSet(); + } + + //вывод карты + private void buttonShowOnMap_Click(object sender, EventArgs e) + { + if (_mapPlanesCollectionGeneric == null) + { + return; + } + + pictureBox.Image = _mapPlanesCollectionGeneric.ShowOnMap(); + } + + //перемещение + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_mapPlanesCollectionGeneric == null) + { + return; + } + + //получаем имя кнопки + string name = ((Button)sender)?.Name ?? string.Empty; + Direction dir = Direction.None; + + switch (name) + { + case "buttonUp": + dir = Direction.Up; + break; + case "buttonLeft": + dir = Direction.Left; + break; + case "buttonDown": + dir = Direction.Down; + break; + case "buttonRight": + dir = Direction.Right; + break; + } + + pictureBox.Image = _mapPlanesCollectionGeneric.MoveObject(dir); + } + + } +} \ No newline at end of file diff --git a/Airbus/Airbus/FormMap.resx b/Airbus/Airbus/FormMapWithSetPlanes.resx similarity index 93% rename from Airbus/Airbus/FormMap.resx rename to Airbus/Airbus/FormMapWithSetPlanes.resx index 5cb320f..f298a7b 100644 --- a/Airbus/Airbus/FormMap.resx +++ b/Airbus/Airbus/FormMapWithSetPlanes.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/Airbus/Airbus/Program.cs b/Airbus/Airbus/Program.cs index 3c7e1fb..5166800 100644 --- a/Airbus/Airbus/Program.cs +++ b/Airbus/Airbus/Program.cs @@ -11,7 +11,7 @@ namespace Airbus // 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 FormMapWithSetPlanes()); } } } \ No newline at end of file