Kasatkin S.P. LabWork_Hard01 #1

Closed
Sem730 wants to merge 2 commits from LabWork01 into main
17 changed files with 1018 additions and 0 deletions

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectLocomotive_Hard", "ProjectLocomotive_Hard\ProjectLocomotive_Hard.csproj", "{28ABABDC-B05B-4292-89B8-13190ED0F68F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{28ABABDC-B05B-4292-89B8-13190ED0F68F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28ABABDC-B05B-4292-89B8-13190ED0F68F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28ABABDC-B05B-4292-89B8-13190ED0F68F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28ABABDC-B05B-4292-89B8-13190ED0F68F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9EA9A6E7-AC15-460D-8C18-3D73874FFFB1}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLocomotive_Hard
{
internal enum CountWheel
{
Two = 2,
Three = 3,
Four = 4,
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLocomotive_Hard
{
internal enum Direction
{
Up = 1,
Down = 2,
Left = 3,
Right = 4
}
}

View File

@ -0,0 +1,190 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLocomotive_Hard
{
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
internal class DrawningLocomotive
{
/// <summary>
/// Класс-сущность
/// </summary>
public EntityLocomotive Locomotivе { private set; get; }
public DrawningLocomotiveWheel DrawningWheel { get; private set; }
/// <summary>
/// Левая координата отрисовки локомотива
/// </summary>
private float _startPosX;
/// <summary>
/// Верхняя кооридната отрисовки локомотива
/// </summary>
private float _startPosY;
/// <summary>
/// Ширина окна отрисовки
/// </summary>
private int? _pictureWidth = null;
/// <summary>
/// Высота окна отрисовки
/// </summary>
private int? _pictureHeight = null;
/// <summary>
/// Ширина отрисовки локомотива
/// </summary>
private readonly int _LocWidth = 140;
/// <summary>
/// Высота отрисовки локомотива
/// </summary>
private readonly int _LocHeight = 50;
/// <summary>
/// Инициализация свойств
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес локомотива</param>
/// <param name="bodyColor">Цвет кузова</param>
public void Init(int speed, float weight, Color bodyColor)
{
Locomotivе = new EntityLocomotive();
Locomotivе.Init(speed, weight, bodyColor);
DrawningWheel = new();
DrawningWheel.SetCountWheel = 4;
}
/// <summary>
/// Установка позиции автомобиля
/// </summary>
/// <param name="x">Координата X</param>
/// <param name="y">Координата Y</param>
/// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param>
public void SetPosition(int x, int y, int width, int height)
{
// TODO проверки
if (x < 0 || y < 0 || width < x + _LocWidth || height < y + _LocHeight)
{
_pictureHeight = null;
_pictureWidth = null;
return;
}
_startPosX = x;
_startPosY = y;
_pictureWidth = width;
_pictureHeight = height;
}
/// <summary>
/// Изменение направления перемещения
/// </summary>
/// <param name="direction">Направление</param>
public void MoveTransport(Direction direction)
{
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
{
return;
}
switch (direction)
{
// вправо
case Direction.Right:
if (_startPosX + _LocWidth + Locomotivе.Step < _pictureWidth)
{
_startPosX += Locomotivе.Step;
}
break;
//влево
case Direction.Left:
// TODO: Продумать логику
if (_startPosX - Locomotivе.Step > 0)
{
_startPosX -= Locomotivе.Step;
}
break;
//вверх
case Direction.Up:
//TODO: Продумать логику
if (_startPosY - Locomotivе.Step > 0)
{
_startPosY -= Locomotivе.Step;
}
break;
//вниз
case Direction.Down:
if (_startPosY + _LocHeight + Locomotivе.Step < _pictureHeight)
{
_startPosY += Locomotivе.Step;
}
break;
}
}
/// <summary>
/// Отрисовка автомобиля
/// </summary>
/// <param name="g"></param>
public void DrawTransport(Graphics g)
{
if (_startPosX < 0 || _startPosY < 0
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
{
return;
}
Pen pen = new(Color.Black);
// кузов электролокомотива (верхняя часть)
g.DrawLine(pen, _startPosX + 7, _startPosY, _startPosX + 80, _startPosY);
g.DrawLine(pen, _startPosX + 80, _startPosY, _startPosX + 80, _startPosY + 15);
g.DrawLine(pen, _startPosX + 80, _startPosY + 15, _startPosX + 2, _startPosY + 15);
g.DrawLine(pen, _startPosX + 2, _startPosY + 15, _startPosX + 7, _startPosY);
// кузов электролокомотива (нижняя часть)
g.DrawLine(pen, _startPosX + 2, _startPosY + 15, _startPosX + 2, _startPosY + 30);
g.DrawLine(pen, _startPosX + 2, _startPosY + 30, _startPosX + 80, _startPosY + 30);
g.DrawLine(pen, _startPosX + 80, _startPosY + 30, _startPosX + 80, _startPosY + 15);
// колёса электролокомотива
Brush br = new SolidBrush(Locomotivе?.BodyColor ?? Color.Black);
g.FillEllipse(br, _startPosX + 3, _startPosY + 30, 15, 15);
g.FillEllipse(br, _startPosX + 22, _startPosY + 30, 15, 15);
g.FillEllipse(br, _startPosX + 42, _startPosY + 30, 15, 15);
g.FillEllipse(br, _startPosX + 62, _startPosY + 30, 15, 15);
// окна электролокомотива
Brush brBlue = new SolidBrush(Color.Blue);
g.FillRectangle(brBlue, _startPosX + 10, _startPosY + 3, 5, 10);
g.FillRectangle(brBlue, _startPosX + 50, _startPosY + 3, 5, 10);
g.FillRectangle(brBlue, _startPosX + 70, _startPosY + 3, 5, 10);
// дверь электролокомотива
g.DrawLine(pen, _startPosX + 20, _startPosY + 6, _startPosX + 30, _startPosY + 6);
g.DrawLine(pen, _startPosX + 30, _startPosY + 8, _startPosX + 30, _startPosY + 25);
g.DrawLine(pen, _startPosX + 30, _startPosY + 25, _startPosX + 20, _startPosY + 25);
g.DrawLine(pen, _startPosX + 20, _startPosY + 25, _startPosX + 20, _startPosY + 6);
//тележка
g.DrawLine(pen, _startPosX + 80, _startPosY + 25, _startPosX + 140, _startPosY + 25);
g.DrawLine(pen, _startPosX + 140, _startPosY + 25, _startPosX + 140, _startPosY + 10);
g.DrawLine(pen, _startPosX + 140, _startPosY + 10, _startPosX + 90, _startPosY + 10);
g.DrawLine(pen, _startPosX + 90, _startPosY + 10, _startPosX + 90, _startPosY + 25);
DrawningWheel.DrawningWheel(g, _startPosX, _startPosY);
}
/// <summary>
/// Смена границ формы отрисовки
/// </summary>
/// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param>
public void ChangeBorders(int width, int height)
{
_pictureWidth = width;
_pictureHeight = height;
if (_pictureWidth <= _LocWidth || _pictureHeight <= _LocHeight)
{
_pictureWidth = null;
_pictureHeight = null;
return;
}
if (_startPosX + _LocWidth > _pictureWidth)
{
_startPosX = _pictureWidth.Value - _LocWidth;
}
if (_startPosY + _LocHeight > _pictureHeight)
{
_startPosY = _pictureHeight.Value - _LocHeight;
}
}
}
}

View File

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLocomotive_Hard
{
/// <summary>
/// Класс-дополнение к отвечающий за число колёс и их отрисовку
/// </summary>
internal class DrawningLocomotiveWheel
{
/// <summary>Приватное поле содержащие текущее количество палуб</summary>
private CountWheel _countWheel;
/// <summary>
/// Открытое свойство, через которое можно в поле-перечисление занести значение
/// </summary>
public int SetCountWheel
{
set
{
switch (value)
{
case 2:
_countWheel = CountWheel.Two;
break;
case 3:
_countWheel = CountWheel.Three;
break;
case 4:
_countWheel = CountWheel.Four;
break;
default:
_countWheel = CountWheel.Two;
break;
}
}
}
/// <summary>Отрисовывает колёса</summary>
/// <param name="g">The g.</param>
///// <param name="colorDecks">Цвет колёс.</param>
/// <param name="PosX">начальная позиция по x</param>
/// <param name="PosY">начальная позиция по y</param>
public void DrawningWheel(Graphics g, float PosX, float PosY)
{
if ((int)_countWheel == 2)
{
Brush brr = new SolidBrush(Color.Green);
g.FillEllipse(brr, PosX + 95, PosY + 25, 15, 15);
g.FillEllipse(brr, PosX + 120, PosY + 25, 15, 15);
}
if ((int)_countWheel == 3)
{
Brush brr = new SolidBrush(Color.Blue);
g.FillEllipse(brr, PosX + 92, PosY + 25, 13, 13);
g.FillEllipse(brr, PosX + 110, PosY + 25, 13, 13);
g.FillEllipse(brr, PosX + 128, PosY + 25, 13, 13);
}
if ((int)_countWheel == 4)
{
Brush brr = new SolidBrush(Color.HotPink);
g.FillEllipse(brr, PosX + 90, PosY + 25, 10, 10);
g.FillEllipse(brr, PosX + 103, PosY + 25, 10, 10);
g.FillEllipse(brr, PosX + 116, PosY + 25, 10, 10);
g.FillEllipse(brr, PosX + 129, PosY + 25, 10, 10);
}
}
}
}

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLocomotive_Hard
{
internal class EntityLocomotive
{
/// <summary>
/// Скорость
/// </summary>
public int Speed { get; private set; }
/// <summary>
/// Вес
/// </summary>
public float Weight { get; private set; }
/// <summary>
/// Цвет кузова
/// </summary>
public Color BodyColor { get; private set; }
/// <summary>
/// Шаг передвижения локомотива
/// </summary>
public float Step => Speed * 100 / Weight;
/// <summary>
/// Инициализация полей объекта-класса локомотива
/// </summary>
/// <param name="speed"></param>
/// <param name="weight"></param>
/// <param name="bodyColor"></param>
/// <returns></returns>
public void Init(int speed, float weight, Color bodyColor)
{
Random rnd = new();
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
BodyColor = bodyColor;
}
}
}

View File

@ -0,0 +1,228 @@
namespace ProjectLocomotive_Hard
{
partial class FormLocomotive
{
/// <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.pictureBoxLocomotive = new System.Windows.Forms.PictureBox();
this.buttonCreate = new System.Windows.Forms.Button();
this.buttonUp = 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.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
this.statusStrip = new System.Windows.Forms.StatusStrip();
this.labelDecksCount = new System.Windows.Forms.Label();
this.countDecksBox = new System.Windows.Forms.NumericUpDown();
this.toolStripStatusCountDecks = new System.Windows.Forms.ToolStripStatusLabel();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit();
this.statusStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.countDecksBox)).BeginInit();
this.SuspendLayout();
//
// pictureBoxLocomotive
//
this.pictureBoxLocomotive.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxLocomotive.Location = new System.Drawing.Point(0, 0);
this.pictureBoxLocomotive.Name = "pictureBoxLocomotive";
this.pictureBoxLocomotive.Size = new System.Drawing.Size(959, 418);
this.pictureBoxLocomotive.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxLocomotive.TabIndex = 0;
this.pictureBoxLocomotive.TabStop = false;
//
// buttonCreate
//
this.buttonCreate.Location = new System.Drawing.Point(404, 370);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(93, 30);
this.buttonCreate.TabIndex = 2;
this.buttonCreate.Text = "Создать";
this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
//
// buttonUp
//
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.BackgroundImage = global::ProjectLocomotive_Hard.Properties.Resources.up;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(834, 339);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(30, 30);
this.buttonUp.TabIndex = 3;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
this.buttonUp.Resize += new System.EventHandler(this.PictureBoxLocomotive_Resize);
//
// buttonLeft
//
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.BackgroundImage = global::ProjectLocomotive_Hard.Properties.Resources.left;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(798, 374);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
this.buttonLeft.TabIndex = 4;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
this.buttonLeft.Resize += new System.EventHandler(this.PictureBoxLocomotive_Resize);
//
// buttonDown
//
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.BackgroundImage = global::ProjectLocomotive_Hard.Properties.Resources.down;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(834, 373);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(30, 30);
this.buttonDown.TabIndex = 6;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
this.buttonDown.Resize += new System.EventHandler(this.PictureBoxLocomotive_Resize);
//
// buttonRight
//
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRight.BackgroundImage = global::ProjectLocomotive_Hard.Properties.Resources.right;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(870, 375);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(30, 30);
this.buttonRight.TabIndex = 5;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
this.buttonRight.Resize += new System.EventHandler(this.PictureBoxLocomotive_Resize);
//
// toolStripStatusLabelSpeed
//
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(93, 25);
this.toolStripStatusLabelSpeed.Text = "Скорость:";
//
// toolStripStatusLabelWeight
//
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(43, 25);
this.toolStripStatusLabelWeight.Text = "Вес:";
//
// toolStripStatusLabelBodyColor
//
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(55, 25);
this.toolStripStatusLabelBodyColor.Text = "Цвет:";
//
// statusStrip
//
this.statusStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabelSpeed,
this.toolStripStatusLabelWeight,
this.toolStripStatusLabelBodyColor,
this.toolStripStatusCountDecks});
this.statusStrip.Location = new System.Drawing.Point(0, 418);
this.statusStrip.Name = "statusStrip";
this.statusStrip.Size = new System.Drawing.Size(959, 32);
this.statusStrip.TabIndex = 1;
//
// labelDecksCount
//
this.labelDecksCount.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelDecksCount.AutoSize = true;
this.labelDecksCount.Location = new System.Drawing.Point(13, 373);
this.labelDecksCount.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelDecksCount.Name = "labelDecksCount";
this.labelDecksCount.Size = new System.Drawing.Size(162, 25);
this.labelDecksCount.TabIndex = 9;
this.labelDecksCount.Text = "Количество колёс:";
//
// countDecksBox
//
this.countDecksBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.countDecksBox.Location = new System.Drawing.Point(195, 367);
this.countDecksBox.Margin = new System.Windows.Forms.Padding(4);
this.countDecksBox.Maximum = new decimal(new int[] {
4,
0,
0,
0});
this.countDecksBox.Name = "countDecksBox";
this.countDecksBox.Size = new System.Drawing.Size(188, 31);
this.countDecksBox.TabIndex = 10;
this.countDecksBox.Value = new decimal(new int[] {
2,
0,
0,
0});
//
// toolStripStatusCountDecks
//
this.toolStripStatusCountDecks.Name = "toolStripStatusCountDecks";
this.toolStripStatusCountDecks.Size = new System.Drawing.Size(162, 25);
this.toolStripStatusCountDecks.Text = "Количество колёс:";
//
// FormLocomotive
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(959, 450);
this.Controls.Add(this.countDecksBox);
this.Controls.Add(this.labelDecksCount);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.pictureBoxLocomotive);
this.Controls.Add(this.statusStrip);
this.Name = "FormLocomotive";
this.Text = "Локомотив";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).EndInit();
this.statusStrip.ResumeLayout(false);
this.statusStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.countDecksBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private PictureBox pictureBoxLocomotive;
private Button buttonCreate;
private Button buttonUp;
private Button buttonLeft;
private Button buttonDown;
private Button buttonRight;
private ToolStripStatusLabel toolStripStatusLabelSpeed;
private ToolStripStatusLabel toolStripStatusLabelWeight;
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
private StatusStrip statusStrip;
private Label labelDecksCount;
private NumericUpDown countDecksBox;
private ToolStripStatusLabel toolStripStatusCountDecks;
}
}

View File

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectLocomotive_Hard
{
public partial class FormLocomotive : Form
{
private DrawningLocomotive _elloc;
public FormLocomotive()
{
InitializeComponent();
}
/// <summary>
/// Метод прорисовки электролокомотива
/// </summary>
private void Draw()
{
Bitmap bmp = new(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
Graphics gr = Graphics.FromImage(bmp);
_elloc?.DrawTransport(gr);
pictureBoxLocomotive.Image = bmp;
}
/// <summary>
/// Обработка нажатия кнопки "Создать"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
_elloc = new DrawningLocomotive();
_elloc.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_elloc.DrawningWheel.SetCountWheel = ((int)countDecksBox.Value);
_elloc.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
toolStripStatusLabelSpeed.Text = $"Скорость: {_elloc.Locomotivе.Speed}";
toolStripStatusLabelWeight.Text = $"Вес: {_elloc.Locomotivе.Weight}";
toolStripStatusLabelBodyColor.Text = $"Цвет: {_elloc.Locomotivе.BodyColor.Name}";
toolStripStatusCountDecks.Text = $"Количество колёс: {(int)countDecksBox.Value}";
Draw();
}
/// <summary>
/// Изменение размеров формы
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonMove_Click(object sender, EventArgs e)
{
//получаем имя кнопки
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
_elloc?.MoveTransport(Direction.Up);
break;
case "buttonDown":
_elloc?.MoveTransport(Direction.Down);
break;
case "buttonLeft":
_elloc?.MoveTransport(Direction.Left);
break;
case "buttonRight":
_elloc?.MoveTransport(Direction.Right);
break;
}
Draw();
}
/// <summary>
/// Изменение размеров формы
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PictureBoxLocomotive_Resize(object sender, EventArgs e)
{
_elloc?.ChangeBorders(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
Draw();
}
}
}

View File

@ -0,0 +1,63 @@
<root>
<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>
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,17 @@
namespace ProjectLocomotive_Hard
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormLocomotive());
}
}
}

View File

@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<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>

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectLocomotive_Hard.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("ProjectLocomotive_Hard.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 down {
get {
object obj = ResourceManager.GetObject("down", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap left {
get {
object obj = ResourceManager.GetObject("left", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap right {
get {
object obj = ResourceManager.GetObject("right", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap up {
get {
object obj = ResourceManager.GetObject("up", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View 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="down" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="left" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="right" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="up" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB