changes forms

This commit is contained in:
ArtemEmelyanov 2022-10-16 13:14:33 +04:00
parent 96b1b664a7
commit 80f867986d
11 changed files with 385 additions and 337 deletions

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Airbus
{
internal enum Direction
public enum Direction
{
None = 0,
Up = 1,

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Airbus
{
internal class DrawningPlane
public class DrawningPlane
{
/// <summary>
/// Класс-сущность

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Airbus
{
internal class EntityPlane
public class EntityPlane
{
/// <summary>
/// Скорость

View File

@ -1,216 +0,0 @@
namespace Airbus
{
partial class FormMap
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBoxPlane = 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.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
this.buttonCreate = 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.buttonDown = new System.Windows.Forms.Button();
this.buttonCreateModif = new System.Windows.Forms.Button();
this.comboBoxSelector = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlane)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// pictureBoxPlane
//
this.pictureBoxPlane.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxPlane.Location = new System.Drawing.Point(0, 0);
this.pictureBoxPlane.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pictureBoxPlane.Name = "pictureBoxPlane";
this.pictureBoxPlane.Size = new System.Drawing.Size(700, 338);
this.pictureBoxPlane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxPlane.TabIndex = 0;
this.pictureBoxPlane.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.toolStripStatusLabelBodyColor});
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(59, 17);
this.toolStripStatusLabelSpeed.Text = "Скорость";
//
// toolStripStatusLabelWeight
//
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(26, 17);
this.toolStripStatusLabelWeight.Text = "Вес";
//
// toolStripStatusLabelBodyColor
//
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(33, 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(10, 286);
this.buttonCreate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(82, 22);
this.buttonCreate.TabIndex = 2;
this.buttonCreate.Text = "Создать";
this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_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.arrowRight;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(658, 286);
this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(26, 22);
this.buttonRight.TabIndex = 3;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.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.arrowLeft;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(595, 286);
this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(26, 22);
this.buttonLeft.TabIndex = 4;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_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.arrowUp;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(626, 260);
this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(26, 22);
this.buttonUp.TabIndex = 5;
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::Airbus.Properties.Resources.arrowDown;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(626, 286);
this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(26, 22);
this.buttonDown.TabIndex = 6;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonCreateModif
//
this.buttonCreateModif.Location = new System.Drawing.Point(98, 285);
this.buttonCreateModif.Name = "buttonCreateModif";
this.buttonCreateModif.Size = new System.Drawing.Size(99, 23);
this.buttonCreateModif.TabIndex = 7;
this.buttonCreateModif.Text = "Модификация";
this.buttonCreateModif.UseVisualStyleBackColor = true;
this.buttonCreateModif.Click += new System.EventHandler(this.buttonCreateModif_Click);
//
// comboBoxSelector
//
this.comboBoxSelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSelector.FormattingEnabled = true;
this.comboBoxSelector.Items.AddRange(new object[] {
"Простая карта",
"Вторая карта"});
this.comboBoxSelector.Location = new System.Drawing.Point(8, 8);
this.comboBoxSelector.Name = "comboBoxSelector";
this.comboBoxSelector.Size = new System.Drawing.Size(121, 23);
this.comboBoxSelector.TabIndex = 8;
this.comboBoxSelector.SelectedIndexChanged += new System.EventHandler(this.comboBoxSelector_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.comboBoxSelector);
this.Controls.Add(this.buttonCreateModif);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.pictureBoxPlane);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormMap";
this.Text = "Карта";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlane)).EndInit();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private PictureBox pictureBoxPlane;
private StatusStrip statusStrip1;
private ToolStripStatusLabel toolStripStatusLabelSpeed;
private ToolStripStatusLabel toolStripStatusLabelWeight;
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
private Button buttonCreate;
private Button buttonRight;
private Button buttonLeft;
private Button buttonUp;
private Button buttonDown;
private Button buttonCreateModif;
private ComboBox comboBoxSelector;
}
}

View File

@ -1,114 +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();
}
/// <summary>
/// Заполнение информации по объекту
/// </summary>
/// <param name="plane"></param>
private void SetData(DrawningPlane plane)
{
toolStripStatusLabelSpeed.Text = $"Скорость: {plane.Plane.Speed}";
toolStripStatusLabelWeight.Text = $"Вес: {plane.Plane.Weight}";
toolStripStatusLabelBodyColor.Text = $"Цвет: {plane.Plane.BodyColor.Name}";
pictureBoxPlane.Image = _abstractMap.CreateMap(pictureBoxPlane.Width, pictureBoxPlane.Height, new DrawningObjectPlane(plane));
}
/// <summary>
/// Обработка нажатия кнопки "Создать"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
var plane = new DrawningPlane(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
SetData(plane);
}
/// <summary>
/// Изменение размеров формы
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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;
}
pictureBoxPlane.Image = _abstractMap?.MoveObject(dir);
}
/// <summary>
/// Обработка нажатия кнопки "Модификация"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonCreateModif_Click(object sender, EventArgs e)
{
Random rnd = new();
var plane = new DrawningAirbus(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)), Convert.ToBoolean(rnd.Next(0, 2)));
SetData(plane);
}
/// <summary>
/// Смена карты
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void comboBoxSelector_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBoxSelector.Text)
{
case "Простая карта":
_abstractMap = new SimpleMap();
break;
case "Вторая карта":
_abstractMap = new MyMap();
break;
}
}
}
}

View File

@ -0,0 +1,199 @@
namespace Airbus
{
partial class FormMapWithSetPlanes
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.pictureBox = new System.Windows.Forms.PictureBox();
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
this.buttonAddPlane = new System.Windows.Forms.Button();
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
this.buttonRemovePlane = new System.Windows.Forms.Button();
this.buttonShowStorage = new System.Windows.Forms.Button();
this.buttonShowOnMap = new System.Windows.Forms.Button();
this.buttonUp = 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.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.buttonLeft);
this.groupBox1.Controls.Add(this.buttonRight);
this.groupBox1.Controls.Add(this.buttonDown);
this.groupBox1.Controls.Add(this.buttonUp);
this.groupBox1.Controls.Add(this.buttonShowOnMap);
this.groupBox1.Controls.Add(this.buttonShowStorage);
this.groupBox1.Controls.Add(this.buttonRemovePlane);
this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
this.groupBox1.Controls.Add(this.buttonAddPlane);
this.groupBox1.Controls.Add(this.comboBoxSelectorMap);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
this.groupBox1.Location = new System.Drawing.Point(600, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(200, 450);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Инструменты";
//
// pictureBox1
//
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox.Location = new System.Drawing.Point(0, 0);
this.pictureBox.Name = "pictureBox1";
this.pictureBox.Size = new System.Drawing.Size(600, 450);
this.pictureBox.TabIndex = 0;
this.pictureBox.TabStop = false;
//
// comboBoxSelectorMap
//
this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Location = new System.Drawing.Point(17, 22);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(171, 23);
this.comboBoxSelectorMap.TabIndex = 0;
//
// buttonAddPlane
//
this.buttonAddPlane.Location = new System.Drawing.Point(17, 64);
this.buttonAddPlane.Name = "buttonAddPlane";
this.buttonAddPlane.Size = new System.Drawing.Size(171, 31);
this.buttonAddPlane.TabIndex = 1;
this.buttonAddPlane.Text = "Добавить самолёт";
this.buttonAddPlane.UseVisualStyleBackColor = true;
//
// maskedTextBoxPosition
//
this.maskedTextBoxPosition.Location = new System.Drawing.Point(17, 126);
this.maskedTextBoxPosition.Mask = "00";
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
this.maskedTextBoxPosition.Size = new System.Drawing.Size(171, 23);
this.maskedTextBoxPosition.TabIndex = 2;
//
// buttonRemovePlane
//
this.buttonRemovePlane.Location = new System.Drawing.Point(17, 169);
this.buttonRemovePlane.Name = "buttonRemovePlane";
this.buttonRemovePlane.Size = new System.Drawing.Size(171, 31);
this.buttonRemovePlane.TabIndex = 3;
this.buttonRemovePlane.Text = "Удалить самолёт";
this.buttonRemovePlane.UseVisualStyleBackColor = true;
//
// buttonShowStorage
//
this.buttonShowStorage.Location = new System.Drawing.Point(17, 259);
this.buttonShowStorage.Name = "buttonShowStorage";
this.buttonShowStorage.Size = new System.Drawing.Size(171, 34);
this.buttonShowStorage.TabIndex = 4;
this.buttonShowStorage.Text = "Посмотреть хранилище";
this.buttonShowStorage.UseVisualStyleBackColor = true;
//
// buttonShowOnMap
//
this.buttonShowOnMap.Location = new System.Drawing.Point(17, 308);
this.buttonShowOnMap.Name = "buttonShowOnMap";
this.buttonShowOnMap.Size = new System.Drawing.Size(171, 31);
this.buttonShowOnMap.TabIndex = 5;
this.buttonShowOnMap.Text = "Посмотреть карту";
this.buttonShowOnMap.UseVisualStyleBackColor = true;
//
// buttonUp
//
this.buttonUp.BackgroundImage = global::Airbus.Properties.Resources.arrowUp;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(92, 370);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(30, 30);
this.buttonUp.TabIndex = 6;
this.buttonUp.UseVisualStyleBackColor = true;
//
// buttonDown
//
this.buttonDown.BackgroundImage = global::Airbus.Properties.Resources.arrowDown;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(92, 406);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(30, 30);
this.buttonDown.TabIndex = 7;
this.buttonDown.UseVisualStyleBackColor = true;
//
// buttonRight
//
this.buttonRight.BackgroundImage = global::Airbus.Properties.Resources.arrowRight;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(128, 406);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(30, 30);
this.buttonRight.TabIndex = 8;
this.buttonRight.UseVisualStyleBackColor = true;
//
// buttonLeft
//
this.buttonLeft.BackgroundImage = global::Airbus.Properties.Resources.arrowLeft;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(56, 406);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
this.buttonLeft.TabIndex = 9;
this.buttonLeft.UseVisualStyleBackColor = true;
//
// 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.groupBox1);
this.Name = "FormMapWithSetPlanes";
this.Text = "FormMapWithSetPlanes";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.ResumeLayout(false);
}
#endregion
private GroupBox groupBox1;
private Button buttonLeft;
private Button buttonRight;
private Button buttonDown;
private Button buttonUp;
private Button buttonShowOnMap;
private Button buttonShowStorage;
private Button buttonRemovePlane;
private MaskedTextBox maskedTextBoxPosition;
private Button buttonAddPlane;
private ComboBox comboBoxSelectorMap;
private PictureBox pictureBox;
}
}

View File

@ -0,0 +1,161 @@
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 Airbus
{
public partial class FormMapWithSetPlanes : Form
{
/// <summary>
/// Объект от класса карты с набором объектов
/// </summary>
private MapWithSetPlanesGeneric<DrawningObjectPlane, AbstractMap> _mapPlanesCollectionGeneric;
/// <summary>
/// Конструктор
/// </summary>
public FormMapWithSetPlanes()
{
InitializeComponent();
}
/// <summary>
/// Выбор карты
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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<DrawningObjectPlane, AbstractMap>(pictureBox.Width, pictureBox.Height, map);
}
else
{
_mapPlanesCollectionGeneric = null;
}
}
/// <summary>
/// Добавление объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddPlane_Click(object sender, EventArgs e)
{
if (_mapPlanesCollectionGeneric == null)
{
return;
}
FormPlane form = new();
if (form.ShowDialog() == DialogResult.OK)
{
DrawningObjectPlane plane = new(form.SelectedPlane);
if (_mapPlanesCollectionGeneric + plane)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapPlanesCollectionGeneric.ShowSet();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
}
/// <summary>
/// Удаление объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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("Не удалось удалить объект");
}
}
/// <summary>
/// Вывод набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonShowStorage_Click(object sender, EventArgs e)
{
if (_mapPlanesCollectionGeneric == null)
{
return;
}
pictureBox.Image = _mapPlanesCollectionGeneric.ShowSet();
}
/// <summary>
/// Вывод карты
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonShowOnMap_Click(object sender, EventArgs e)
{
if (_mapPlanesCollectionGeneric == null)
{
return;
}
pictureBox.Image = _mapPlanesCollectionGeneric.ShowOnMap();
}
/// <summary>
/// Перемещение
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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 "buttonDown":
dir = Direction.Down;
break;
case "buttonLeft":
dir = Direction.Left;
break;
case "buttonRight":
dir = Direction.Right;
break;
}
pictureBox.Image = _mapPlanesCollectionGeneric.MoveObject(dir);
}
}
}

View File

@ -57,7 +57,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -39,6 +39,7 @@
this.buttonUp = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonCreateModif = new System.Windows.Forms.Button();
this.buttonSelectPlane = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirbus)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
@ -160,11 +161,22 @@
this.buttonCreateModif.UseVisualStyleBackColor = true;
this.buttonCreateModif.Click += new System.EventHandler(this.buttonCreateModif_Click);
//
// buttonSelectPlane
//
this.buttonSelectPlane.Location = new System.Drawing.Point(514, 285);
this.buttonSelectPlane.Name = "buttonSelectPlane";
this.buttonSelectPlane.Size = new System.Drawing.Size(75, 23);
this.buttonSelectPlane.TabIndex = 8;
this.buttonSelectPlane.Text = "Выбрать";
this.buttonSelectPlane.UseVisualStyleBackColor = true;
this.buttonSelectPlane.Click += new System.EventHandler(this.buttonSelectPlane_Click);
//
// FormPlane
//
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.buttonSelectPlane);
this.Controls.Add(this.buttonCreateModif);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonUp);
@ -197,5 +209,6 @@
private Button buttonUp;
private Button buttonDown;
private Button buttonCreateModif;
private Button buttonSelectPlane;
}
}

View File

@ -14,6 +14,8 @@ namespace Airbus
{
private DrawningPlane _plane;
public DrawningPlane SelectedPlane { get; private set; }
public FormPlane()
{
InitializeComponent();
@ -93,6 +95,12 @@ namespace Airbus
SetData();
Draw();
}
private void buttonSelectPlane_Click(object sender, EventArgs e)
{
SelectedPlane = _plane;
DialogResult = DialogResult.OK;
}
}
}

View File

@ -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());
}
}
}