Добавление родителей и ввод конструкторов
This commit is contained in:
parent
9e549db077
commit
cc18d95546
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBus
|
||||
namespace AirBus.Drawings
|
||||
{
|
||||
/// <summary>
|
||||
/// Направление перемещения
|
75
AirBus/AirBus/Drawings/DrawingAirBus.cs
Normal file
75
AirBus/AirBus/Drawings/DrawingAirBus.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AirBus.Entities;
|
||||
|
||||
namespace AirBus.Drawings
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawingAirBus : DrawingPlane
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="extraEngine">Признак наличия дополнительных пары двигателей</param>
|
||||
/// <param name="secondFloor">Признак наличия второго этажа</param>
|
||||
public DrawingAirBus(int speed, double weight, Color bodyColor, Color additionalColor,
|
||||
bool extraEngine, bool secondFloor) : base(175, 72)
|
||||
{
|
||||
EntityPlane = new EntityAirBus(speed, weight, bodyColor, additionalColor, extraEngine, secondFloor);
|
||||
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityPlane == null || EntityPlane is not EntityAirBus airBus || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black, 1);
|
||||
Brush additionalBrush = new SolidBrush(airBus.AdditionalColor);
|
||||
Brush br = new SolidBrush(airBus.BodyColor);
|
||||
Brush brBlack = new SolidBrush(Color.Black);
|
||||
|
||||
base.DrawTransport(g);
|
||||
|
||||
if (airBus.ExtraEngine) // двигатели опционально
|
||||
{
|
||||
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 75, _startPosY.Value + 51, 10, 10);
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 80, _startPosY.Value + 51, 10, 10);
|
||||
g.DrawArc(pen, _startPosX.Value + 75, _startPosY.Value + 51, 10, 10, 90, 180);
|
||||
g.DrawArc(pen, _startPosX.Value + 80, _startPosY.Value + 51, 10, 10, -90, 180);
|
||||
g.DrawLine(pen, new Point(_startPosX.Value + 80, _startPosY.Value + 51), new Point(_startPosX.Value + 85, _startPosY.Value + 51));
|
||||
g.DrawLine(pen, new Point(_startPosX.Value + 80, _startPosY.Value + 61), new Point(_startPosX.Value + 85, _startPosY.Value + 61));
|
||||
}
|
||||
|
||||
if (airBus.SecondFloor) // пассажирский второй этаж
|
||||
{
|
||||
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 90, _startPosY.Value + 25, 50, 10);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value + 25, 50, 10);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -3,18 +3,16 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AirBus.Entities;
|
||||
|
||||
namespace AirBus
|
||||
namespace AirBus.Drawings
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawingAirBus
|
||||
public class DrawingPlane
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityAirBus? EntityAirBus { get; set; }
|
||||
public EntityPlane? EntityPlane { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
@ -29,12 +27,12 @@ namespace AirBus
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки самолёта
|
||||
/// </summary>
|
||||
private int? _startPosX;
|
||||
protected int? _startPosX;
|
||||
|
||||
/// <summary>
|
||||
/// Верхняя координата прорисовки самолёта
|
||||
/// </summary>
|
||||
private int? _startPosY;
|
||||
protected int? _startPosY;
|
||||
|
||||
/// <summary>
|
||||
/// Ширина прорисовки самолёта
|
||||
@ -47,26 +45,40 @@ namespace AirBus
|
||||
private readonly int _drawingAirBusHeight = 72;
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// Пустой конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="extraEngine">Признак наличия дополнительных пары двигателей</param>
|
||||
/// <param name="secondFloor">Признак наличия второго этажа</param>
|
||||
/// <param name="wingLine">Признак наличия линии на крыле</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor,
|
||||
bool extraEngine, bool secondFloor)
|
||||
private DrawingPlane()
|
||||
{
|
||||
EntityAirBus = new EntityAirBus();
|
||||
EntityAirBus.Init(speed, weight, bodyColor, additionalColor, extraEngine, secondFloor);
|
||||
_pictureHeight = null;
|
||||
_pictureWidth = null;
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="drawingAirBusWidth">Ширина прорисовки</param>
|
||||
/// <param name="drawingAirBusHeight">Высота прорисовки</param>
|
||||
protected DrawingPlane(int drawingAirBusWidth, int drawingAirBusHeight) : this()
|
||||
{
|
||||
_drawingAirBusWidth = drawingAirBusWidth;
|
||||
_drawingAirBusHeight = drawingAirBusHeight;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
public DrawingPlane(int speed, double weight, Color bodyColor) : this()
|
||||
{
|
||||
EntityPlane = new EntityPlane(speed, weight, bodyColor);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Установка границ поля
|
||||
/// </summary>
|
||||
@ -114,37 +126,37 @@ namespace AirBus
|
||||
/// <returns>true - перемещение выполнено, false - перемещение невозможно</returns>
|
||||
public bool MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityAirBus == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
if (EntityPlane == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch(direction)
|
||||
switch (direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
if(_startPosX.Value - EntityAirBus.Step > 0)
|
||||
if (_startPosX.Value - EntityPlane.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityAirBus.Step;
|
||||
_startPosX -= (int)EntityPlane.Step;
|
||||
}
|
||||
return true;
|
||||
|
||||
case DirectionType.Up:
|
||||
if(_startPosY.Value - EntityAirBus.Step > 0)
|
||||
if (_startPosY.Value - EntityPlane.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityAirBus.Step;
|
||||
_startPosY -= (int)EntityPlane.Step;
|
||||
}
|
||||
return true;
|
||||
|
||||
case DirectionType.Right:
|
||||
if(_startPosX.Value + EntityAirBus.Step + _drawingAirBusWidth < _pictureWidth.Value )
|
||||
if (_startPosX.Value + EntityPlane.Step + _drawingAirBusWidth < _pictureWidth.Value)
|
||||
{
|
||||
_startPosX += (int)EntityAirBus.Step;
|
||||
_startPosX += (int)EntityPlane.Step;
|
||||
}
|
||||
return true;
|
||||
case DirectionType.Down:
|
||||
if(_startPosY + EntityAirBus.Step + _drawingAirBusHeight < _pictureHeight.Value )
|
||||
if (_startPosY + EntityPlane.Step + _drawingAirBusHeight < _pictureHeight.Value)
|
||||
{
|
||||
_startPosY += (int)EntityAirBus.Step;
|
||||
_startPosY += (int)EntityPlane.Step;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
@ -156,16 +168,15 @@ namespace AirBus
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityAirBus == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
if (EntityPlane == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black, 1);
|
||||
Brush additionalBrush = new SolidBrush(EntityAirBus.AdditionalColor);
|
||||
Brush br = new SolidBrush(EntityAirBus.BodyColor);
|
||||
Brush br = new SolidBrush(EntityPlane.BodyColor);
|
||||
Brush brBlack = new SolidBrush(Color.Black);
|
||||
|
||||
//точки для заднего крыла
|
||||
@ -205,7 +216,7 @@ namespace AirBus
|
||||
g.DrawLine(pen, new Point(_startPosX.Value + 38, _startPosY.Value + 60), new Point(_startPosX.Value + 38, _startPosY.Value + 70)); // стойка заднего шасси
|
||||
g.DrawLine(pen, new Point(_startPosX.Value + 39, _startPosY.Value + 60), new Point(_startPosX.Value + 39, _startPosY.Value + 70)); // стойка заднего шасси
|
||||
g.DrawLine(pen, new Point(_startPosX.Value + 144, _startPosY.Value + 60), new Point(_startPosX.Value + 144, _startPosY.Value + 65)); // стойка переднего шасси
|
||||
|
||||
|
||||
// чёрные заливки
|
||||
g.FillEllipse(brBlack, _startPosX.Value, _startPosY.Value + 30, 10, 10); // заднее крыло
|
||||
g.FillEllipse(brBlack, _startPosX.Value + 15, _startPosY.Value + 30, 10, 10);
|
||||
@ -214,28 +225,6 @@ namespace AirBus
|
||||
g.FillEllipse(brBlack, _startPosX.Value + 50, _startPosY.Value + 45, 7, 7); //крыло
|
||||
g.FillRectangle(brBlack, _startPosX.Value + 54, _startPosY.Value + 45, 55, 7);
|
||||
g.FillEllipse(brBlack, _startPosX.Value + 105, _startPosY.Value + 45, 7, 7);
|
||||
|
||||
if(EntityAirBus.ExtraEngine) // двигатели опционально
|
||||
{
|
||||
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 75, _startPosY.Value + 51, 10, 10);
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 80, _startPosY.Value + 51, 10, 10);
|
||||
g.DrawArc(pen, _startPosX.Value + 75, _startPosY.Value + 51, 10, 10, 90, 180);
|
||||
g.DrawArc(pen, _startPosX.Value + 80, _startPosY.Value + 51, 10, 10, -90, 180);
|
||||
g.DrawLine(pen, new Point(_startPosX.Value + 80, _startPosY.Value + 51), new Point(_startPosX.Value + 85, _startPosY.Value + 51));
|
||||
g.DrawLine(pen, new Point(_startPosX.Value + 80, _startPosY.Value + 61), new Point(_startPosX.Value + 85, _startPosY.Value + 61));
|
||||
}
|
||||
|
||||
if(EntityAirBus.SecondFloor) // пассажирский второй этаж
|
||||
{
|
||||
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 90, _startPosY.Value + 25, 50, 10);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value + 25, 50, 10);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -4,50 +4,27 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBus
|
||||
namespace AirBus.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность "Аэробус"
|
||||
/// </summary>
|
||||
public class EntityAirBus
|
||||
public class EntityAirBus : EntityPlane
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public double Weight { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Цвет корпуса
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дополнительный цвет для опциональных элементов
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия дополнительной пары двигателей
|
||||
/// </summary>
|
||||
public bool ExtraEngine { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия второго этажа
|
||||
/// </summary>
|
||||
public bool SecondFloor { get; private set; }
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Шаг перемещения самолёта
|
||||
/// </summary>
|
||||
public double Step => Speed * 100 / Weight;
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация полей объекта-класса самолёта "Аэробус"
|
||||
@ -58,13 +35,9 @@ namespace AirBus
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="extraEngine">Признак наличия дополнительных пары двигателей</param>
|
||||
/// <param name="secondFloor">Признак наличия второго этажа</param>
|
||||
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor,
|
||||
bool extraEngine, bool secondFloor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
public EntityAirBus(int speed, double weight, Color bodyColor, Color additionalColor,
|
||||
bool extraEngine, bool secondFloor) : base(speed, weight, bodyColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
ExtraEngine = extraEngine;
|
||||
SecondFloor = secondFloor;
|
49
AirBus/AirBus/Entities/EntityPlane.cs
Normal file
49
AirBus/AirBus/Entities/EntityPlane.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBus.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность "Самолёт"
|
||||
/// </summary>
|
||||
public class EntityPlane
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public double Weight { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Цвет корпуса
|
||||
/// </summary>
|
||||
public Color BodyColor { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Шаг перемещения самолёта
|
||||
/// </summary>
|
||||
public double Step => Speed * 100 / Weight;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор сущности Plane
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
public EntityPlane(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
18
AirBus/AirBus/FormAirBus.Designer.cs
generated
18
AirBus/AirBus/FormAirBus.Designer.cs
generated
@ -35,6 +35,7 @@
|
||||
buttonUp = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonCreatePlane = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxAirBus).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -52,9 +53,9 @@
|
||||
buttonCreateAirBus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateAirBus.Location = new Point(12, 427);
|
||||
buttonCreateAirBus.Name = "buttonCreateAirBus";
|
||||
buttonCreateAirBus.Size = new Size(94, 29);
|
||||
buttonCreateAirBus.Size = new Size(305, 29);
|
||||
buttonCreateAirBus.TabIndex = 1;
|
||||
buttonCreateAirBus.Text = "Создать";
|
||||
buttonCreateAirBus.Text = "Создать AirBus";
|
||||
buttonCreateAirBus.UseVisualStyleBackColor = true;
|
||||
buttonCreateAirBus.Click += buttonCreateAirBus_Click;
|
||||
//
|
||||
@ -109,6 +110,17 @@
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonCreatePlane
|
||||
//
|
||||
buttonCreatePlane.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreatePlane.Location = new Point(333, 427);
|
||||
buttonCreatePlane.Name = "buttonCreatePlane";
|
||||
buttonCreatePlane.Size = new Size(305, 29);
|
||||
buttonCreatePlane.TabIndex = 1;
|
||||
buttonCreatePlane.Text = "Создать самолёт";
|
||||
buttonCreatePlane.UseVisualStyleBackColor = true;
|
||||
buttonCreatePlane.Click += buttonCreateAirBus_Click;
|
||||
//
|
||||
// FormAirBus
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
@ -118,6 +130,7 @@
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonCreatePlane);
|
||||
Controls.Add(buttonCreateAirBus);
|
||||
Controls.Add(pictureBoxAirBus);
|
||||
Name = "FormAirBus";
|
||||
@ -134,5 +147,6 @@
|
||||
private Button buttonUp;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private Button buttonCreatePlane;
|
||||
}
|
||||
}
|
@ -7,12 +7,13 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using AirBus.Drawings;
|
||||
|
||||
namespace AirBus;
|
||||
|
||||
public partial class FormAirBus : Form
|
||||
{
|
||||
private DrawingAirBus? _drawingAirBus;
|
||||
private DrawingPlane? _drawingPlane;
|
||||
public FormAirBus()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -20,33 +21,63 @@ public partial class FormAirBus : Form
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawingAirBus == null)
|
||||
if (_drawingPlane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Bitmap bmp = new(pictureBoxAirBus.Width, pictureBoxAirBus.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawingAirBus.DrawTransport(gr);
|
||||
_drawingPlane.DrawTransport(gr);
|
||||
pictureBoxAirBus.Image = bmp;
|
||||
}
|
||||
private void buttonCreateAirBus_Click(object sender, EventArgs e)
|
||||
|
||||
private void CreateObject(string type)
|
||||
{
|
||||
Random random = new();
|
||||
_drawingAirBus = new DrawingAirBus();
|
||||
_drawingAirBus.Init(random.Next(100, 300), random.Next(1000, 3000),
|
||||
switch (type)
|
||||
{
|
||||
case nameof(DrawingPlane):
|
||||
_drawingPlane = new DrawingPlane(random.Next(100, 300), random.Next(1000, 3000),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
|
||||
break;
|
||||
case nameof(DrawingAirBus):
|
||||
_drawingPlane = new DrawingAirBus(random.Next(100, 300), random.Next(1000, 3000),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||
_drawingAirBus.SetPictureSize(pictureBoxAirBus.Width, pictureBoxAirBus.Height);
|
||||
_drawingAirBus.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
_drawingPlane.SetPictureSize(pictureBoxAirBus.Width, pictureBoxAirBus.Height);
|
||||
_drawingPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать Аеробус"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonCreateAirBus_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateObject(nameof(DrawingAirBus));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать самолёт"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonCreatePlane_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateObject(nameof(DrawingPlane));
|
||||
}
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawingAirBus == null)
|
||||
if (_drawingPlane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -56,16 +87,16 @@ public partial class FormAirBus : Form
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
result = _drawingAirBus.MoveTransport(DirectionType.Up);
|
||||
result = _drawingPlane.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
result = _drawingAirBus.MoveTransport(DirectionType.Down);
|
||||
result = _drawingPlane.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
result = _drawingAirBus.MoveTransport(DirectionType.Left);
|
||||
result = _drawingPlane.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
result = _drawingAirBus.MoveTransport(DirectionType.Right);
|
||||
result = _drawingPlane.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user