Compare commits

...

16 Commits

Author SHA1 Message Date
bekodeg
59a0baa1aa изменение статуса TUDO 2023-11-08 08:47:24 +04:00
bekodeg
d03960db79 изменение кнопки на лямбду и исправление бага с добавлением ничего 2023-11-07 12:23:36 +04:00
bekodeg
e5a45732e9 5 работа работает 2023-11-06 20:02:11 +04:00
bekodeg
26a589af93 копирование кода из пдф 2023-11-04 13:18:36 +04:00
bekodeg
c6059a9dfa 4 работа финал 2023-11-04 11:34:17 +04:00
bekodeg
85704d9e33 завершение 4 работы 2023-10-25 11:03:02 +04:00
bekodeg
0d25d56f0f изменение на колекции 2023-10-25 10:36:16 +04:00
bekodeg
74ad587062 промежуточный результат 2023-10-25 10:25:50 +04:00
bekodeg
ddcceff03f перегрузка сложения и вычитания 2023-10-25 09:50:26 +04:00
bekodeg
7880fc1215 исправление порядка добавления 2023-10-25 09:06:28 +04:00
bekodeg
d2e990ba5a небольшая коркктировка названий 2023-10-24 14:59:56 +04:00
bekodeg
7583b8b681 финал 3 работа 2023-10-23 20:14:39 +04:00
bekodeg
d25d9a4ea5 создание стратегии дохождения до границы, обновление формы и подключение нового функционала к элементам управления 2023-10-13 10:40:45 +04:00
bekodeg
5eaaca5971 создание базовых и дочерних классов для хранения отрисовки и логики перемещения объектов 2023-10-10 19:30:57 +04:00
15d9fc266c удаление пустого класса 2023-09-27 10:24:29 +04:00
bekodeg
ea5160cb05 первая работа 2023-09-27 09:51:02 +04:00
36 changed files with 3402 additions and 0 deletions

25
ElectricLocomotive.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectElectricLocomotive", "ElectricLocomotive\ProjectElectricLocomotive.csproj", "{F2E231D6-98A4-412A-952D-87456DBD3E48}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F2E231D6-98A4-412A-952D-87456DBD3E48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2E231D6-98A4-412A-952D-87456DBD3E48}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2E231D6-98A4-412A-952D-87456DBD3E48}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2E231D6-98A4-412A-952D-87456DBD3E48}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6E3B9EE7-DD4B-4BFD-BDE8-4A29F694592B}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive;
/// <summary>
/// Направление перемещения
/// </summary>
public enum DirectionType
{
/// <summary>
/// Вверх
/// /// </summary>
Up = 1,
/// <summary>
/// Вниз
/// </summary>
Down = 2,
/// <summary>
/// Влево
/// </summary>
Left = 3,
/// <summary>
/// Вправо
/// </summary>
Right = 4
}

View File

@ -0,0 +1,68 @@
using ProjectElectricLocomotive.Entities;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net.NetworkInformation;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.DrawningObjects
{
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawningElectricLocomotive : DrawningLocomotive
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="horns">Признак наличия рогов</param>
/// <param name="battery">Признак наличия отсека для батарей</param>
/// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param>
public DrawningElectricLocomotive(int speed, double weight, Color bodyColor,
Color additionalColor, bool horns, bool battery, int width, int height) :
base(speed, weight, bodyColor, width, height, 120, 70)
{
if (EntityLocomotive != null)
{
EntityLocomotive = new EntityElectricLocomotive(speed, weight, bodyColor, additionalColor, horns, battery);
}
}
public override void DrawTransport(Graphics g)
{
if (EntityLocomotive is not EntityElectricLocomotive electricLocomotive)
{
return;
}
base.DrawTransport(g);
Pen pen = new(Color.Black, 5);
Brush brush = new SolidBrush(EntityLocomotive.BodyColor);
Point[] points;
// рога
if (electricLocomotive.Horns)
{
pen = new(Color.Black, 2);
points = new Point[4];
points[0] = new Point(_startPosX + 50, _startPosY + 20);
points[1] = new Point(_startPosX + 40, _startPosY + 10);
points[2] = new Point(_startPosX + 50, _startPosY);
points[3] = new Point(_startPosX + 60, _startPosY + 10);
g.DrawPolygon(pen, points);
}
// отсек для батарей
if (electricLocomotive.Battery)
{
brush = new SolidBrush(electricLocomotive.AdditionalColor);
g.FillRectangle(brush, _startPosX + 80, _startPosY + 45, 35, 9);
}
}
}
}

View File

@ -0,0 +1,220 @@
using ProjectElectricLocomotive.Entities;
using ProjectElectricLocomotive;
using ProjectElectricLocomotive.MovementStrategy;
namespace ProjectElectricLocomotive.DrawningObjects
{
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawningLocomotive
{
/// <summary>
/// Класс-сущность
/// </summary>
public EntityLocomotive? EntityLocomotive { get; protected set; }
/// <summary>
/// Ширина окна
/// </summary>
protected int _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
protected int _pictureHeight;
/// <summary>
/// Левая координата прорисовки автомобиля
/// </summary>
protected int _startPosX;
/// <summary>
/// Верхняя кооридната прорисовки автомобиля
/// </summary>
protected int _startPosY;
/// <summary>
/// Ширина прорисовки автомобиля
/// </summary>
protected readonly int _locomotiveWidth = 120;
/// <summary>
/// Высота прорисовки автомобиля
/// </summary>
protected readonly int _locomotiveHeight = 70;
/// <summary>
/// Координата X объекта
/// </summary>
public int GetPosX => _startPosX;
/// <summary>
/// Координата Y объекта
/// </summary>
public int GetPosY => _startPosY;
/// <summary>
/// Ширина объекта
/// </summary>
public int GetWidth => _locomotiveWidth;
/// <summary>
/// Высота объекта
/// </summary>
public int GetHeight => _locomotiveHeight;
/// <summary>
/// Получение объекта IMoveableObject из объекта DrawningLocomotive
/// </summary>
public IMoveableObject GetMoveableObject => new DrawningObjectLocomotive(this);
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param>
/// <returns>true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах</returns>
public DrawningLocomotive(int speed, double weight, Color bodyColor, int width, int height)
{
if (width < _locomotiveWidth || height < _locomotiveHeight)
{
return;
}
_pictureWidth = width;
_pictureHeight = height;
EntityLocomotive = new EntityLocomotive(speed, weight, bodyColor);
}
public DrawningLocomotive(int speed, double weight, Color bodyColor,
int width, int height, int locomotiveWidth, int locomotiveHeight)
{
if (width < _locomotiveWidth || height < _locomotiveHeight)
{
return;
}
_pictureWidth = width;
_pictureHeight = height;
_locomotiveWidth = locomotiveWidth;
_locomotiveHeight = locomotiveHeight;
EntityLocomotive = new EntityLocomotive(speed, weight, bodyColor);
}
/// <summary>
/// Установка позиции
/// </summary>
/// <param name="x">Координата X</param>
/// <param name="y">Координата Y</param>
public void SetPosition(int x, int y)
{
x = Math.Min(Math.Max(0, x), _pictureWidth - _locomotiveWidth);
y = Math.Min(Math.Max(0, y), _pictureHeight - _locomotiveHeight);
_startPosX = x;
_startPosY = y;
}
/// <summary>
/// Прорисовка объекта
/// </summary>
/// <param name="g"></param>
public virtual void DrawTransport(Graphics g)
{
if (EntityLocomotive == null)
{
return;
}
// корпус электровоза
Pen pen = new(Color.Black, 5);
Brush brush = new SolidBrush(EntityLocomotive.BodyColor);
Point[] points = new Point[5];
points[0] = new Point(_startPosX, _startPosY + 40);
points[1] = new Point(_startPosX + 10, _startPosY + 20);
points[2] = new Point(_startPosX + 120, _startPosY + 20);
points[3] = new Point(_startPosX + 120, _startPosY + 60);
points[4] = new Point(_startPosX, _startPosY + 60);
g.FillPolygon(brush, points);
g.DrawLine(pen,
new Point(_startPosX, _startPosY + 40),
new Point(_startPosX + 120, _startPosY + 40));
// окна
brush = new SolidBrush(Color.FromArgb(0, 162, 232));
g.FillRectangle(brush, _startPosX + 12, _startPosY + 24, 30, 11);
g.FillEllipse(brush, _startPosX + 55, _startPosY + 24, 11, 11);
g.FillEllipse(brush, _startPosX + 75, _startPosY + 24, 11, 11);
g.FillEllipse(brush, _startPosX + 95, _startPosY + 24, 11, 11);
// колёса
brush = new SolidBrush(Color.Black);
g.FillEllipse(brush, _startPosX + 10, _startPosY + 55, 15, 15);
g.FillEllipse(brush, _startPosX + 25, _startPosY + 55, 15, 15);
g.FillEllipse(brush, _startPosX + 80, _startPosY + 55, 15, 15);
g.FillEllipse(brush, _startPosX + 95, _startPosY + 55, 15, 15);
}
/// <summary>
/// Изменение размера поля
/// </summary>
/// <param name="newSize">Новый размер</param>
public void SetPictureSize(Size newSize)
{
_pictureHeight = newSize.Height;
_pictureWidth = newSize.Width;
}
/// <summary>
/// Проверка, что объект может переместится по указанному направлению
/// </summary>
/// <param name="direction">Направление</param>
/// <returns>true - можно переместится по указанному направлению</returns>
public bool CanMove(DirectionType direction)
{
if (EntityLocomotive == null)
{
return false;
}
return direction switch
{
//влево
DirectionType.Left => _startPosX - EntityLocomotive.Step > 0,
//вверх
DirectionType.Up => _startPosY - EntityLocomotive.Step > 0,
// вправо
DirectionType.Right => _startPosX + _locomotiveWidth + EntityLocomotive.Step < _pictureWidth,
//вниз
DirectionType.Down => _startPosY + _locomotiveHeight + EntityLocomotive.Step < _pictureHeight,
_ => false,
};
}
/// <summary>
/// Изменение направления перемещения
/// </summary>
/// <param name="direction">Направление</param>
public void MoveTransport(DirectionType direction)
{
if (!CanMove(direction) || EntityLocomotive == null)
{
return;
}
switch (direction)
{
//влево
case DirectionType.Left:
_startPosX -= (int)EntityLocomotive.Step;
break;
//вверх
case DirectionType.Up:
_startPosY -= (int)EntityLocomotive.Step;
break;
// вправо
case DirectionType.Right:
_startPosX += (int)EntityLocomotive.Step;
break;
//вниз
case DirectionType.Down:
_startPosY += (int)EntityLocomotive.Step;
break;
}
}
}
}

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.Entities
{
/// <summary>
/// Класс-сущность "Электровоз"
/// </summary>
public class EntityElectricLocomotive : EntityLocomotive
{
/// <summary>
/// Дополнительный цвет (для опциональных элементов)
/// </summary>
public Color AdditionalColor { get; private set; }
/// <summary>
/// Признак (опция) наличия рогов
/// </summary>
public bool Horns { get; private set; }
/// <summary>
/// Признак (опция) наличия отсека для батарей
/// </summary>
public bool Battery { get; private set; }
/// <summary>
/// Инициализация полей объекта-класса спортивного автомобиля
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Веc поезда</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="horns">Признак наличия рогов</param>
/// <param name="battery">Признак наличия отсека для батарей</param>
public EntityElectricLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool horns, bool battery) :
base(speed, weight, bodyColor)
{
AdditionalColor = additionalColor;
Horns = horns;
Battery = battery;
}
public void ChangeAdditionalColor(Color additionalColor)
{
AdditionalColor = additionalColor;
}
}
}

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.Entities
{
/// <summary>
/// Класс-сущность "Поезд"
/// </summary>
public class EntityLocomotive
{
/// <summary>
/// Скорость
/// </summary>
public int Speed { get; private set; }
/// <summary>
/// Вес
/// </summary>
public double Weight { get; private set; }
/// <summary>
/// Основной цвет
/// </summary>
public Color BodyColor { get; private set; }
/// <summary>
/// Шаг перемещения автомобиля
/// </summary>
public double Step => (double)Speed * 100 / Weight;
/// <summary>
/// Конструктор с параметрами
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес поезда</param>
/// <param name="bodyColor">Основной цвет</param>
public EntityLocomotive(int speed, double weight, Color bodyColor)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
}
public void ChangeBodyColor(Color color)
{
BodyColor = color;
}
}
}

View File

@ -0,0 +1,208 @@
namespace ProjectElectricLocomotive
{
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()
{
buttonUp = new Button();
buttonRight = new Button();
buttonCreateLocomotive = new Button();
buttonDown = new Button();
buttonLeft = new Button();
pictureBoxElectricLocomotive = new PictureBox();
buttonCreateElectricLocomotive = new Button();
comboBoxStrategy = new ComboBox();
buttonStep = new Button();
buttonSelectLocomotive = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxElectricLocomotive).BeginInit();
SuspendLayout();
//
// buttonUp
//
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonUp.BackgroundImage = Properties.Resources.arrowUp;
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
buttonUp.Location = new Point(54, 514);
buttonUp.Margin = new Padding(3, 4, 3, 4);
buttonUp.Name = "buttonUp";
buttonUp.Size = new Size(34, 40);
buttonUp.TabIndex = 0;
buttonUp.Text = "\r\n";
buttonUp.UseVisualStyleBackColor = true;
buttonUp.Click += buttonUp_Click;
//
// buttonRight
//
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonRight.BackgroundImage = Properties.Resources.arrowRight;
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
buttonRight.Location = new Point(95, 562);
buttonRight.Margin = new Padding(3, 4, 3, 4);
buttonRight.Name = "buttonRight";
buttonRight.Size = new Size(34, 40);
buttonRight.TabIndex = 1;
buttonRight.Text = "\r\n";
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += buttonRight_Click;
//
// buttonCreateLocomotive
//
buttonCreateLocomotive.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCreateLocomotive.Location = new Point(816, 514);
buttonCreateLocomotive.Margin = new Padding(3, 4, 3, 4);
buttonCreateLocomotive.Name = "buttonCreateLocomotive";
buttonCreateLocomotive.Size = new Size(182, 40);
buttonCreateLocomotive.TabIndex = 2;
buttonCreateLocomotive.Text = "создать локомотив";
buttonCreateLocomotive.UseVisualStyleBackColor = true;
buttonCreateLocomotive.Click += buttonCreateLocomotive_Click;
//
// buttonDown
//
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonDown.BackgroundImage = Properties.Resources.arrowDown;
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
buttonDown.Location = new Point(54, 562);
buttonDown.Margin = new Padding(3, 4, 3, 4);
buttonDown.Name = "buttonDown";
buttonDown.Size = new Size(34, 40);
buttonDown.TabIndex = 3;
buttonDown.Text = "\r\n";
buttonDown.UseVisualStyleBackColor = true;
buttonDown.Click += buttonDown_Click;
//
// buttonLeft
//
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
buttonLeft.Location = new Point(13, 562);
buttonLeft.Margin = new Padding(3, 4, 3, 4);
buttonLeft.Name = "buttonLeft";
buttonLeft.Size = new Size(34, 40);
buttonLeft.TabIndex = 4;
buttonLeft.Text = "\r\n";
buttonLeft.UseVisualStyleBackColor = true;
buttonLeft.Click += buttonLeft_Click;
//
// pictureBoxElectricLocomotive
//
pictureBoxElectricLocomotive.Dock = DockStyle.Fill;
pictureBoxElectricLocomotive.Location = new Point(0, 0);
pictureBoxElectricLocomotive.Name = "pictureBoxElectricLocomotive";
pictureBoxElectricLocomotive.Size = new Size(1010, 615);
pictureBoxElectricLocomotive.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBoxElectricLocomotive.TabIndex = 5;
pictureBoxElectricLocomotive.TabStop = false;
pictureBoxElectricLocomotive.SizeChanged += pictureBoxElectricLocomotive_SizeChanged;
//
// buttonCreateElectricLocomotive
//
buttonCreateElectricLocomotive.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCreateElectricLocomotive.Location = new Point(816, 466);
buttonCreateElectricLocomotive.Margin = new Padding(3, 4, 3, 4);
buttonCreateElectricLocomotive.Name = "buttonCreateElectricLocomotive";
buttonCreateElectricLocomotive.Size = new Size(182, 40);
buttonCreateElectricLocomotive.TabIndex = 6;
buttonCreateElectricLocomotive.Text = "создать электропоезд";
buttonCreateElectricLocomotive.UseVisualStyleBackColor = true;
buttonCreateElectricLocomotive.Click += buttonCreateElectricLocomotive_Click;
//
// comboBoxStrategy
//
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxStrategy.FormattingEnabled = true;
comboBoxStrategy.Items.AddRange(new object[] { "идти к центру экрана", "идти к краю экрана" });
comboBoxStrategy.Location = new Point(816, 12);
comboBoxStrategy.Name = "comboBoxStrategy";
comboBoxStrategy.Size = new Size(182, 28);
comboBoxStrategy.TabIndex = 7;
//
// buttonStep
//
buttonStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonStep.Location = new Point(915, 47);
buttonStep.Margin = new Padding(3, 4, 3, 4);
buttonStep.Name = "buttonStep";
buttonStep.Size = new Size(83, 33);
buttonStep.TabIndex = 8;
buttonStep.Text = "шаг";
buttonStep.UseVisualStyleBackColor = true;
buttonStep.Click += buttonStep_Click;
//
// buttonSelectLocomotive
//
buttonSelectLocomotive.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonSelectLocomotive.Location = new Point(816, 562);
buttonSelectLocomotive.Margin = new Padding(3, 4, 3, 4);
buttonSelectLocomotive.Name = "buttonSelectLocomotive";
buttonSelectLocomotive.Size = new Size(182, 40);
buttonSelectLocomotive.TabIndex = 9;
buttonSelectLocomotive.Text = "выбрать";
buttonSelectLocomotive.UseVisualStyleBackColor = true;
buttonSelectLocomotive.Click += buttonSelectLocomotive_Click;
//
// FormLocomotive
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1010, 615);
Controls.Add(buttonSelectLocomotive);
Controls.Add(buttonStep);
Controls.Add(comboBoxStrategy);
Controls.Add(buttonCreateElectricLocomotive);
Controls.Add(buttonLeft);
Controls.Add(buttonDown);
Controls.Add(buttonCreateLocomotive);
Controls.Add(buttonRight);
Controls.Add(buttonUp);
Controls.Add(pictureBoxElectricLocomotive);
Margin = new Padding(3, 4, 3, 4);
MinimumSize = new Size(500, 300);
Name = "FormLocomotive";
Text = "ElectricLocomotive";
((System.ComponentModel.ISupportInitialize)pictureBoxElectricLocomotive).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonUp;
private Button buttonRight;
private Button buttonCreateLocomotive;
private Button buttonDown;
private Button buttonLeft;
private PictureBox pictureBoxElectricLocomotive;
private Button buttonCreateElectricLocomotive;
private ComboBox comboBoxStrategy;
private Button buttonStep;
private Button button1;
private Button buttonSelectLocomotive;
}
}

View File

@ -0,0 +1,50 @@
namespace ProjectElectricLocomotive
{
public partial class FormLocomotive : Form
{
private void buttonCreateLocomotive_Click(object sender, EventArgs e)
{
ButtonCreateLocomotive_Click(sender, e);
}
private void buttonUp_Click(object sender, EventArgs e)
{
ButtonMove_Click(sender, e);
}
private void buttonDown_Click(object sender, EventArgs e)
{
ButtonMove_Click(sender, e);
}
private void buttonLeft_Click(object sender, EventArgs e)
{
ButtonMove_Click(sender, e);
}
private void buttonRight_Click(object sender, EventArgs e)
{
ButtonMove_Click(sender, e);
}
private void pictureBoxElectricLocomotive_SizeChanged(object sender, EventArgs e)
{
PictureBoxElectricLocomotive_SizeChanged(sender, e);
}
private void buttonStep_Click(object sender, EventArgs e)
{
ButtonnStartegyStep_Click(sender, e);
}
private void buttonCreateElectricLocomotive_Click(object sender, EventArgs e)
{
ButtonCreateElectricLocomotive_Click(sender, e);
}
private void buttonSelectLocomotive_Click(object sender, EventArgs e)
{
ButtonSelectLocomotive_Click(sender, e);
}
}
}

View File

@ -0,0 +1,120 @@
<?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>
</root>

View File

@ -0,0 +1,215 @@
namespace ProjectElectricLocomotive
{
partial class FormLocomotiveCollection
{
/// <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()
{
tableLayoutPanel1 = new TableLayoutPanel();
pictureBoxCollection = new PictureBox();
groupBox1 = new GroupBox();
groupBox2 = new GroupBox();
buttonDelObject = new Button();
listBoxStorages = new ListBox();
buttonAddObject = new Button();
textBoxStorageName = new TextBox();
maskedTextBoxNumber = new MaskedTextBox();
buttonRefreshCollection = new Button();
buttonRemoveLocomotive = new Button();
buttonAddLocomotive = new Button();
tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
groupBox1.SuspendLayout();
groupBox2.SuspendLayout();
SuspendLayout();
//
// tableLayoutPanel1
//
tableLayoutPanel1.AutoSize = true;
tableLayoutPanel1.ColumnCount = 2;
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel1.Controls.Add(pictureBoxCollection, 0, 0);
tableLayoutPanel1.Controls.Add(groupBox1, 1, 0);
tableLayoutPanel1.Dock = DockStyle.Fill;
tableLayoutPanel1.Location = new Point(0, 0);
tableLayoutPanel1.Name = "tableLayoutPanel1";
tableLayoutPanel1.RowCount = 1;
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.Size = new Size(885, 449);
tableLayoutPanel1.TabIndex = 0;
//
// pictureBoxCollection
//
pictureBoxCollection.Dock = DockStyle.Fill;
pictureBoxCollection.Location = new Point(3, 3);
pictureBoxCollection.MinimumSize = new Size(100, 100);
pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(673, 444);
pictureBoxCollection.TabIndex = 1;
pictureBoxCollection.TabStop = false;
//
// groupBox1
//
groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
groupBox1.Controls.Add(groupBox2);
groupBox1.Controls.Add(maskedTextBoxNumber);
groupBox1.Controls.Add(buttonRefreshCollection);
groupBox1.Controls.Add(buttonRemoveLocomotive);
groupBox1.Controls.Add(buttonAddLocomotive);
groupBox1.Location = new Point(682, 3);
groupBox1.MaximumSize = new Size(200, 1000000);
groupBox1.MinimumSize = new Size(200, 200);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(200, 444);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "Инструменты";
//
// groupBox2
//
groupBox2.Controls.Add(buttonDelObject);
groupBox2.Controls.Add(listBoxStorages);
groupBox2.Controls.Add(buttonAddObject);
groupBox2.Controls.Add(textBoxStorageName);
groupBox2.Location = new Point(6, 26);
groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(188, 244);
groupBox2.TabIndex = 5;
groupBox2.TabStop = false;
groupBox2.Text = "Наборы";
//
// buttonDelObject
//
buttonDelObject.Location = new Point(4, 204);
buttonDelObject.Name = "buttonDelObject";
buttonDelObject.Size = new Size(176, 29);
buttonDelObject.TabIndex = 3;
buttonDelObject.Text = "Удалить набор";
buttonDelObject.UseVisualStyleBackColor = true;
buttonDelObject.Click += buttonDelObject_Click;
//
// listBoxStorages
//
listBoxStorages.FormattingEnabled = true;
listBoxStorages.ItemHeight = 20;
listBoxStorages.Location = new Point(6, 94);
listBoxStorages.Name = "listBoxStorages";
listBoxStorages.Size = new Size(174, 104);
listBoxStorages.TabIndex = 2;
listBoxStorages.SelectedIndexChanged += listBoxStorages_SelectedIndexChanged;
//
// buttonAddObject
//
buttonAddObject.Location = new Point(4, 59);
buttonAddObject.Name = "buttonAddObject";
buttonAddObject.Size = new Size(176, 29);
buttonAddObject.TabIndex = 1;
buttonAddObject.Text = "Добавить набор";
buttonAddObject.UseVisualStyleBackColor = true;
buttonAddObject.Click += buttonAddObject_Click;
//
// textBoxStorageName
//
textBoxStorageName.Location = new Point(6, 26);
textBoxStorageName.Name = "textBoxStorageName";
textBoxStorageName.Size = new Size(176, 27);
textBoxStorageName.TabIndex = 0;
//
// maskedTextBoxNumber
//
maskedTextBoxNumber.Location = new Point(10, 328);
maskedTextBoxNumber.Mask = "00000";
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
maskedTextBoxNumber.Size = new Size(184, 27);
maskedTextBoxNumber.TabIndex = 4;
maskedTextBoxNumber.ValidatingType = typeof(int);
//
// buttonRefreshCollection
//
buttonRefreshCollection.Location = new Point(10, 396);
buttonRefreshCollection.Name = "buttonRefreshCollection";
buttonRefreshCollection.Size = new Size(184, 29);
buttonRefreshCollection.TabIndex = 3;
buttonRefreshCollection.Text = "Обновить колекцию";
buttonRefreshCollection.UseVisualStyleBackColor = true;
buttonRefreshCollection.Click += buttonRefreshCollection_Click;
//
// buttonRemoveLocomotive
//
buttonRemoveLocomotive.Location = new Point(10, 361);
buttonRemoveLocomotive.Name = "buttonRemoveLocomotive";
buttonRemoveLocomotive.Size = new Size(184, 29);
buttonRemoveLocomotive.TabIndex = 2;
buttonRemoveLocomotive.Text = "Удалить локомотив";
buttonRemoveLocomotive.UseVisualStyleBackColor = true;
buttonRemoveLocomotive.Click += buttonRemoveLocomotive_Click;
//
// buttonAddLocomotive
//
buttonAddLocomotive.Location = new Point(10, 293);
buttonAddLocomotive.Name = "buttonAddLocomotive";
buttonAddLocomotive.Size = new Size(184, 29);
buttonAddLocomotive.TabIndex = 0;
buttonAddLocomotive.Text = "Добавить локомотив";
buttonAddLocomotive.UseVisualStyleBackColor = true;
buttonAddLocomotive.Click += buttonAddLocomotive_Click;
//
// FormLocomotiveCollection
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(885, 449);
Controls.Add(tableLayoutPanel1);
MinimumSize = new Size(700, 400);
Name = "FormLocomotiveCollection";
Text = "FormLocomotiveCollection";
tableLayoutPanel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
groupBox1.ResumeLayout(false);
groupBox1.PerformLayout();
groupBox2.ResumeLayout(false);
groupBox2.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private TableLayoutPanel tableLayoutPanel1;
private GroupBox groupBox1;
private Button buttonAddLocomotive;
private PictureBox pictureBoxCollection;
private Button buttonRemoveLocomotive;
private Button buttonRefreshCollection;
private MaskedTextBox maskedTextBoxNumber;
private GroupBox groupBox2;
private TextBox textBoxStorageName;
private Button buttonAddObject;
private ListBox listBoxStorages;
private Button buttonDelObject;
}
}

View File

@ -0,0 +1,44 @@
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 ProjectElectricLocomotive
{
public partial class FormLocomotiveCollection
{
private void buttonAddLocomotive_Click(object sender, EventArgs e)
{
ButtonAddLocomotive_Click(sender, e);
}
private void buttonRemoveLocomotive_Click(object sender, EventArgs e)
{
ButtonRemoveLocomotive_Click(sender, e);
}
private void buttonRefreshCollection_Click(object sender, EventArgs e)
{
ButtonRefreshCollection_Click(sender, e);
}
private void buttonAddObject_Click(object sender, EventArgs e)
{
ButtonAddObject_Click(sender, e);
}
private void buttonDelObject_Click(object sender, EventArgs e)
{
ButtonDelObject_Click(sender, e);
}
private void listBoxStorages_SelectedIndexChanged(object sender, EventArgs e)
{
ListBoxObjects_SelectedIndexChanged(sender, e);
}
}
}

View File

@ -0,0 +1,120 @@
<?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>
</root>

View File

@ -0,0 +1,364 @@
namespace ProjectElectricLocomotive
{
partial class FormLocomotiveConfig
{
/// <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()
{
groupBox1 = new GroupBox();
labelModifiedObject = new Label();
labelSimpleObject = new Label();
groupBox2 = new GroupBox();
panelPurple = new Panel();
panelBlack = new Panel();
panelGray = new Panel();
panelWhite = new Panel();
panelYellow = new Panel();
panelBlue = new Panel();
panelGreen = new Panel();
panelRed = new Panel();
checkBoxBattery = new CheckBox();
checkBoxHorns = new CheckBox();
numericUpDownWeight = new NumericUpDown();
numericUpDownSpeed = new NumericUpDown();
label2 = new Label();
label1 = new Label();
pictureBoxObject = new PictureBox();
labelBodyColor = new Label();
labelAdditionalColor = new Label();
buttonOK = new Button();
buttonClose = new Button();
panelObject = new Panel();
groupBox1.SuspendLayout();
groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
panelObject.SuspendLayout();
SuspendLayout();
//
// groupBox1
//
groupBox1.Controls.Add(labelModifiedObject);
groupBox1.Controls.Add(labelSimpleObject);
groupBox1.Controls.Add(groupBox2);
groupBox1.Controls.Add(checkBoxBattery);
groupBox1.Controls.Add(checkBoxHorns);
groupBox1.Controls.Add(numericUpDownWeight);
groupBox1.Controls.Add(numericUpDownSpeed);
groupBox1.Controls.Add(label2);
groupBox1.Controls.Add(label1);
groupBox1.Location = new Point(12, 31);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(568, 293);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "Параметры";
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(397, 219);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(113, 35);
labelModifiedObject.TabIndex = 8;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
labelModifiedObject.MouseDown += labelObject_MouseDown;
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(278, 219);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(113, 35);
labelSimpleObject.TabIndex = 7;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += labelObject_MouseDown;
//
// groupBox2
//
groupBox2.Controls.Add(panelPurple);
groupBox2.Controls.Add(panelBlack);
groupBox2.Controls.Add(panelGray);
groupBox2.Controls.Add(panelWhite);
groupBox2.Controls.Add(panelYellow);
groupBox2.Controls.Add(panelBlue);
groupBox2.Controls.Add(panelGreen);
groupBox2.Controls.Add(panelRed);
groupBox2.Location = new Point(278, 57);
groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(239, 135);
groupBox2.TabIndex = 6;
groupBox2.TabStop = false;
groupBox2.Text = "Цвета";
//
// panelPurple
//
panelPurple.BackColor = Color.Purple;
panelPurple.Location = new Point(184, 81);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(40, 40);
panelPurple.TabIndex = 3;
panelPurple.MouseDown += panelObject_MouseDown;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(129, 81);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(40, 40);
panelBlack.TabIndex = 3;
panelBlack.MouseDown += panelObject_MouseDown;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(73, 81);
panelGray.Name = "panelGray";
panelGray.Size = new Size(40, 40);
panelGray.TabIndex = 3;
panelGray.MouseDown += panelObject_MouseDown;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(15, 81);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(40, 40);
panelWhite.TabIndex = 4;
panelWhite.MouseDown += panelObject_MouseDown;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(184, 26);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(40, 40);
panelYellow.TabIndex = 3;
panelYellow.MouseDown += panelObject_MouseDown;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(129, 26);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(40, 40);
panelBlue.TabIndex = 2;
panelBlue.MouseDown += panelObject_MouseDown;
//
// panelGreen
//
panelGreen.BackColor = Color.Green;
panelGreen.Location = new Point(73, 26);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(40, 40);
panelGreen.TabIndex = 1;
panelGreen.MouseDown += panelObject_MouseDown;
//
// panelRed
//
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(15, 26);
panelRed.Name = "panelRed";
panelRed.Size = new Size(40, 40);
panelRed.TabIndex = 0;
panelRed.MouseDown += panelObject_MouseDown;
//
// checkBoxBattery
//
checkBoxBattery.AutoSize = true;
checkBoxBattery.Location = new Point(27, 230);
checkBoxBattery.Name = "checkBoxBattery";
checkBoxBattery.Size = new Size(215, 24);
checkBoxBattery.TabIndex = 5;
checkBoxBattery.Text = "Признак наличия батареи";
checkBoxBattery.UseVisualStyleBackColor = true;
//
// checkBoxHorns
//
checkBoxHorns.AutoSize = true;
checkBoxHorns.Location = new Point(27, 186);
checkBoxHorns.Name = "checkBoxHorns";
checkBoxHorns.Size = new Size(199, 24);
checkBoxHorns.TabIndex = 4;
checkBoxHorns.Text = "Признак наличия рогов";
checkBoxHorns.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(109, 105);
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownWeight.Name = "numericUpDownWeight";
numericUpDownWeight.Size = new Size(86, 27);
numericUpDownWeight.TabIndex = 3;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(109, 57);
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownSpeed.Name = "numericUpDownSpeed";
numericUpDownSpeed.Size = new Size(86, 27);
numericUpDownSpeed.TabIndex = 2;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(27, 107);
label2.Name = "label2";
label2.Size = new Size(36, 20);
label2.TabIndex = 1;
label2.Text = "Вес:";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(27, 59);
label1.Name = "label1";
label1.Size = new Size(76, 20);
label1.TabIndex = 0;
label1.Text = "Скорость:";
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(11, 60);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(244, 194);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
// labelBodyColor
//
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(11, 14);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(113, 35);
labelBodyColor.TabIndex = 8;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
labelBodyColor.DragEnter += labelObject_DragEnter;
//
// labelAdditionalColor
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(142, 14);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(113, 35);
labelAdditionalColor.TabIndex = 9;
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
labelAdditionalColor.DragEnter += labelObject_DragEnter;
//
// buttonOK
//
buttonOK.Location = new Point(608, 295);
buttonOK.Name = "buttonOK";
buttonOK.Size = new Size(113, 29);
buttonOK.TabIndex = 10;
buttonOK.Text = "Добавить";
buttonOK.UseVisualStyleBackColor = true;
buttonOK.Click += buttonOk_Click;
//
// buttonClose
//
buttonClose.Location = new Point(739, 295);
buttonClose.Name = "buttonClose";
buttonClose.Size = new Size(113, 29);
buttonClose.TabIndex = 11;
buttonClose.Text = "Отмена";
buttonClose.UseVisualStyleBackColor = true;
//
// panelObject
//
panelObject.AllowDrop = true;
panelObject.Controls.Add(labelAdditionalColor);
panelObject.Controls.Add(pictureBoxObject);
panelObject.Controls.Add(labelBodyColor);
panelObject.Location = new Point(597, 31);
panelObject.Name = "panelObject";
panelObject.Size = new Size(266, 254);
panelObject.TabIndex = 12;
panelObject.DragDrop += panelObject_DragDrop;
panelObject.DragEnter += panelObject_DragEnter;
//
// FormLocomotiveConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(911, 339);
Controls.Add(buttonClose);
Controls.Add(buttonOK);
Controls.Add(groupBox1);
Controls.Add(panelObject);
Name = "FormLocomotiveConfig";
Text = "FormLocomotiveConfig";
groupBox1.ResumeLayout(false);
groupBox1.PerformLayout();
groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
panelObject.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private GroupBox groupBox1;
private Label label1;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Label label2;
private CheckBox checkBoxBattery;
private CheckBox checkBoxHorns;
private GroupBox groupBox2;
private Panel panelRed;
private Panel panelPurple;
private Panel panelBlack;
private Panel panelGray;
private Panel panelWhite;
private Panel panelYellow;
private Panel panelBlue;
private Panel panelGreen;
private Label labelModifiedObject;
private Label labelSimpleObject;
private PictureBox pictureBoxObject;
private Label labelBodyColor;
private Label labelAdditionalColor;
private Button buttonOK;
private Button buttonClose;
private Panel panelObject;
}
}

View File

@ -0,0 +1,54 @@
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 ProjectElectricLocomotive
{
public partial class FormLocomotiveConfig
{
private void labelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
}
private void panelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
}
private void panelObject_DragEnter(object sender, DragEventArgs e)
{
PanelObject_DragEnter(sender, e);
}
private void labelObject_DragEnter(object sender, DragEventArgs e)
{
LabelObject_DragEnter(sender, e);
}
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
{
LabelBodyColor_DragDrop(sender, e);
}
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
LabelAdditionalColor_DragDrop(sender, e);
}
private void panelObject_DragDrop(object sender, DragEventArgs e)
{
PanelObject_DragDrop(sender, e);
}
private void buttonOk_Click(object sender, EventArgs e)
{
ButtonOk_Click(sender, e);
}
}
}

View File

@ -0,0 +1,120 @@
<?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>
</root>

View File

@ -0,0 +1,150 @@
using ProjectElectricLocomotive.DrawningObjects;
using ProjectElectricLocomotive.MovementStrategy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.Generics
{
/// <summary>
/// Параметризованный класс для набора объектов DrawningLocomotive
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="U"></typeparam>
internal class LocomotivesGenericCollection<T, U>
where T : DrawningLocomotive
where U : IMoveableObject
{
/// <summary>
/// Ширина окна прорисовки
/// </summary>
private readonly int _pictureWidth;
/// <summary>
/// Высота окна прорисовки
/// </summary>
private readonly int _pictureHeight;
/// <summary>
/// Размер занимаемого объектом места (ширина)
/// </summary>
private readonly int _placeSizeWidth = 210;
/// <summary>
/// Размер занимаемого объектом места (высота)
/// </summary>
private readonly int _placeSizeHeight = 90;
/// <summary>
/// Набор объектов
/// </summary>
private readonly SetGeneric<T> _collection;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
public LocomotivesGenericCollection(int picWidth, int picHeight)
{
int width = picWidth / _placeSizeWidth;
int height = picHeight / _placeSizeHeight;
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = new SetGeneric<T>(width * height);
}
/// <summary>
/// Перегрузка оператора сложения
/// </summary>
/// <param name="collect"></param>
/// <param name="obj"></param>
/// <returns></returns>
public static int operator +(LocomotivesGenericCollection<T, U> collect, T? obj)
{
if (obj == null)
{
return 0;
}
if (collect?._collection.Insert(obj) ?? false)
{
return collect._collection.Count;
}
return 0;
}
/// <summary>
/// Перегрузка оператора вычитания
/// </summary>
/// <param name="collect"></param>
/// <param name="pos"></param>
/// <returns></returns>
public static int operator -(LocomotivesGenericCollection<T, U> collect, int
pos)
{
T? obj = collect._collection[pos];
if (obj != null && collect._collection.Remove(pos))
{
return collect._collection.Count;
}
return -1;
}
/// <summary>
/// Получение объекта IMoveableObject
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
public U? GetU(int pos)
{
return (U?)_collection[pos]?.GetMoveableObject;
}
/// <summary>
/// Вывод всего набора объектов
/// </summary>
/// <returns></returns>
public Bitmap ShowLocomotives()
{
Bitmap bmp = new(_pictureWidth, _pictureHeight);
Graphics gr = Graphics.FromImage(bmp);
DrawBackground(gr);
DrawObjects(gr);
return bmp;
}
/// <summary>
/// Метод отрисовки фона
/// </summary>
/// <param name="g"></param>
private void DrawBackground(Graphics g)
{
Pen pen = new(Color.Black, 3);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
1; ++j)
{
//линия рамзетки места
g.DrawLine(pen, i * _placeSizeWidth, j *
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
_placeSizeHeight);
}
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
}
}
/// <summary>
/// Метод прорисовки объектов
/// </summary>
/// <param name="g"></param>
private void DrawObjects(Graphics g)
{
int ColumnCount = _pictureWidth / _placeSizeWidth;
int RowsCount = _pictureHeight / _placeSizeHeight;
int pos = 0;
foreach (var locomotive in _collection.GetLocomotives())
{
if (locomotive != null)
{
locomotive.SetPosition((pos % ColumnCount) * _placeSizeWidth, ((RowsCount - pos / ColumnCount - 1) * _placeSizeHeight));
locomotive.DrawTransport(g);
++pos;
}
}
}
}
}

View File

@ -0,0 +1,96 @@
using ProjectElectricLocomotive.DrawningObjects;
using ProjectElectricLocomotive.MovementStrategy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace ProjectElectricLocomotive.Generics
{
/// <summary>
/// Класс для хранения коллекции
/// </summary>
internal class LocomotivesGenericStorage
{
/// <summary>
/// Словарь (хранилище)
/// </summary>
readonly Dictionary<string, LocomotivesGenericCollection<
DrawningLocomotive, DrawningObjectLocomotive>
> _locomotiveStorage;
/// <summary>
/// Возвращение списка названий наборов
/// </summary>
public List<string> Keys => _locomotiveStorage.Keys.ToList();
/// <summary>
/// Ширина окна отрисовки
/// </summary>
private readonly int _pictureWidth;
/// <summary>
/// Высота окна отрисовки
/// </summary>
private readonly int _pictureHeight;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="pictureWidth"></param>
/// <param name="pictureHeight"></param>
public LocomotivesGenericStorage(int pictureWidth, int pictureHeight)
{
_locomotiveStorage = new Dictionary<string,
LocomotivesGenericCollection<DrawningLocomotive,
DrawningObjectLocomotive>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
/// <summary>
/// Добавление набора
/// </summary>
/// <param name="name">Название набора</param>
public void AddSet(string name)
{
if (Keys.Contains(name))
{
return;
};
_locomotiveStorage.Add(name,
new LocomotivesGenericCollection<
DrawningLocomotive, DrawningObjectLocomotive>(
_pictureWidth, _pictureHeight));
}
/// <summary>
/// Удаление набора
/// </summary>
/// <param name="name">Название набора</param>
public void DelSet(string name)
{
if (Keys.Contains(name))
{
_locomotiveStorage.Remove(name);
}
}
/// <summary>
/// Доступ к набору
/// </summary>
/// <param name="ind"></param>
/// <returns></returns>
public LocomotivesGenericCollection<DrawningLocomotive,
DrawningObjectLocomotive>? this[string ind]
{
get
{
if (Keys.Contains(ind))
{
return _locomotiveStorage[ind];
}
return null;
}
}
}
}

View File

@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.Generics
{
/// <summary>
/// Параметризованный набор объектов
/// </summary>
/// <typeparam name="T"></typeparam>
internal class SetGeneric<T>
where T : class
{
/// <summary>
/// Список объектов, которые храним
/// </summary>
private readonly List<T?> _places;
/// <summary>
/// Количество объектов в массиве
/// </summary>
public int Count => _places.Count;
/// <summary>
/// Максимальное количество объектов в списке
/// </summary>
private readonly int _maxCount;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="count"></param>
public SetGeneric(int count)
{
_maxCount = count;
_places = new List<T?>(count);
}
/// <summary>
/// Добавление объекта в набор
/// </summary>
/// <param name="locomotive">Добавляемый локомотив</param>
/// <returns></returns>
public bool Insert(T locomotive)
{
if (_places.Count >= _maxCount) {
return false;
}
_places.Insert(0, locomotive);
return true;
}
/// <summary>
/// Добавление объекта в набор на конкретную позицию
/// </summary>
/// <param name="locomotive">Добавляемый поезд</param>
/// <param name="position">Позиция</param>
/// <returns></returns>
public bool Insert(T locomotive, int position)
{
if (_places.Count >= _maxCount || position >= 0 || position <= _places.Count)
{
return false;
}
_places.Insert(position, locomotive);
return true;
}
/// <summary>
/// Удаление объекта из набора с конкретной позиции
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
public bool Remove(int position)
{
if (position >= Count || position < 0)
{
return false;
}
_places.RemoveAt(position);
return true;
}
/// <summary>
/// Получение объекта из набора по позиции
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
public T? this[int position]
{
get
{
if (position >= Count || position < 0)
{
return null;
}
return _places[position];
}
set
{
if (position < Count || position >= 0)
{
_places[position] = value;
}
}
}
/// <summary>
/// Проход по списку
/// </summary>
/// <returns></returns>
public IEnumerable<T?> GetLocomotives(int? maxLocomotives = null)
{
for (int i = 0; i < _places.Count; ++i)
{
yield return _places[i];
if (maxLocomotives.HasValue && i == maxLocomotives.Value)
{
yield break;
}
}
}
}
}

View File

@ -0,0 +1,221 @@
using ProjectElectricLocomotive.DrawningObjects;
using ProjectElectricLocomotive.MovementStrategy;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive
{
/// <summary>
/// Форма работы с объектом "электровоз"
/// </summary>
public partial class FormLocomotive
{
/// <summary>
/// Поле-объект для прорисовки объекта
/// <summary>
private DrawningLocomotive? _drawningLocomotive;
/// <summary>
/// Стратегия перемещения
/// </summary>
private AbstractStrategy? _strategy;
/// <summary>
/// Выбранный электровоз
/// </summary>
public DrawningLocomotive? SelectedLocomotive { get; private set; }
/// <summary>
/// Инициализация формы
/// </summary>
public FormLocomotive()
{
InitializeComponent();
_strategy = null;
SelectedLocomotive = null;
}
/// <summary>
/// Метод прорисовки локомотива
/// </summary>
private void Draw()
{
if (_drawningLocomotive == null)
{
return;
}
Bitmap bmp = new(pictureBoxElectricLocomotive.Width,
pictureBoxElectricLocomotive.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningLocomotive.DrawTransport(gr);
pictureBoxElectricLocomotive.Image = bmp;
}
/// Обработка нажатия кнопки "Создать электровоз"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreateElectricLocomotive_Click(object sender, EventArgs e)
{
Random random = new();
Color bodyColor = Color.FromArgb(
random.Next(0, 256),
random.Next(0, 256),
random.Next(0, 256));
Color additionalColor = Color.FromArgb(
random.Next(0, 256),
random.Next(0, 256),
random.Next(0, 256));
ColorDialog dialog;
dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
bodyColor = dialog.Color;
}
dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
additionalColor = dialog.Color;
}
_drawningLocomotive = new DrawningElectricLocomotive(
random.Next(100, 300),
random.Next(1000, 3000),
bodyColor,
additionalColor,
Convert.ToBoolean(random.Next(0, 2)),
Convert.ToBoolean(random.Next(0, 2)),
pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height);
_drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
/// <summary>
/// Обработка нажатия кнопки "Создать локомотив"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreateLocomotive_Click(object sender, EventArgs e)
{
Random random = new();
Color color = Color.FromArgb(
random.Next(0, 256),
random.Next(0, 256),
random.Next(0, 256));
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
color = dialog.Color;
}
_drawningLocomotive = new DrawningLocomotive(
random.Next(100, 300),
random.Next(1000, 3000),
color,
pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height);
_drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
/// <summary>
/// Изменение размеров формы
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PictureBoxElectricLocomotive_SizeChanged(object sender, EventArgs e)
{
Size size = ((PictureBox)sender)?.Size ?? Size.Empty;
if (_strategy != null)
{
_strategy.SetFieldSize(size);
}
if (_drawningLocomotive != null)
{
_drawningLocomotive.SetPictureSize(size);
}
}
/// <summary>
/// Изменение положения автомобиля
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_drawningLocomotive == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
_drawningLocomotive.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
_drawningLocomotive.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
_drawningLocomotive.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
_drawningLocomotive.MoveTransport(DirectionType.Right);
break;
}
Draw();
}
/// <summary>
/// Шаг стратегии перемещения
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonnStartegyStep_Click(object sender, EventArgs e)
{
if (_drawningLocomotive == null)
{
return;
}
if (comboBoxStrategy.Enabled)
{
_strategy = comboBoxStrategy.SelectedIndex switch
{
0 => new MoveToCenter(),
1 => new MoveToBorder(),
_ => null,
};
if (_strategy == null)
{
return;
}
_strategy.SetData(
_drawningLocomotive.GetMoveableObject,
pictureBoxElectricLocomotive.Width,
pictureBoxElectricLocomotive.Height
);
}
if (_strategy == null)
{
return;
}
comboBoxStrategy.Enabled = false;
_strategy.MakeStep();
Draw();
if (_strategy.GetStatus() == Status.Finish)
{
comboBoxStrategy.Enabled = true;
_strategy = null;
}
}
/// <summary>
/// Выбор локомотива
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonSelectLocomotive_Click(object sender, EventArgs e)
{
SelectedLocomotive = _drawningLocomotive;
DialogResult = DialogResult.OK;
}
}
}

View File

@ -0,0 +1,195 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectElectricLocomotive.DrawningObjects;
using ProjectElectricLocomotive.Generics;
using ProjectElectricLocomotive.MovementStrategy;
namespace ProjectElectricLocomotive
{
/// <summary>
/// Форма для работы с набором объектов класса DrawningLocomotive
/// </summary>
public partial class FormLocomotiveCollection : Form
{
/// <summary>
/// Набор объектов
/// </summary>
private readonly LocomotivesGenericStorage _storage;
/// <summary>
/// Конструктор
/// </summary>
public FormLocomotiveCollection()
{
InitializeComponent();
_storage = new LocomotivesGenericStorage(
pictureBoxCollection.Width,
pictureBoxCollection.Height
);
}
/// <summary>
/// Заполнение listBoxObjects
/// </summary>
private void ReloadObjects()
{
int index = listBoxStorages.SelectedIndex;
listBoxStorages.Items.Clear();
for (int i = 0; i < _storage.Keys.Count; i++)
{
listBoxStorages.Items.Add(_storage.Keys[i]);
}
if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
{
listBoxStorages.SelectedIndex = 0;
}
else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count)
{
listBoxStorages.SelectedIndex = index;
}
}
/// <summary>
/// Добавление набора в коллекцию
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddObject_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxStorageName.Text))
{
MessageBox.Show("Не все данные заполнены", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_storage.AddSet(textBoxStorageName.Text);
ReloadObjects();
}
/// <summary>
/// Выбор набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ListBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
{
pictureBoxCollection.Image =
_storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowLocomotives();
}
/// <summary>
/// Удаление набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonDelObject_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?",
"Удаление", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
_storage.DelSet(listBoxStorages.SelectedItem.ToString() ?? string.Empty);
ReloadObjects();
}
}
/// <summary>
/// Добавление объекта в набор
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddLocomotive_Click(object sender, EventArgs e)
{
var formLocomotiveConfig = new FormLocomotiveConfig();
formLocomotiveConfig.AddEvent(addLocomotive);
formLocomotiveConfig.Show();
}
private void addLocomotive(DrawningLocomotive SelectedLocomotive)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
SelectedLocomotive.SetPictureSize(pictureBoxCollection.Size);
if (obj + SelectedLocomotive > 0)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowLocomotives();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
/// <summary>
/// Удаление объекта из набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonRemoveLocomotive_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
if (MessageBox.Show(
"Удалить объект?", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos;
try
{
pos = Convert.ToInt32(maskedTextBoxNumber.Text);
} catch(System.FormatException ex)
{
pos = 0;
}
if (obj - pos != -1)
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = obj.ShowLocomotives();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
/// <summary>
/// Обновление рисунка по набору
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
pictureBoxCollection.Image = obj.ShowLocomotives();
}
}
}

View File

@ -0,0 +1,201 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectElectricLocomotive.DrawningObjects;
using ProjectElectricLocomotive.Entities;
namespace ProjectElectricLocomotive
{
partial class FormLocomotiveConfig : Form
{
/// <summary>
/// Переменная-выбранный локомотив
/// </summary>
DrawningLocomotive? _locomotive = null;
/// <summary>
/// Событие
/// </summary>
private event Action<DrawningLocomotive>? EventAddLocomotive;
/// <summary>
/// Конструктор
/// </summary>
public FormLocomotiveConfig()
{
InitializeComponent();
panelBlack.MouseDown += PanelColor_MouseDown;
panelPurple.MouseDown += PanelColor_MouseDown;
panelGray.MouseDown += PanelColor_MouseDown;
panelGreen.MouseDown += PanelColor_MouseDown;
panelRed.MouseDown += PanelColor_MouseDown;
panelWhite.MouseDown += PanelColor_MouseDown;
panelYellow.MouseDown += PanelColor_MouseDown;
panelBlue.MouseDown += PanelColor_MouseDown;
buttonClose.Click += (sender, e) => Close();
}
/// <summary>
/// Отрисовать локомотив
/// </summary>
private void DrawLocomotive()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_locomotive?.SetPosition(5, 5);
_locomotive?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
/// <summary>
/// Добавление события
/// </summary>
/// <param name="ev">Привязанный метод</param>
public void AddEvent(Action<DrawningLocomotive>? ev)
{
if (EventAddLocomotive == null)
{
EventAddLocomotive = ev;
}
else
{
EventAddLocomotive += ev;
}
}
/// <summary>
/// Передаем информацию при нажатии на Label
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Проверка получаемой информации (ее типа на соответствие требуемому)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
/// <summary>
/// Действия при приеме перетаскиваемой информации
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text).ToString())
{
case "labelSimpleObject":
_locomotive = new DrawningLocomotive((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
pictureBoxObject.Height);
break;
case "labelModifiedObject":
_locomotive = new DrawningElectricLocomotive((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, Color.Black,
checkBoxHorns.Checked, checkBoxBattery.Checked,
pictureBoxObject.Width, pictureBoxObject.Height);
break;
}
DrawLocomotive();
}
private void LabelObject_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
/// <summary>
/// Передаем информацию при нажатии на Panel
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Передача базового цвета
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelBodyColor_DragDrop(object sender, DragEventArgs e)
{
if (_locomotive is null)
{
MessageBox.Show("Локомотив не задан");
return;
}
Color bodyColor = (Color)e.Data?.GetData(typeof(Color));
_locomotive?.EntityLocomotive.ChangeBodyColor(bodyColor);
DrawLocomotive();
}
/// <summary>
/// Передача дополнительного цвета цвета
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
if (_locomotive is null)
{
MessageBox.Show("Локомотив не задан");
return;
}
Color addColor = (Color)e.Data?.GetData(typeof(Color));
if (_locomotive is DrawningElectricLocomotive)
{
(_locomotive?.EntityLocomotive as EntityElectricLocomotive).ChangeAdditionalColor(addColor);
}
else
{
MessageBox.Show("Нельзя задать доп. цвет обычному локомотиву");
}
DrawLocomotive();
}
/// <summary>
/// Добавление локомотива
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonOk_Click(object sender, EventArgs e)
{
if (_locomotive is not null)
{
EventAddLocomotive?.Invoke(_locomotive);
}
Close();
}
}
}

View File

@ -0,0 +1,139 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Windows.Forms.AxHost;
namespace ProjectElectricLocomotive.MovementStrategy
{
/// <summary>
/// Класс-стратегия перемещения объекта
/// </summary>
public abstract class AbstractStrategy
{
/// <summary>
/// Перемещаемый объект
/// </summary>
private IMoveableObject? _moveableObject;
/// <summary>
/// Статус перемещения
/// </summary>
private Status _state = Status.NotInit;
/// <summary>
/// Ширина поля
/// </summary>
protected int FieldWidth { get; private set; }
/// <summary>
/// Высота поля
/// </summary>
protected int FieldHeight { get; private set; }
/// <summary>
/// Статус перемещения
/// </summary>
public Status GetStatus() { return _state; }
/// <summary>
/// Установка данных
/// </summary>
/// <param name="moveableObject">Перемещаемый объект</param>
/// <param name="width">Ширина поля</param>
/// <param name="height">Высота поля</param>
public void SetData(IMoveableObject moveableObject, int width, int height)
{
if (moveableObject == null)
{
_state = Status.NotInit;
return;
}
_state = Status.InProgress;
_moveableObject = moveableObject;
FieldWidth = width;
FieldHeight = height;
}
/// <summary>
/// Шаг перемещения
/// </summary>
public void MakeStep()
{
if (_state != Status.InProgress)
{
return;
}
if (IsTargetDestinaion())
{
_state = Status.Finish;
return;
}
MoveToTarget();
}
/// <summary>
/// Перемещение влево
/// </summary>
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
protected bool MoveLeft() => MoveTo(DirectionType.Left);
/// <summary>
/// Перемещение вправо
/// </summary>
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
protected bool MoveRight() => MoveTo(DirectionType.Right);
/// <summary>
/// Перемещение вверх
/// </summary>
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
protected bool MoveUp() => MoveTo(DirectionType.Up);
/// <summary>
/// Перемещение вниз
/// </summary>
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
protected bool MoveDown() => MoveTo(DirectionType.Down);
/// <summary>
/// Параметры объекта
/// </summary>
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
/// <summary>
/// Шаг объекта
/// </summary>
/// <returns></returns>
protected int? GetStep()
{
if (_state != Status.InProgress)
{
return null;
}
return _moveableObject?.GetStep;
}
/// <summary>
/// Перемещение к цели
/// </summary>
protected abstract void MoveToTarget();
/// <summary>
/// Достигнута ли цель
/// </summary>
/// <returns></returns>
protected abstract bool IsTargetDestinaion();
/// <summary>
/// Попытка перемещения в требуемом направлении
/// </summary>
/// <param name="directionType">Направление</param>
/// <returns>Результат попытки (true - удалось переместиться, false - неудача)</returns>
private bool MoveTo(DirectionType directionType)
{
if (_state != Status.InProgress)
{
return false;
}
if (_moveableObject?.CheckCanMove(directionType) ?? false)
{
_moveableObject.MoveObject(directionType);
return true;
}
return false;
}
public void SetFieldSize(Size newSize)
{
FieldWidth = newSize.Width;
FieldHeight = newSize.Height;
}
}
}

View File

@ -0,0 +1,42 @@
using ProjectElectricLocomotive.DrawningObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.MovementStrategy
{
/// <summary>
/// Реализация интерфейса IDrawningObject для работы с объектом DrawningLocomotive(паттерн Adapter)
/// </summary>
public class DrawningObjectLocomotive : IMoveableObject
{
private readonly DrawningLocomotive? _drawningLocomotive = null;
public DrawningObjectLocomotive(DrawningLocomotive drawningLocomotive)
{
_drawningLocomotive = drawningLocomotive;
}
public ObjectParameters? GetObjectPosition
{
get
{
if (_drawningLocomotive == null || _drawningLocomotive.EntityLocomotive ==
null)
{
return null;
}
return new ObjectParameters(_drawningLocomotive.GetPosX,
_drawningLocomotive.GetPosY, _drawningLocomotive.GetWidth, _drawningLocomotive.GetHeight);
}
}
public int GetStep => (int)(_drawningLocomotive?.EntityLocomotive?.Step ?? 0);
public bool CheckCanMove(DirectionType direction) => _drawningLocomotive?.CanMove(direction) ?? false;
public void MoveObject(DirectionType direction) => _drawningLocomotive?.MoveTransport(direction);
}
}

View File

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectElectricLocomotive;
namespace ProjectElectricLocomotive.MovementStrategy
{
/// <summary>
/// Интерфейс для работы с перемещаемым объектом
/// </summary>
public interface IMoveableObject
{
/// <summary>
/// Получение координаты X объекта
/// </summary>
ObjectParameters? GetObjectPosition { get; }
/// <summary>
/// Шаг объекта
/// </summary>
int GetStep { get; }
/// <summary>
/// Проверка, можно ли переместиться по нужному направлению
/// </summary>
/// <param name="direction"></param>
/// <returns></returns>
bool CheckCanMove(DirectionType direction);
/// <summary>
/// Изменение направления пермещения объекта
/// </summary>
/// <param name="direction">Направление</param>
void MoveObject(DirectionType direction);
}
}

View File

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.MovementStrategy
{
/// <summary>
/// Стратегия перемещения объекта к границе экрана экрана
/// </summary>
internal class MoveToBorder : AbstractStrategy
{
protected override bool IsTargetDestinaion()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return false;
}
if (MoveRight())
{
MoveLeft();
return false;
}
if (MoveDown())
{
MoveUp();
return false;
}
return true;
}
protected override void MoveToTarget()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return;
}
MoveRight();
MoveDown();
}
}
}

View File

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.MovementStrategy
{
/// <summary>
/// Стратегия перемещения объекта в центр экрана
/// </summary>
public class MoveToCenter : AbstractStrategy
{
protected override bool IsTargetDestinaion()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return false;
}
return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 &&
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
objParams.ObjectMiddleVertical <= FieldHeight / 2 &&
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
}
protected override void MoveToTarget()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return;
}
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
if (Math.Abs(diffX) > GetStep())
{
if (diffX > 0)
{
MoveLeft();
}
else
{
MoveRight();
}
}
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
if (Math.Abs(diffY) > GetStep())
{
if (diffY > 0)
{
MoveUp();
}
else
{
MoveDown();
}
}
}
}
}

View File

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.MovementStrategy
{
/// <summary>
/// Параметры-координаты объекта
/// </summary>
public class ObjectParameters
{
private readonly int _x;
private readonly int _y;
private readonly int _width;
private readonly int _height;
/// <summary>
/// Левая граница
/// </summary>
public int LeftBorder => _x;
/// <summary>
/// Верхняя граница
/// </summary>
public int TopBorder => _y;
/// <summary>
/// Правая граница
/// </summary>
public int RightBorder => _x + _width;
/// <summary>
/// Нижняя граница
/// </summary>
public int DownBorder => _y + _height;
/// <summary>
/// Середина объекта
/// </summary>
public int ObjectMiddleHorizontal => _x + _width / 2;
/// <summary>
/// Середина объекта
/// </summary>
public int ObjectMiddleVertical => _y + _height / 2;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="x">Координата X</param>
/// <param name="y">Координата Y</param>
/// <param name="width">Ширина</param>
/// <param name="height">Высота</param>
public ObjectParameters(int x, int y, int width, int height)
{
_x = x;
_y = y;
_width = width;
_height = height;
}
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectElectricLocomotive.MovementStrategy
{
/// <summary>
/// Статус выполнения операции перемещения
/// </summary>
public enum Status
{
NotInit,
InProgress,
Finish
}
}

View File

@ -0,0 +1,17 @@
namespace ProjectElectricLocomotive
{
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 FormLocomotiveCollection());
}
}
}

View File

@ -0,0 +1,26 @@
<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>
<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>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectElectricLocomotive.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("ProjectElectricLocomotive.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));
}
}
}
}

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="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="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="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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B