Готовая 1 лабораторная
This commit is contained in:
parent
ca2322e875
commit
17c57e7c37
28
ProjectMonorail/ProjectMonorail/DirectionType.cs
Normal file
28
ProjectMonorail/ProjectMonorail/DirectionType.cs
Normal file
@ -0,0 +1,28 @@
|
||||
namespace ProjectMonorail
|
||||
{
|
||||
/// <summary>
|
||||
/// Направление перемещения
|
||||
/// </summary>
|
||||
public enum DirectionType
|
||||
{
|
||||
/// <summary>
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
}
|
||||
}
|
236
ProjectMonorail/ProjectMonorail/DrawingMonorail.cs
Normal file
236
ProjectMonorail/ProjectMonorail/DrawingMonorail.cs
Normal file
@ -0,0 +1,236 @@
|
||||
namespace ProjectMonorail
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawingMonorail
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityMonorail? EntityMonorail { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
private int _pictureWidth;
|
||||
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
private int _pictureHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки монорельса
|
||||
/// </summary>
|
||||
private int _startPosX;
|
||||
|
||||
/// <summary>
|
||||
/// Верхняя координата прорисовки монорельса
|
||||
/// </summary>
|
||||
private int _startPosY;
|
||||
|
||||
/// <summary>
|
||||
/// Ширина прорисовки монорельса
|
||||
/// </summary>
|
||||
private int _monorailWidth = 117;
|
||||
|
||||
/// <summary>
|
||||
/// Высота прорисовки монорельса
|
||||
/// </summary>
|
||||
private int _monorailHeight = 56;
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="mainColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="magneticRail">Признак наличия магнитной рельсы</param>
|
||||
/// <param name="extraCabin">Признак наличия дополнительной кабины</param>
|
||||
/// <param name="width">Ширина картинки</param>
|
||||
/// <param name="height">Высота картинки</param>
|
||||
/// <returns>true - объект создан, false - проверка не пройдена,
|
||||
///нельзя создать объект в этих размерах</returns>
|
||||
public bool Init(int speed, double weight, Color mainColor, Color
|
||||
additionalColor, bool magneticRail, bool extraCabin, int width, int height)
|
||||
{
|
||||
if (extraCabin)
|
||||
{
|
||||
_monorailWidth = 183;
|
||||
}
|
||||
if (magneticRail)
|
||||
{
|
||||
_monorailWidth = 186;
|
||||
_monorailHeight = 92;
|
||||
}
|
||||
if (width < _monorailWidth || height < _monorailHeight) { return false; }
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityMonorail = new EntityMonorail();
|
||||
EntityMonorail.Init(speed, weight, mainColor, additionalColor,
|
||||
magneticRail, extraCabin);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Установка позиции
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x < 0 || x + _monorailWidth > _pictureWidth) { x = 0; }
|
||||
if (y < 0 || y + _monorailHeight > _pictureHeight) { y = 0; }
|
||||
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Изменение направления перемещения
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityMonorail == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
//влево
|
||||
case DirectionType.Left:
|
||||
if (_startPosX - EntityMonorail.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityMonorail.Step;
|
||||
}
|
||||
break;
|
||||
//вверх
|
||||
case DirectionType.Up:
|
||||
if (_startPosY - EntityMonorail.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityMonorail.Step;
|
||||
}
|
||||
break;
|
||||
//вправо
|
||||
case DirectionType.Right:
|
||||
if (_startPosX + _monorailWidth + EntityMonorail.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityMonorail.Step;
|
||||
}
|
||||
break;
|
||||
//вниз
|
||||
case DirectionType.Down:
|
||||
if (_startPosY + _monorailHeight + EntityMonorail.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityMonorail.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityMonorail == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen mainPen = new Pen(Color.Black, 2);
|
||||
Pen additionalPen = new(Color.Blue);
|
||||
Brush mainBrush = new SolidBrush(EntityMonorail.MainColor);
|
||||
Brush additionalBrush = new SolidBrush(EntityMonorail.AdditionalColor);
|
||||
Brush brBlue = new SolidBrush(Color.Blue);
|
||||
Brush brBlack = new SolidBrush(Color.Black);
|
||||
Brush brWhite = new SolidBrush(Color.White);
|
||||
Brush brGray = new SolidBrush(Color.Gray);
|
||||
|
||||
//корпус локомотива
|
||||
Point[] locoPoints = { new Point(_startPosX + 29, _startPosY + 15), new Point(_startPosX + 112, _startPosY + 15),
|
||||
new Point(_startPosX + 112, _startPosY + 46), new Point(_startPosX + 25, _startPosY + 46), new Point(_startPosX + 25, _startPosY + 31) };
|
||||
g.FillPolygon(mainBrush, locoPoints);
|
||||
g.DrawPolygon(mainPen, locoPoints);
|
||||
g.DrawLine(additionalPen, _startPosX + 25, _startPosY + 31, _startPosX + 112, _startPosY + 31);
|
||||
|
||||
//дверь локомотива
|
||||
g.FillRectangle(brGray, _startPosX + 54, _startPosY + 21, 7, 20);
|
||||
g.DrawRectangle(mainPen, _startPosX + 54, _startPosY + 21, 7, 20);
|
||||
|
||||
//окна локомотива
|
||||
g.FillRectangle(brBlue, _startPosX + 32, _startPosY + 18, 6, 9);
|
||||
g.DrawRectangle(mainPen, _startPosX + 32, _startPosY + 18, 6, 9);
|
||||
g.FillRectangle(brBlue, _startPosX + 44, _startPosY + 18, 6, 9);
|
||||
g.DrawRectangle(mainPen, _startPosX + 44, _startPosY + 18, 6, 9);
|
||||
g.FillRectangle(brBlue, _startPosX + 103, _startPosY + 18, 6, 9);
|
||||
g.DrawRectangle(mainPen, _startPosX + 103, _startPosY + 18, 6, 9);
|
||||
|
||||
//колеса и тележка локомотива
|
||||
g.FillRectangle(brBlack, _startPosX + 23, _startPosY + 47, 33, 6);
|
||||
g.DrawRectangle(mainPen, _startPosX + 23, _startPosY + 47, 33, 6);
|
||||
g.FillRectangle(brBlack, _startPosX + 76, _startPosY + 47, 30, 6);
|
||||
g.DrawRectangle(mainPen, _startPosX + 76, _startPosY + 47, 30, 6);
|
||||
g.FillEllipse(brWhite, _startPosX + 25, _startPosY + 47, 10, 9);
|
||||
g.DrawEllipse(mainPen, _startPosX + 25, _startPosY + 47, 10, 9);
|
||||
g.FillEllipse(brWhite, _startPosX + 45, _startPosY + 47, 10, 9);
|
||||
g.DrawEllipse(mainPen, _startPosX + 45, _startPosY + 47, 10, 9);
|
||||
g.FillEllipse(brWhite, _startPosX + 75, _startPosY + 47, 10, 9);
|
||||
g.DrawEllipse(mainPen, _startPosX + 75, _startPosY + 47, 10, 9);
|
||||
g.FillEllipse(brWhite, _startPosX + 95, _startPosY + 47, 10, 9);
|
||||
g.DrawEllipse(mainPen, _startPosX + 95, _startPosY + 47, 10, 9);
|
||||
Point[] bogiePoints = { new Point(_startPosX + 26, _startPosY + 46), new Point(_startPosX + 24, _startPosY + 54),
|
||||
new Point(_startPosX + 12, _startPosY + 54), new Point(_startPosX + 8, _startPosY + 51), new Point(_startPosX + 12, _startPosY + 48),
|
||||
new Point(_startPosX + 18, _startPosY + 46) };
|
||||
g.FillPolygon(brBlack, bogiePoints);
|
||||
|
||||
//соединение между кабинами
|
||||
g.DrawRectangle(mainPen, _startPosX + 112, _startPosY + 18, 5, 28);
|
||||
g.FillRectangle(brBlack, _startPosX + 112, _startPosY + 18, 5, 28);
|
||||
|
||||
//магнитная рельса
|
||||
if (EntityMonorail.MagneticRail)
|
||||
{
|
||||
g.DrawRectangle(mainPen, _startPosX + 2, _startPosY + 58, 184, 18);
|
||||
g.FillRectangle(brGray, _startPosX + 2, _startPosY + 58, 184, 18);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
g.DrawRectangle(mainPen, _startPosX + 35 + 35 * i, _startPosY + 77, 8, 15);
|
||||
g.FillRectangle(brGray, _startPosX + 35 + 35 * i, _startPosY + 77, 8, 15);
|
||||
}
|
||||
}
|
||||
|
||||
//дополнительная кабина
|
||||
if (EntityMonorail.ExtraCabin)
|
||||
{
|
||||
//корпус дополнительной кабины
|
||||
g.FillRectangle(mainBrush, _startPosX + 118, _startPosY + 15, 65, 31);
|
||||
g.DrawRectangle(mainPen, _startPosX + 118, _startPosY + 15, 65, 31);
|
||||
g.DrawLine(additionalPen, _startPosX + 118, _startPosY + 31, _startPosX + 183, _startPosY + 31);
|
||||
|
||||
//дверь дополнительной кабины
|
||||
g.FillRectangle(additionalBrush, _startPosX + 146, _startPosY + 21, 7, 20);
|
||||
g.DrawRectangle(mainPen, _startPosX + 146, _startPosY + 21, 7, 20);
|
||||
|
||||
//окна дополнительной кабины
|
||||
g.FillRectangle(brBlue, _startPosX + 130, _startPosY + 18, 6, 9);
|
||||
g.DrawRectangle(mainPen, _startPosX + 130, _startPosY + 18, 6, 9);
|
||||
g.FillRectangle(brBlue, _startPosX + 169, _startPosY + 18, 6, 9);
|
||||
g.DrawRectangle(mainPen, _startPosX + 169, _startPosY + 18, 6, 9);
|
||||
|
||||
//колеса и тележка дополнительной кабины
|
||||
g.FillRectangle(brBlack, _startPosX + 126, _startPosY + 47, 15, 6);
|
||||
g.DrawRectangle(mainPen, _startPosX + 126, _startPosY + 47, 15, 6);
|
||||
g.FillRectangle(brBlack, _startPosX + 159, _startPosY + 47, 15, 6);
|
||||
g.DrawRectangle(mainPen, _startPosX + 159, _startPosY + 47, 15, 6);
|
||||
g.FillEllipse(brWhite, _startPosX + 128, _startPosY + 47, 10, 9);
|
||||
g.DrawEllipse(mainPen, _startPosX + 128, _startPosY + 47, 10, 9);
|
||||
g.FillEllipse(brWhite, _startPosX + 161, _startPosY + 47, 10, 9);
|
||||
g.DrawEllipse(mainPen, _startPosX + 161, _startPosY + 47, 10, 9);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
ProjectMonorail/ProjectMonorail/EntityMonorail.cs
Normal file
60
ProjectMonorail/ProjectMonorail/EntityMonorail.cs
Normal file
@ -0,0 +1,60 @@
|
||||
namespace ProjectMonorail
|
||||
{
|
||||
public class EntityMonorail
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public double Weight { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color MainColor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия магнитной рельсы
|
||||
/// </summary>
|
||||
public bool MagneticRail { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия дополнительной кабины
|
||||
/// </summary>
|
||||
public bool ExtraCabin { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Шаг перемещения монорельса
|
||||
/// </summary>
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация полей объекта-класса монорельса
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес монорельса</param>
|
||||
/// <param name="mainColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="magneticRail">Признак наличия магнитной рельсы</param>
|
||||
/// <param name="extraCabin">Признак наличия дополнительной кабины</param>
|
||||
public void Init(int speed, double weight, Color mainColor, Color
|
||||
additionalColor, bool magneticRail, bool extraCabin)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
MainColor = mainColor;
|
||||
AdditionalColor = additionalColor;
|
||||
MagneticRail = magneticRail;
|
||||
ExtraCabin = extraCabin;
|
||||
}
|
||||
}
|
||||
}
|
39
ProjectMonorail/ProjectMonorail/Form1.Designer.cs
generated
39
ProjectMonorail/ProjectMonorail/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace ProjectMonorail
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <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.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace ProjectMonorail
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
138
ProjectMonorail/ProjectMonorail/FormMonorail.Designer.cs
generated
Normal file
138
ProjectMonorail/ProjectMonorail/FormMonorail.Designer.cs
generated
Normal file
@ -0,0 +1,138 @@
|
||||
namespace ProjectMonorail
|
||||
{
|
||||
partial class FormMonorail
|
||||
{
|
||||
/// <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.pictureBoxMonorail = new System.Windows.Forms.PictureBox();
|
||||
this.buttonCreateMonorail = 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();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxMonorail)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxMonorail
|
||||
//
|
||||
this.pictureBoxMonorail.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxMonorail.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxMonorail.Name = "pictureBoxMonorail";
|
||||
this.pictureBoxMonorail.Size = new System.Drawing.Size(884, 461);
|
||||
this.pictureBoxMonorail.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxMonorail.TabIndex = 0;
|
||||
this.pictureBoxMonorail.TabStop = false;
|
||||
//
|
||||
// buttonCreateMonorail
|
||||
//
|
||||
this.buttonCreateMonorail.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreateMonorail.Location = new System.Drawing.Point(12, 419);
|
||||
this.buttonCreateMonorail.Name = "buttonCreateMonorail";
|
||||
this.buttonCreateMonorail.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCreateMonorail.TabIndex = 1;
|
||||
this.buttonCreateMonorail.Text = "Create";
|
||||
this.buttonCreateMonorail.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateMonorail.Click += new System.EventHandler(this.buttonCreateMonorail_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::ProjectMonorail.Properties.Resources.arrowLeft;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(770, 419);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 2;
|
||||
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::ProjectMonorail.Properties.Resources.arrowDown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonDown.Location = new System.Drawing.Point(806, 419);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 3;
|
||||
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::ProjectMonorail.Properties.Resources.arrowRight;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonRight.Location = new System.Drawing.Point(842, 419);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 4;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.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::ProjectMonorail.Properties.Resources.arrowUp;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonUp.Location = new System.Drawing.Point(806, 383);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 5;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
//
|
||||
// FormMonorail
|
||||
//
|
||||
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.buttonUp);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
this.Controls.Add(this.buttonCreateMonorail);
|
||||
this.Controls.Add(this.pictureBoxMonorail);
|
||||
this.Name = "FormMonorail";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Monorail";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxMonorail)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxMonorail;
|
||||
private Button buttonCreateMonorail;
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private Button buttonUp;
|
||||
}
|
||||
}
|
82
ProjectMonorail/ProjectMonorail/FormMonorail.cs
Normal file
82
ProjectMonorail/ProjectMonorail/FormMonorail.cs
Normal file
@ -0,0 +1,82 @@
|
||||
namespace ProjectMonorail
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма работы с объектом "Монорельс"
|
||||
/// </summary>
|
||||
public partial class FormMonorail : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Поле-объект для прорисовки объекта
|
||||
/// </summary>
|
||||
private DrawingMonorail? _drawingMonorail;
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация формы
|
||||
/// </summary>
|
||||
public FormMonorail()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Метод прорисовки транспорта
|
||||
/// </summary>
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawingMonorail == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxMonorail.Width, pictureBoxMonorail.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawingMonorail.DrawTransport(gr);
|
||||
pictureBoxMonorail.Image = bmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonCreateMonorail_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
_drawingMonorail = new DrawingMonorail();
|
||||
_drawingMonorail.Init(random.Next(300, 500), 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)),
|
||||
pictureBoxMonorail.Width, pictureBoxMonorail.Height);
|
||||
_drawingMonorail.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопок управления движением
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawingMonorail == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawingMonorail.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawingMonorail.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawingMonorail.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawingMonorail.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
@ -26,36 +26,36 @@
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
@ -11,7 +11,7 @@ namespace ProjectMonorail
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new FormMonorail());
|
||||
}
|
||||
}
|
||||
}
|
@ -8,4 +8,19 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
103
ProjectMonorail/ProjectMonorail/Properties/Resources.Designer.cs
generated
Normal file
103
ProjectMonorail/ProjectMonorail/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ProjectMonorail.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectMonorail.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowDown {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowLeft {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowRight {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowUp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
ProjectMonorail/ProjectMonorail/Properties/Resources.resx
Normal file
133
ProjectMonorail/ProjectMonorail/Properties/Resources.resx
Normal file
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="arrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
ProjectMonorail/ProjectMonorail/Resources/arrowDown.png
Normal file
BIN
ProjectMonorail/ProjectMonorail/Resources/arrowDown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 415 B |
BIN
ProjectMonorail/ProjectMonorail/Resources/arrowLeft.png
Normal file
BIN
ProjectMonorail/ProjectMonorail/Resources/arrowLeft.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 411 B |
BIN
ProjectMonorail/ProjectMonorail/Resources/arrowRight.png
Normal file
BIN
ProjectMonorail/ProjectMonorail/Resources/arrowRight.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 352 B |
BIN
ProjectMonorail/ProjectMonorail/Resources/arrowUp.png
Normal file
BIN
ProjectMonorail/ProjectMonorail/Resources/arrowUp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 412 B |
Loading…
Reference in New Issue
Block a user