Добавление родителей и ввод новых конструкторов
This commit is contained in:
parent
46aae7a930
commit
b10750e801
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace monorail;
|
||||
namespace Monorail.Drawnings;
|
||||
/// <summary>
|
||||
/// Направление перемещения
|
||||
/// </summary>
|
67
Monorail/Monorail/Drawnings/DrawningMonorail.cs
Normal file
67
Monorail/Monorail/Drawnings/DrawningMonorail.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using Monorail.Entities;
|
||||
|
||||
namespace Monorail.Drawnings;
|
||||
/// <summary>
|
||||
/// Класс отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawningMonorail : Drawning_Monorail
|
||||
{
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="magneticRail">магнитный рельс</param>
|
||||
/// <param name="secondCabin">Вторая кабинка в задней части</param>
|
||||
|
||||
public DrawningMonorail(int speed, double weight, Color bodyColor, Color additionalColor, bool magneticRail, bool secondCabin) : base(95, 40)
|
||||
{
|
||||
Entity_Monorail = new EntityMonorail(speed, weight, bodyColor, additionalColor, magneticRail, secondCabin);
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (Entity_Monorail == null || Entity_Monorail is not EntityMonorail monorail || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(monorail.AdditionalColor);
|
||||
|
||||
//магнитная рельса
|
||||
if (monorail.MagneticRail)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value + 40, 90, 3);
|
||||
}
|
||||
|
||||
//вторая часть монорельса
|
||||
|
||||
if (monorail.SecondCabin)
|
||||
{
|
||||
Point[] points_second_cabin = {
|
||||
new Point(_startPosX.Value + 85, _startPosY.Value),
|
||||
new Point(_startPosX.Value + 95, _startPosY.Value + 15),
|
||||
new Point(_startPosX.Value + 95, _startPosY.Value + 30),
|
||||
new Point(_startPosX.Value + 85, _startPosY.Value + 30),
|
||||
new Point(_startPosX.Value + 85, _startPosY.Value + 15),
|
||||
new Point(_startPosX.Value + 95, _startPosY.Value + 15)
|
||||
|
||||
};
|
||||
g.DrawPolygon(pen, points_second_cabin);
|
||||
g.FillPolygon(additionalBrush, points_second_cabin);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//_startPosX += 10;
|
||||
//_startPosY += 5;
|
||||
base.DrawTransport(g);
|
||||
//_startPosX -= 10;
|
||||
//_startPosY -= 5;
|
||||
}
|
||||
}
|
@ -1,15 +1,18 @@
|
||||
|
||||
using Monorail.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace monorail;
|
||||
/// <summary>
|
||||
/// Класс отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawningMonorail
|
||||
namespace Monorail.Drawnings;
|
||||
|
||||
public class Drawning_Monorail
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность (объект)
|
||||
/// </summary>
|
||||
public EntityMonorail? EntityMonorail { get; private set; }
|
||||
public Entity_Monorail? Entity_Monorail { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
@ -24,42 +27,62 @@ public class DrawningMonorail
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки монорельса
|
||||
/// </summary>
|
||||
private int? _startPosX;
|
||||
protected int? _startPosX;
|
||||
|
||||
/// <summary>
|
||||
/// Верхняя координата прорисовки монорельса
|
||||
/// </summary>
|
||||
private int? _startPosY;
|
||||
protected int? _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина прорисовки монорельса (размер объекта)
|
||||
/// </summary>
|
||||
private readonly int _drawningMonorailWidth = 95;
|
||||
private readonly int _drawningMonorailWidth = 90;
|
||||
/// <summary>
|
||||
/// Высота прорисовки монорельса (размер объекта)
|
||||
/// </summary>
|
||||
private readonly int _drawingMonorailHeight = 40;
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация свойства
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="magneticRail">магнитный рельс</param>
|
||||
/// <param name="secondCabin">Вторая кабинка в задней части</param>
|
||||
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool magneticRail, bool secondCabin)
|
||||
/// <summary>
|
||||
/// Пустой конструктор
|
||||
/// </summary>
|
||||
private Drawning_Monorail()
|
||||
{
|
||||
EntityMonorail = new EntityMonorail();
|
||||
EntityMonorail.Init(speed, weight, bodyColor, additionalColor, magneticRail, secondCabin);
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Конструтор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
|
||||
|
||||
public Drawning_Monorail(int speed, double weight, Color bodyColor) : this()
|
||||
{
|
||||
Entity_Monorail = new Entity_Monorail(speed, weight, bodyColor);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструтор для наследников
|
||||
/// </summary>
|
||||
/// <param name="drawningMonorailWidth">Ширина прорисовки монорельса (размер объекта)</param>
|
||||
/// <param name="drawingMonorailHeight">Высота прорисовки монорельса (размер объекта)</param>
|
||||
|
||||
|
||||
protected Drawning_Monorail(int drawningMonorailWidth, int drawingMonorailHeight) : this()
|
||||
{
|
||||
_drawningMonorailWidth = drawningMonorailWidth;
|
||||
_drawingMonorailHeight = drawingMonorailHeight;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Установка границ поля
|
||||
/// </summary>
|
||||
@ -141,7 +164,7 @@ public class DrawningMonorail
|
||||
/// <returns>true - перемещение выполнено, false - перемещение невозможно</returns>
|
||||
public bool MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityMonorail == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
if (Entity_Monorail == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -149,33 +172,33 @@ public class DrawningMonorail
|
||||
{
|
||||
//влево
|
||||
case DirectionType.Left:
|
||||
if (_startPosX.Value - EntityMonorail.Step > 0)
|
||||
if (_startPosX.Value - Entity_Monorail.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityMonorail.Step;
|
||||
_startPosX -= (int)Entity_Monorail.Step;
|
||||
}
|
||||
return true;
|
||||
//вверх
|
||||
case DirectionType.Up:
|
||||
if (_startPosY.Value - EntityMonorail.Step > 0)
|
||||
if (_startPosY.Value - Entity_Monorail.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityMonorail.Step;
|
||||
_startPosY -= (int)Entity_Monorail.Step;
|
||||
}
|
||||
return true;
|
||||
// вправо
|
||||
case DirectionType.Right:
|
||||
// TODO прописать логику сдвига в право
|
||||
if (_startPosX.Value + EntityMonorail.Step + _drawningMonorailWidth < _pictureWidth)
|
||||
if (_startPosX.Value + Entity_Monorail.Step + _drawningMonorailWidth < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityMonorail.Step;
|
||||
_startPosX += (int)Entity_Monorail.Step;
|
||||
}
|
||||
|
||||
return true;
|
||||
//вниз
|
||||
case DirectionType.Down:
|
||||
//TODO прописать логику сдвига в вниз
|
||||
if (_startPosY.Value + EntityMonorail.Step + _drawingMonorailHeight < _pictureHeight)
|
||||
if (_startPosY.Value + Entity_Monorail.Step + _drawingMonorailHeight < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityMonorail.Step;
|
||||
_startPosY += (int)Entity_Monorail.Step;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
@ -189,43 +212,20 @@ public class DrawningMonorail
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
///
|
||||
public void DrawTransport(Graphics g)
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityMonorail == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
if (Entity_Monorail == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(EntityMonorail.AdditionalColor);
|
||||
|
||||
//магнитная рельса
|
||||
if (EntityMonorail.MagneticRail)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value + 40, 90, 3);
|
||||
}
|
||||
|
||||
//вторая часть монорельса
|
||||
|
||||
if (EntityMonorail.SecondCabin)
|
||||
{
|
||||
Point[] points_second_cabin = {
|
||||
new Point(_startPosX.Value + 85, _startPosY.Value),
|
||||
new Point(_startPosX.Value + 95, _startPosY.Value + 15),
|
||||
new Point(_startPosX.Value + 95, _startPosY.Value + 30),
|
||||
new Point(_startPosX.Value + 85, _startPosY.Value + 30),
|
||||
new Point(_startPosX.Value + 85, _startPosY.Value + 15),
|
||||
new Point(_startPosX.Value + 95, _startPosY.Value + 15)
|
||||
|
||||
};
|
||||
g.DrawPolygon(pen, points_second_cabin);
|
||||
g.FillPolygon(additionalBrush, points_second_cabin);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//границы Монорельса
|
||||
Brush br = new SolidBrush(EntityMonorail.BodyColor);
|
||||
Brush br = new SolidBrush(Entity_Monorail.BodyColor);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value + 15, 80, 15);
|
||||
Point[] points1 = {
|
||||
new Point(_startPosX.Value + 15, _startPosY.Value),
|
||||
@ -244,7 +244,7 @@ public class DrawningMonorail
|
||||
new Point(_startPosX.Value + 84, _startPosY.Value + 1),
|
||||
new Point(_startPosX.Value + 84, _startPosY.Value + 14),
|
||||
new Point(_startPosX.Value + 6, _startPosY.Value + 14)
|
||||
};
|
||||
};
|
||||
|
||||
g.FillPolygon(br, points2);
|
||||
|
||||
@ -266,7 +266,7 @@ public class DrawningMonorail
|
||||
//1-ый держатель
|
||||
|
||||
Point[] points_cart1 = {
|
||||
new Point(_startPosX.Value, _startPosY.Value + 35),
|
||||
new Point(_startPosX.Value + 5, _startPosY.Value + 30),
|
||||
new Point(_startPosX.Value + 15, _startPosY.Value + 35),
|
||||
new Point(_startPosX.Value + 15, _startPosY.Value + 30),
|
||||
new Point(_startPosX.Value + 5, _startPosY.Value + 30)
|
||||
@ -330,4 +330,4 @@ public class DrawningMonorail
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +1,9 @@
|
||||
namespace monorail;
|
||||
namespace Monorail.Entities;
|
||||
/// <summary>
|
||||
/// Класс-сущность "Монорельс"
|
||||
/// </summary>
|
||||
public class EntityMonorail
|
||||
public class EntityMonorail : Entity_Monorail
|
||||
{
|
||||
/// <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>
|
||||
@ -30,11 +18,7 @@ public class EntityMonorail
|
||||
public bool SecondCabin { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// шаг
|
||||
/// </summary>
|
||||
public double Step => Speed * 100 / Weight;
|
||||
/// <summary>
|
||||
/// Инициализация полей объекта-класса монорельса
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
@ -42,7 +26,8 @@ public class EntityMonorail
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="magneticRail">признак наличие рельса</param>
|
||||
/// <param name="secondCabin">признак вторая кабинка</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool magneticRail, bool secondCabin)
|
||||
|
||||
public EntityMonorail(int speed, double weight, Color bodyColor, Color additionalColor, bool magneticRail, bool secondCabin) : base(speed, weight, bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
@ -50,5 +35,13 @@ public class EntityMonorail
|
||||
AdditionalColor = additionalColor;
|
||||
MagneticRail = magneticRail;
|
||||
SecondCabin = secondCabin;
|
||||
|
||||
}
|
||||
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool magneticRail, bool secondCabin)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
MagneticRail = magneticRail;
|
||||
SecondCabin = secondCabin;
|
||||
}
|
||||
}
|
48
Monorail/Monorail/Entities/Entity_Monorail.cs
Normal file
48
Monorail/Monorail/Entities/Entity_Monorail.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Monorail.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Класс-сущносить "Монорельс"
|
||||
/// </summary>
|
||||
public class Entity_Monorail
|
||||
{
|
||||
/// <summary>
|
||||
/// скорость
|
||||
/// </summary>
|
||||
public int Speed { get; set; }
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public double Weight { get; set; }
|
||||
/// <summary>
|
||||
/// основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// шаг
|
||||
/// </summary>
|
||||
public double Step => Speed * 100 / Weight;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор сущности
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
|
||||
public Entity_Monorail(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
|
||||
}
|
||||
|
||||
}
|
17
Monorail/Monorail/FormMonorail.Designer.cs
generated
17
Monorail/Monorail/FormMonorail.Designer.cs
generated
@ -34,6 +34,7 @@
|
||||
buttonDown = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonCreateMonorail = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1Monorail).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -51,9 +52,9 @@
|
||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreate.Location = new Point(10, 358);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(75, 23);
|
||||
buttonCreate.Size = new Size(221, 23);
|
||||
buttonCreate.TabIndex = 1;
|
||||
buttonCreate.Text = "создать";
|
||||
buttonCreate.Text = "создать монорельс";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += buttonCreate_Click;
|
||||
//
|
||||
@ -105,11 +106,22 @@
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonCreateMonorail
|
||||
//
|
||||
buttonCreateMonorail.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateMonorail.Location = new Point(247, 358);
|
||||
buttonCreateMonorail.Name = "buttonCreateMonorail";
|
||||
buttonCreateMonorail.Size = new Size(221, 23);
|
||||
buttonCreateMonorail.TabIndex = 6;
|
||||
buttonCreateMonorail.Text = "создать monorail";
|
||||
buttonCreateMonorail.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormMonorail
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(755, 393);
|
||||
Controls.Add(buttonCreateMonorail);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonDown);
|
||||
@ -130,5 +142,6 @@
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private Button buttonUp;
|
||||
private Button buttonCreateMonorail;
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using monorail;
|
||||
using Monorail.Drawnings;
|
||||
|
||||
namespace Monorail;
|
||||
/// <summary>
|
||||
/// Форма работы с объектом "Монорельс"
|
||||
@ -8,7 +9,8 @@ public partial class FormMonorail : Form
|
||||
/// <summary>
|
||||
/// Поле-объект для прорисовки объекта
|
||||
/// </summary>
|
||||
private DrawningMonorail? _drawningMonorail;
|
||||
private Drawning_Monorail? _drawning_Monorail;
|
||||
|
||||
/// <summary>
|
||||
/// конструктор формы
|
||||
/// </summary>
|
||||
@ -21,46 +23,70 @@ public partial class FormMonorail : Form
|
||||
/// </summary>
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningMonorail == null)
|
||||
if (_drawning_Monorail == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Bitmap bmp = new(pictureBox1Monorail.Width, pictureBox1Monorail.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningMonorail.DrawTransport(gr);
|
||||
_drawning_Monorail.DrawTransport(gr);
|
||||
pictureBox1Monorail.Image = bmp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void FormMonorail_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void CreateObject(string type)
|
||||
{
|
||||
Random random = new();
|
||||
switch (type)
|
||||
{
|
||||
case nameof(Drawning_Monorail):
|
||||
_drawning_Monorail = new Drawning_Monorail(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(DrawningMonorail):
|
||||
_drawning_Monorail = new DrawningMonorail(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)));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
_drawning_Monorail.SetPictureSize(pictureBox1Monorail.Width, pictureBox1Monorail.Height);
|
||||
_drawning_Monorail.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
//_strategy = null;
|
||||
//comboBoxStrategy.Enabled = true;
|
||||
Draw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать"
|
||||
/// Обработка нажатия кнопки "Создать Монорельс"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
_drawningMonorail = new DrawningMonorail();
|
||||
_drawningMonorail.Init(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)));
|
||||
_drawningMonorail.SetPictureSize(pictureBox1Monorail.Width, pictureBox1Monorail.Height);
|
||||
_drawningMonorail.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
private void buttonCreate_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningMonorail));
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать _Монорельс"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreateMonorail_Click(object sender, EventArgs e) => CreateObject(nameof(Drawning_Monorail));
|
||||
|
||||
Bitmap bmp = new(pictureBox1Monorail.Width, pictureBox1Monorail.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningMonorail.DrawTransport(gr);
|
||||
pictureBox1Monorail.Image = bmp;
|
||||
Draw();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перемещение объекта по форме (нажатие кнопок навигации)
|
||||
@ -69,7 +95,7 @@ public partial class FormMonorail : Form
|
||||
/// <param name="e"></param>
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningMonorail == null)
|
||||
if (_drawning_Monorail == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -79,16 +105,16 @@ public partial class FormMonorail : Form
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
result = _drawningMonorail.MoveTransport(DirectionType.Up);
|
||||
result = _drawning_Monorail.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
result = _drawningMonorail.MoveTransport(DirectionType.Down);
|
||||
result = _drawning_Monorail.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
result = _drawningMonorail.MoveTransport(DirectionType.Left);
|
||||
result = _drawning_Monorail.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
result = _drawningMonorail.MoveTransport(DirectionType.Right);
|
||||
result = _drawning_Monorail.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
if (result)
|
||||
@ -97,4 +123,6 @@ public partial class FormMonorail : Form
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user