base add airplanes
This commit is contained in:
parent
8f82b634a8
commit
9074f7f01c
80
Airbus/Airbus/FormMapWithSetAirplane.Designer.cs
generated
80
Airbus/Airbus/FormMapWithSetAirplane.Designer.cs
generated
@ -37,11 +37,11 @@
|
|||||||
this.buttonStorage = new System.Windows.Forms.Button();
|
this.buttonStorage = new System.Windows.Forms.Button();
|
||||||
this.buttonRemoveAirplane = new System.Windows.Forms.Button();
|
this.buttonRemoveAirplane = new System.Windows.Forms.Button();
|
||||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||||
this.buttonAddAirbus = new System.Windows.Forms.Button();
|
this.buttonAddAirplane = new System.Windows.Forms.Button();
|
||||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||||
this.groupBoxTools.SuspendLayout();
|
this.groupBoxTools.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
@ -54,7 +54,7 @@
|
|||||||
this.groupBoxTools.Controls.Add(this.buttonStorage);
|
this.groupBoxTools.Controls.Add(this.buttonStorage);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonRemoveAirplane);
|
this.groupBoxTools.Controls.Add(this.buttonRemoveAirplane);
|
||||||
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
|
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonAddAirbus);
|
this.groupBoxTools.Controls.Add(this.buttonAddAirplane);
|
||||||
this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap);
|
this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap);
|
||||||
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
||||||
this.groupBoxTools.Location = new System.Drawing.Point(600, 0);
|
this.groupBoxTools.Location = new System.Drawing.Point(600, 0);
|
||||||
@ -66,17 +66,27 @@
|
|||||||
//
|
//
|
||||||
// buttonDown
|
// buttonDown
|
||||||
//
|
//
|
||||||
this.buttonDown.Location = new System.Drawing.Point(0, 0);
|
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonDown.BackgroundImage = global::Airbus.Properties.Resources.v4;
|
||||||
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonDown.Location = new System.Drawing.Point(80, 380);
|
||||||
this.buttonDown.Name = "buttonDown";
|
this.buttonDown.Name = "buttonDown";
|
||||||
this.buttonDown.Size = new System.Drawing.Size(75, 23);
|
this.buttonDown.Size = new System.Drawing.Size(35, 35);
|
||||||
this.buttonDown.TabIndex = 0;
|
this.buttonDown.TabIndex = 9;
|
||||||
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
// buttonRight
|
// buttonRight
|
||||||
//
|
//
|
||||||
this.buttonRight.Location = new System.Drawing.Point(0, 0);
|
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonRight.BackgroundImage = global::Airbus.Properties.Resources.v3;
|
||||||
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonRight.Location = new System.Drawing.Point(112, 348);
|
||||||
this.buttonRight.Name = "buttonRight";
|
this.buttonRight.Name = "buttonRight";
|
||||||
this.buttonRight.Size = new System.Drawing.Size(75, 23);
|
this.buttonRight.Size = new System.Drawing.Size(35, 35);
|
||||||
this.buttonRight.TabIndex = 1;
|
this.buttonRight.TabIndex = 8;
|
||||||
|
this.buttonRight.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
// buttonLeft
|
// buttonLeft
|
||||||
//
|
//
|
||||||
@ -88,6 +98,7 @@
|
|||||||
this.buttonLeft.Size = new System.Drawing.Size(35, 35);
|
this.buttonLeft.Size = new System.Drawing.Size(35, 35);
|
||||||
this.buttonLeft.TabIndex = 7;
|
this.buttonLeft.TabIndex = 7;
|
||||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
// buttonUp
|
// buttonUp
|
||||||
//
|
//
|
||||||
@ -99,6 +110,7 @@
|
|||||||
this.buttonUp.Size = new System.Drawing.Size(35, 35);
|
this.buttonUp.Size = new System.Drawing.Size(35, 35);
|
||||||
this.buttonUp.TabIndex = 6;
|
this.buttonUp.TabIndex = 6;
|
||||||
this.buttonUp.UseVisualStyleBackColor = true;
|
this.buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
// buttonShowOnMap
|
// buttonShowOnMap
|
||||||
//
|
//
|
||||||
@ -135,40 +147,50 @@
|
|||||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(182, 23);
|
this.maskedTextBoxPosition.Size = new System.Drawing.Size(182, 23);
|
||||||
this.maskedTextBoxPosition.TabIndex = 2;
|
this.maskedTextBoxPosition.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// buttonAddAirbus
|
// buttonAddAirplane
|
||||||
//
|
//
|
||||||
this.buttonAddAirbus.Location = new System.Drawing.Point(6, 71);
|
this.buttonAddAirplane.Location = new System.Drawing.Point(6, 74);
|
||||||
this.buttonAddAirbus.Name = "buttonAddAirbus";
|
this.buttonAddAirplane.Name = "buttonAddAirplane";
|
||||||
this.buttonAddAirbus.Size = new System.Drawing.Size(182, 23);
|
this.buttonAddAirplane.Size = new System.Drawing.Size(182, 23);
|
||||||
this.buttonAddAirbus.TabIndex = 1;
|
this.buttonAddAirplane.TabIndex = 1;
|
||||||
this.buttonAddAirbus.Text = "Добавить Самолёт";
|
this.buttonAddAirplane.Text = "Добавить Самолёт";
|
||||||
this.buttonAddAirbus.UseVisualStyleBackColor = true;
|
this.buttonAddAirplane.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddAirplane.Click += new System.EventHandler(this.buttonAddAirplane_Click);
|
||||||
//
|
//
|
||||||
// comboBoxSelectorMap
|
// comboBoxSelectorMap
|
||||||
//
|
//
|
||||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 22);
|
this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 22);
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||||
|
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||||
|
"Первая карта",
|
||||||
|
"Вторая карта",
|
||||||
|
"Третья карта"});
|
||||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(182, 23);
|
this.comboBoxSelectorMap.Size = new System.Drawing.Size(182, 23);
|
||||||
this.comboBoxSelectorMap.TabIndex = 0;
|
this.comboBoxSelectorMap.TabIndex = 0;
|
||||||
|
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// pictureBox1
|
// pictureBox
|
||||||
//
|
//
|
||||||
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
|
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||||
this.pictureBox1.Name = "pictureBox1";
|
this.pictureBox.Name = "pictureBox";
|
||||||
this.pictureBox1.Size = new System.Drawing.Size(600, 450);
|
this.pictureBox.Size = new System.Drawing.Size(600, 450);
|
||||||
this.pictureBox1.TabIndex = 1;
|
this.pictureBox.TabIndex = 1;
|
||||||
this.pictureBox1.TabStop = false;
|
this.pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
// FormMapWithSetAirplane
|
// FormMapWithSetAirplane
|
||||||
//
|
//
|
||||||
this.ClientSize = new System.Drawing.Size(284, 261);
|
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 = "FormMapWithSetAirplane";
|
this.Name = "FormMapWithSetAirplane";
|
||||||
this.Load += new System.EventHandler(this.FormMapWithSetAirplane_Load);
|
this.Text = "FormMapWithSetAirplane";
|
||||||
this.groupBoxTools.ResumeLayout(false);
|
this.groupBoxTools.ResumeLayout(false);
|
||||||
this.groupBoxTools.PerformLayout();
|
this.groupBoxTools.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -180,9 +202,9 @@
|
|||||||
private Button buttonStorage;
|
private Button buttonStorage;
|
||||||
private Button buttonRemoveAirplane;
|
private Button buttonRemoveAirplane;
|
||||||
private MaskedTextBox maskedTextBoxPosition;
|
private MaskedTextBox maskedTextBoxPosition;
|
||||||
private Button buttonAddAirbus;
|
private Button buttonAddAirplane;
|
||||||
private ComboBox comboBoxSelectorMap;
|
private ComboBox comboBoxSelectorMap;
|
||||||
private PictureBox pictureBox1;
|
private PictureBox pictureBox;
|
||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
|
@ -7,29 +7,164 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using static System.Windows.Forms.DataFormats;
|
||||||
|
|
||||||
namespace Airbus
|
namespace Airbus
|
||||||
{
|
{
|
||||||
public partial class FormMapWithSetAirplane : Form
|
public partial class FormMapWithSetAirplane : Form
|
||||||
{
|
{
|
||||||
|
private AbstractMap _abstractMap;
|
||||||
|
private MapWithSetAirplaneGeneric<DrawningObjectAirplane, AbstractMap>
|
||||||
|
_mapCarsCollectionGeneric;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
public FormMapWithSetAirplane()
|
public FormMapWithSetAirplane()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
private void buttonLeft_Click(object sender, EventArgs e)
|
/// Выбор карты
|
||||||
|
/// </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;
|
||||||
|
case "Вторая карта":
|
||||||
|
map = new SecondMap();
|
||||||
|
break;
|
||||||
|
case "Третья карта":
|
||||||
|
map = new ThirdMap();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (map != null)
|
||||||
|
{
|
||||||
|
_mapCarsCollectionGeneric = new
|
||||||
|
MapWithSetAirplaneGeneric<DrawningObjectAirplane, AbstractMap>(
|
||||||
|
pictureBox.Width, pictureBox.Height, map);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_mapCarsCollectionGeneric = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void buttonAddAirplane_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_mapCarsCollectionGeneric == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FormAirplane form = new();
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
DrawningObjectAirplane airplane = new(form.SelectedAirplane);
|
||||||
|
if (_mapCarsCollectionGeneric + airplane)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBox.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonRemoveCar_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 (_mapCarsCollectionGeneric - pos)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект удален");
|
||||||
|
pictureBox.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Вывод набора
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_mapCarsCollectionGeneric == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pictureBox.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Вывод карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_mapCarsCollectionGeneric == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pictureBox.Image = _mapCarsCollectionGeneric.ShowOnMap();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Перемещение
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_mapCarsCollectionGeneric == 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 = _mapCarsCollectionGeneric.MoveObject(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonRight_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormMapWithSetAirplane_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace Airbus
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormMap());
|
Application.Run(new FormMapWithSetAirplane());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,31 +9,15 @@ namespace Airbus
|
|||||||
internal class SetAirplaneGeneric<T>
|
internal class SetAirplaneGeneric<T>
|
||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Массив объектов, которые храним
|
|
||||||
/// </summary>
|
|
||||||
private readonly T[] _places;
|
private readonly T[] _places;
|
||||||
/// <summary>
|
|
||||||
/// Количество объектов в массиве
|
|
||||||
/// </summary>
|
|
||||||
public int Count => _places.Length;
|
public int Count => _places.Length;
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="count"></param>
|
|
||||||
public SetAirplaneGeneric(int count)
|
public SetAirplaneGeneric(int count)
|
||||||
{
|
{
|
||||||
_places = new T[count];
|
_places = new T[count];
|
||||||
}
|
}
|
||||||
/// <summary>
|
public bool Insert(T airplane)
|
||||||
/// Добавление объекта в набор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="car">Добавляемый автомобиль</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool Insert(T car)
|
|
||||||
{
|
{
|
||||||
// TODO вставка в начало набора
|
return Insert(airplane, 0);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в набор на конкретную позицию
|
/// Добавление объекта в набор на конкретную позицию
|
||||||
|
Loading…
Reference in New Issue
Block a user