Compare commits

...

4 Commits
main ... Lab02

38 changed files with 2037 additions and 56 deletions

View File

@ -0,0 +1,32 @@
namespace ProjectMonorail.Drawings;
/// <summary>
/// Направление перемещения
/// </summary>
public enum DirectionType
{
/// <summary>
/// Неизвестное
/// </summary>
Unknown = -1,
/// <summary>
/// Вверх
/// </summary>
Up = 1,
/// <summary>
/// Вниз
/// </summary>
Down = 2,
/// <summary>
/// Влево
/// </summary>
Left = 3,
/// <summary>
/// Вправо
/// </summary>
Right = 4
}

View File

@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectMonorail.Entities;
namespace ProjectMonorail.Drawings;
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawingMonorail : DrawingTrain
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="wheels">Количество колёс</param>
/// <param name="mainColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="rail">Признак наличия магнитного рельса</param>
/// <param name="secondCarriage">Признак наличия второго вагона</param>
public DrawingMonorail(int speed, double weight, int wheels, Color mainColor, Color additionalColor, bool rail, bool secondCarriage) : base(40, 150)
{
EntityTrain = new EntityMonorail(speed, (int)weight, wheels, mainColor, additionalColor, rail, secondCarriage);
}
/// <summary>
/// Прорисовка объекта
/// </summary>
/// <param name="g"></param>
public override void DrawTransport(Graphics g)
{
if (EntityTrain == null || EntityTrain is not EntityMonorail monoRail || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
base.DrawTransport(g);
Brush additionalBrush = new SolidBrush(monoRail.AdditionalColor);
Pen pen = new(Color.Black);
Brush brBlue = new SolidBrush(Color.LightBlue);
Brush brWhite = new SolidBrush(Color.White);
Brush brBlack = new SolidBrush(Color.Black);
//магнитная рельса
if (monoRail.Rail)
{
if (monoRail.SecondСarriage)
{
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value + 40, 150, 3);
}
else
{
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value + 40, 90, 3);
}
}
//Второй вагон
if (monoRail.SecondСarriage)
{
//кузов
g.DrawRectangle(pen, _startPosX.Value + 95, _startPosY.Value, 55, 30);
g.FillRectangle(additionalBrush, _startPosX.Value + 96, _startPosY.Value + 1, 54, 29);
//сцепка
g.FillRectangle(brBlack, _startPosX.Value + 85, _startPosY.Value + 5, 10, 23);
//Окно
g.DrawRectangle(pen, _startPosX.Value + 105, _startPosY.Value + 5, 35, 10);
g.FillRectangle(brBlue, _startPosX.Value + 106, _startPosY.Value + 6, 34, 9);
//Дверь
g.DrawRectangle(pen, _startPosX.Value + 105, _startPosY.Value + 5, 10, 23);
g.FillRectangle(brWhite, _startPosX.Value + 106, _startPosY.Value + 16, 9, 12);
//Колёса
g.DrawEllipse(pen, _startPosX.Value + 100, _startPosY.Value + 30, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 110, _startPosY.Value + 30, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 130, _startPosY.Value + 30, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 140, _startPosY.Value + 30, 10, 10);
}
switch (monoRail.Wheels)
{
case 3:
g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 30, 10, 10);
g.FillEllipse(brWhite, _startPosX.Value + 30, _startPosY.Value + 30, 10, 10);
break;
case 4:
g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 30, 10, 10);
g.FillEllipse(brWhite, _startPosX.Value + 30, _startPosY.Value + 30, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 50, _startPosY.Value + 30, 10, 10);
g.FillEllipse(brWhite, _startPosX.Value + 50, _startPosY.Value + 30, 10, 10);
break;
}
}
}

View File

@ -0,0 +1,302 @@
using ProjectMonorail.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectMonorail.Drawings;
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение базового объекта-сущности
/// </summary>
public class DrawingTrain
{
/// <summary>
/// Класс-сущность "монорельс"
/// </summary>
public EntityTrain? EntityTrain { get; protected set; }
/// <summary>
/// Высота окна
/// </summary>
private int? _pictureHeight;
/// <summary>
/// Ширина окна
/// </summary>
private int? _pictureWidth;
/// <summary>
/// Левая координата прорисовки монорельса
/// </summary>
protected int? _startPosX;
/// <summary>
/// Верхняя координата прорисовки монорельса
/// </summary>
protected int? _startPosY;
/// <summary>
/// Высота прорисовки монорельса
/// </summary>
private readonly int _drawingMonorailHeight = 40;
/// <summary>
/// Ширина прорисовки монорельса
/// </summary>
private readonly int _drawingMonorailWidth = 95;
/// <summary>
/// Координата X объекта
/// </summary>
public int? GetPosX => _startPosX;
/// <summary>
/// Координата Y объекта
/// </summary>
public int? GetPosY => _startPosY;
/// <summary>
/// Ширина объекта
/// </summary>
public int GetWidth => _drawingMonorailWidth;
/// <summary>
/// Высота объекта
/// </summary>
public int GetHeight => _drawingMonorailHeight;
/// <summary>
/// Пустой конструктор
/// </summary>
private DrawingTrain()
{
_pictureHeight = null;
_pictureWidth = null;
_startPosX = null;
_startPosY = null;
}
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="mainColor">Основной цвет</param>
public DrawingTrain(int speed, double weight, Color mainColor) : this()
{
EntityTrain = new EntityTrain(speed, weight, mainColor);
}
/// <summary>
/// Конструктор для наследников
/// </summary>
/// <param name="drawingMonorailHeight">Высота</param>
/// <param name="drawingMonorailWidth">Ширина</param>
protected DrawingTrain(int drawingMonorailHeight, int drawingMonorailWidth) : this()
{
_drawingMonorailHeight = drawingMonorailHeight;
_drawingMonorailWidth = drawingMonorailWidth;
}
/// <summary>
/// Установка границ поля
/// </summary>
/// <param name="width">Ширина поля</param>
/// <param name="height">Высота поля</param>
/// <returns></returns>
public bool SetPictureSize(int width, int height)
{
//TODO!
if (_drawingMonorailWidth <= width && _drawingMonorailHeight <= height)
{
_pictureWidth = width;
_pictureHeight = height;
if (_startPosX.HasValue && _startPosY.HasValue)
{
if (_startPosX + _drawingMonorailWidth > _pictureWidth)
{
_startPosX = _pictureWidth - _drawingMonorailWidth;
}
if (_startPosY + _drawingMonorailHeight > _pictureHeight)
{
_startPosY = _pictureHeight - _drawingMonorailHeight;
}
}
return true;
}
return false;
}
/// <summary>
/// Установка позиции
/// </summary>
/// <param name="x">Координата x</param>
/// <param name="y">Координата y</param>
public void SetPosition(int x, int y)
{
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
{
return;
}
if (x < 0)
{
x = 0;
}
if (x + _drawingMonorailWidth > _pictureWidth.Value)
{
x = _pictureWidth.Value - _drawingMonorailWidth;
}
if (y < 0)
{
y = 0;
}
if (y + _drawingMonorailHeight > _pictureHeight.Value)
{
y = _pictureHeight.Value - _drawingMonorailHeight;
}
_startPosX = x;
_startPosY = y;
}
/// <summary>
/// Изменение направления перемещения
/// </summary>
/// <param name="direction">Направление</param>
/// <returns>true - перемещение выполнено; false - перемещение невозможно</returns>
public bool MoveTransport(DirectionType direction)
{
if (EntityTrain == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return false;
}
switch (direction)
{
//Перемещение влево
case DirectionType.Left:
if (_startPosX.Value - EntityTrain.Step > 0)
{
_startPosX -= (int)EntityTrain.Step;
}
return true;
//Перемещение вправо
case DirectionType.Right:
if (_startPosX.Value + _drawingMonorailWidth + EntityTrain.Step < _pictureWidth)
{
_startPosX += (int)EntityTrain.Step;
}
return true;
//Перемещение вверх
case DirectionType.Up:
if (_startPosY.Value - EntityTrain.Step > 0)
{
_startPosY -= (int)EntityTrain.Step;
}
return true;
//Перемещение вниз
case DirectionType.Down:
if (_startPosY.Value + _drawingMonorailHeight + EntityTrain.Step < _pictureHeight)
{
_startPosY += (int)EntityTrain.Step;
}
return true;
default: return false;
}
}
/// <summary>
/// Прорисовка объекта
/// </summary>
/// <param name="g"></param>
public virtual void DrawTransport(Graphics g)
{
if (EntityTrain == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black);
Brush mainBrush = new SolidBrush(EntityTrain.MainColor);
Brush brBlue = new SolidBrush(Color.LightBlue);
Brush brWhite = new SolidBrush(Color.White);
Brush brBlack = new SolidBrush(Color.Black);
//Границы монорельса
g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value + 15, 80, 15);
Point[] points1 = {
new Point(_startPosX.Value + 10, _startPosY.Value),
new Point(_startPosX.Value + 85, _startPosY.Value),
new Point(_startPosX.Value + 85, _startPosY.Value + 15),
new Point(_startPosX.Value + 5, _startPosY.Value + 15)
};
g.DrawPolygon(pen, points1);
g.FillRectangle(mainBrush, _startPosX.Value + 6, _startPosY.Value + 16, 79, 14);
Point[] points2 = {
new Point(_startPosX.Value + 10, _startPosY.Value + 1),
new Point(_startPosX.Value + 85, _startPosY.Value + 1),
new Point(_startPosX.Value + 85, _startPosY.Value + 15),
new Point(_startPosX.Value + 5, _startPosY.Value + 15)
};
g.FillPolygon(mainBrush, points2);
//Держатель 1
Point[] points_cart1 = {
new Point(_startPosX.Value, _startPosY.Value + 35),
new Point(_startPosX.Value + 15, _startPosY.Value + 35),
new Point(_startPosX.Value + 15, _startPosY.Value + 30),
new Point(_startPosX.Value + 5, _startPosY.Value + 30)
};
g.DrawPolygon(pen, points_cart1);
g.FillPolygon(brBlack, points_cart1);
//Держатель 2
Point[] points_cart2 = {
new Point(_startPosX.Value + 20, _startPosY.Value + 30),
new Point(_startPosX.Value + 25, _startPosY.Value + 35),
new Point(_startPosX.Value + 30, _startPosY.Value + 35),
new Point(_startPosX.Value + 35, _startPosY.Value + 30)
};
g.DrawPolygon(pen, points_cart2);
g.FillPolygon(brBlack, points_cart2);
//Держатель 3
Point[] points_cart3 = {
new Point(_startPosX.Value + 55, _startPosY.Value + 30),
new Point(_startPosX.Value + 60, _startPosY.Value + 35),
new Point(_startPosX.Value + 65, _startPosY.Value + 35),
new Point(_startPosX.Value + 70, _startPosY.Value + 30)
};
g.DrawPolygon(pen, points_cart3);
g.FillPolygon(brBlack, points_cart3);
//Держатель 4
Point[] points_cart4 = {
new Point(_startPosX.Value + 70, _startPosY.Value + 30),
new Point(_startPosX.Value + 75, _startPosY.Value + 35),
new Point(_startPosX.Value + 90, _startPosY.Value + 35),
new Point(_startPosX.Value + 85, _startPosY.Value + 30)
};
g.DrawPolygon(pen, points_cart4);
g.FillPolygon(brBlack, points_cart4);
//Окна монорельса
g.DrawRectangle(pen, _startPosX.Value + 17, _startPosY.Value + 5, 17, 7);
g.FillRectangle(brBlue, _startPosX.Value + 18, _startPosY.Value + 6, 16, 6);
g.DrawRectangle(pen, _startPosX.Value + 55, _startPosY.Value + 5, 27, 7);
g.FillRectangle(brBlue, _startPosX.Value + 56, _startPosY.Value + 6, 26, 6);
//Дверь монорельса
g.DrawRectangle(pen, _startPosX.Value + 40, _startPosY.Value + 7, 10, 21);
g.FillRectangle(brWhite, _startPosX.Value + 41, _startPosY.Value + 8, 9, 20);
//колёса
//1, 4 колесо
g.DrawEllipse(pen, _startPosX.Value + 15, _startPosY.Value + 30, 10, 10);
g.FillEllipse(brWhite, _startPosX.Value + 15, _startPosY.Value + 30, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 65, _startPosY.Value + 30, 10, 10);
g.FillEllipse(brWhite, _startPosX.Value + 65, _startPosY.Value + 30, 10, 10);
}
}

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectMonorail.Entities;
/// <summary>
/// Класс-сущность "Монорельс"
/// </summary>
public class EntityMonorail : EntityTrain
{
/// <summary>
/// Количество колёс
/// </summary>
public int Wheels { get; private set; }
/// <summary>
/// Дополнительный цвет
/// </summary>
public Color AdditionalColor { get; private set; }
/// <summary>
/// Признак наличия магнитного рельса
/// </summary>
public bool Rail { get; private set; }
/// <summary>
/// Признак наличия второго вагона
/// </summary>
public bool SecondСarriage { get; private set; }
/// <summary>
/// Конструктор
/// </summary>
/// <param name="wheels">Количество колёс</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="rail">Признак наличия магнитного рельса</param>
/// <param name="secondCarriage">Признак наличия второго вагона</param>
public EntityMonorail(int speed, int weight, int wheels, Color mainColor, Color additionalColor, bool rail, bool secondCarriage) : base(speed, weight, mainColor)
{
Wheels = wheels;
AdditionalColor = additionalColor;
Rail = rail;
SecondСarriage = secondCarriage;
}
}

View File

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

View File

@ -1,45 +0,0 @@
namespace ProjectMonorail
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
SuspendLayout();
//
// Form1
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(801, 450);
Name = "Form1";
Text = "Form1";
ResumeLayout(false);
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace ProjectMonorail
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

180
ProjectMonorail/FormMonorail.Designer.cs generated Normal file
View File

@ -0,0 +1,180 @@
namespace ProjectMonorail
{
partial class FormMonorail
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
pictureBoxMonorail = new PictureBox();
buttonDown = new Button();
buttonRight = new Button();
buttonLeft = new Button();
buttonUp = new Button();
CreateMonorailButton = new Button();
CreateTrainButton = new Button();
comboBoxStrategy = new ComboBox();
buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxMonorail).BeginInit();
SuspendLayout();
//
// pictureBoxMonorail
//
pictureBoxMonorail.Dock = DockStyle.Fill;
pictureBoxMonorail.Location = new Point(0, 0);
pictureBoxMonorail.Margin = new Padding(3, 4, 3, 4);
pictureBoxMonorail.Name = "pictureBoxMonorail";
pictureBoxMonorail.Size = new Size(1142, 596);
pictureBoxMonorail.TabIndex = 5;
pictureBoxMonorail.TabStop = false;
//
// buttonDown
//
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonDown.BackgroundImage = Properties.Resources.icons8_стрелка_50вниз;
buttonDown.Location = new Point(1024, 530);
buttonDown.Margin = new Padding(3, 4, 3, 4);
buttonDown.Name = "buttonDown";
buttonDown.Size = new Size(50, 50);
buttonDown.TabIndex = 10;
buttonDown.UseVisualStyleBackColor = true;
buttonDown.Click += ButtonMove_Click;
//
// buttonRight
//
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonRight.BackgroundImage = Properties.Resources.icons8_стрелка_50__1_;
buttonRight.Location = new Point(1080, 530);
buttonRight.Margin = new Padding(3, 4, 3, 4);
buttonRight.Name = "buttonRight";
buttonRight.Size = new Size(50, 50);
buttonRight.TabIndex = 9;
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += ButtonMove_Click;
//
// buttonLeft
//
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonLeft.BackgroundImage = Properties.Resources.icons8_стрелка_50влево;
buttonLeft.Location = new Point(968, 530);
buttonLeft.Margin = new Padding(3, 4, 3, 4);
buttonLeft.Name = "buttonLeft";
buttonLeft.Size = new Size(50, 50);
buttonLeft.TabIndex = 8;
buttonLeft.UseVisualStyleBackColor = true;
buttonLeft.Click += ButtonMove_Click;
//
// buttonUp
//
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonUp.BackgroundImage = Properties.Resources.icons8_стрелка_50вверх;
buttonUp.Location = new Point(1024, 472);
buttonUp.Margin = new Padding(3, 4, 3, 4);
buttonUp.Name = "buttonUp";
buttonUp.Size = new Size(50, 50);
buttonUp.TabIndex = 7;
buttonUp.UseVisualStyleBackColor = true;
buttonUp.Click += ButtonMove_Click;
//
// CreateMonorailButton
//
CreateMonorailButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
CreateMonorailButton.Location = new Point(14, 541);
CreateMonorailButton.Margin = new Padding(3, 4, 3, 4);
CreateMonorailButton.Name = "CreateMonorailButton";
CreateMonorailButton.Size = new Size(167, 39);
CreateMonorailButton.TabIndex = 6;
CreateMonorailButton.Text = "Создать монорельс";
CreateMonorailButton.UseVisualStyleBackColor = true;
CreateMonorailButton.Click += CreateButton_Click;
//
// CreateTrainButton
//
CreateTrainButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
CreateTrainButton.Location = new Point(205, 541);
CreateTrainButton.Margin = new Padding(3, 4, 3, 4);
CreateTrainButton.Name = "CreateTrainButton";
CreateTrainButton.Size = new Size(167, 39);
CreateTrainButton.TabIndex = 11;
CreateTrainButton.Text = "Создать поезд";
CreateTrainButton.UseVisualStyleBackColor = true;
CreateTrainButton.Click += CreateTrainButton_Click;
//
// comboBoxStrategy
//
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxStrategy.FormattingEnabled = true;
comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" });
comboBoxStrategy.Location = new Point(979, 12);
comboBoxStrategy.Name = "comboBoxStrategy";
comboBoxStrategy.Size = new Size(151, 28);
comboBoxStrategy.TabIndex = 12;
//
// buttonStrategyStep
//
buttonStrategyStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonStrategyStep.Location = new Point(1036, 46);
buttonStrategyStep.Name = "buttonStrategyStep";
buttonStrategyStep.Size = new Size(94, 29);
buttonStrategyStep.TabIndex = 13;
buttonStrategyStep.Text = "Шаг";
buttonStrategyStep.UseVisualStyleBackColor = true;
buttonStrategyStep.Click += buttonStrategyStep_Click;
//
// FormMonorail
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1142, 596);
Controls.Add(buttonStrategyStep);
Controls.Add(comboBoxStrategy);
Controls.Add(CreateTrainButton);
Controls.Add(buttonDown);
Controls.Add(buttonRight);
Controls.Add(buttonLeft);
Controls.Add(buttonUp);
Controls.Add(CreateMonorailButton);
Controls.Add(pictureBoxMonorail);
Margin = new Padding(3, 4, 3, 4);
Name = "FormMonorail";
Text = "FormMonorail";
((System.ComponentModel.ISupportInitialize)pictureBoxMonorail).EndInit();
ResumeLayout(false);
}
#endregion
private PictureBox pictureBoxMonorail;
private Button buttonDown;
private Button buttonRight;
private Button buttonLeft;
private Button buttonUp;
private Button CreateMonorailButton;
private Button CreateTrainButton;
private ComboBox comboBoxStrategy;
private Button buttonStrategyStep;
}
}

View File

@ -0,0 +1,168 @@
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;
using ProjectMonorail.Drawings;
using ProjectMonorail.MovementStrategy;
namespace ProjectMonorail
{
/// <summary>
/// Форма работы с объектом "Монорельс"
/// </summary>
public partial class FormMonorail : Form
{
/// <summary>
/// Поле-объект для прорисовки объекта
/// </summary>
private DrawingTrain? _drawingTrain;
/// <summary>
/// Стратегия перемещения
/// </summary>
private AbstractStrategy? _strategy;
/// <summary>
/// Конструктор формы
/// </summary>
public FormMonorail()
{
InitializeComponent();
_strategy = null;
}
/// <summary>
/// Метод прорисовки
/// </summary>
private void Draw()
{
if (_drawingTrain == null)
{
return;
}
Bitmap bmp = new(pictureBoxMonorail.Width, pictureBoxMonorail.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawingTrain.DrawTransport(gr);
pictureBoxMonorail.Image = bmp;
}
private void CreateObject(string type)
{
Random random = new();
switch (type)
{
case nameof(DrawingTrain):
_drawingTrain = new DrawingTrain(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
break;
case nameof(DrawingMonorail):
_drawingTrain = new DrawingMonorail(random.Next(100, 300), random.Next(1000, 3000), random.Next(2, 5),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break;
default: return;
}
_drawingTrain.SetPictureSize(pictureBoxMonorail.Width, pictureBoxMonorail.Height);
_drawingTrain.SetPosition(random.Next(10, 100), random.Next(10, 100));
_strategy = null;
comboBoxStrategy.Enabled = true;
Draw();
}
/// <summary>
/// Обработка нажатия кнопки "Создать монорельс"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CreateButton_Click(object sender, EventArgs e)
{
CreateObject(nameof(DrawingMonorail));
}
/// <summary>
/// Обработка нажатия кнопки "Создать поезд"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CreateTrainButton_Click(object sender, EventArgs e)
{
CreateObject(nameof(DrawingTrain));
}
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_drawingTrain == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
bool result = false;
switch (name)
{
case "buttonUp":
result = _drawingTrain.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
result = _drawingTrain.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
result = _drawingTrain.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
result = _drawingTrain.MoveTransport(DirectionType.Right);
break;
}
if (result)
{
Draw();
}
}
private void buttonStrategyStep_Click(object sender, EventArgs e)
{
if (_drawingTrain == null)
{
return;
}
if (comboBoxStrategy.Enabled)
{
_strategy = comboBoxStrategy.SelectedIndex switch
{
0 => new MoveToCenter(),
1 => new MoveToBorder(),
_ => null
};
if (_strategy == null)
{
return;
}
_strategy.SetData(new MoveableTrain(_drawingTrain), pictureBoxMonorail.Width, pictureBoxMonorail.Height);
}
if (_strategy == null)
{
return;
}
comboBoxStrategy.Enabled = false;
_strategy.MakeStep();
Draw();
if (_strategy.GetStatus() == StrategyStatus.Finish)
{
comboBoxStrategy.Enabled = true;
_strategy = null;
}
}
}
}

View File

@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectMonorail.MovementStrategy;
public abstract class AbstractStrategy
{
/// <summary>
/// Перемещаемый объект
/// </summary>
private IMovableObjects? _moveableObject;
/// <summary>
/// Статус перемещения
/// </summary>
private StrategyStatus _state = StrategyStatus.NotInit;
/// <summary>
/// Ширина поля
/// </summary>
protected int FieldWidth { get; private set; }
/// <summary>
/// Высота поля
/// </summary>
protected int FieldHeight { get; private set; }
/// <summary>
/// Статус перемещения
/// </summary>
/// <returns></returns>
public StrategyStatus GetStatus() { return _state; }
/// <summary>
/// Установка данных
/// </summary>
/// <param name="movableObject">Перемещаемый объект</param>
/// <param name="width">Ширина поля</param>
/// <param name="height">Высота поля</param>
public void SetData(IMovableObjects movableObject, int width, int height)
{
if (movableObject == null)
{
_state = StrategyStatus.NotInit;
return;
}
_state = StrategyStatus.InProgress;
_moveableObject = movableObject;
FieldHeight = height;
FieldWidth = width;
}
/// <summary>
/// Шаг перемещения
/// </summary>
public void MakeStep()
{
if (_state != StrategyStatus.InProgress)
{
return;
}
if (IsTargetDestination())
{
_state = StrategyStatus.Finish;
return;
}
MoveToTarget();
}
/// <summary>
/// Шаг влево
/// </summary>
/// <returns></returns>
protected bool MoveLeft() => MoveTo(MovementDirection.Left);
/// <summary>
/// Шаг вверх
/// </summary>
/// <returns></returns>
protected bool MoveUp() => MoveTo(MovementDirection.Up);
/// <summary>
/// Шаг вправо
/// </summary>
/// <returns></returns>
protected bool MoveRight() => MoveTo(MovementDirection.Right);
/// <summary>
/// Шаг вниз
/// </summary>
/// <returns></returns>
protected bool MoveDown() => MoveTo(MovementDirection.Down);
/// <summary>
/// Параметры объекта
/// </summary>
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
/// <summary>
/// Шаг объекта
/// </summary>
/// <returns></returns>
protected int? GetStep()
{
if(_state != StrategyStatus.InProgress)
{
return null;
}
return _moveableObject?.GetStep;
}
/// <summary>
/// Перемещение к цели
/// </summary>
protected abstract void MoveToTarget();
/// <summary>
/// Достигнута ли цель
/// </summary>
/// <returns></returns>
protected abstract bool IsTargetDestination();
private bool MoveTo(MovementDirection movementDirection)
{
if (_state != StrategyStatus.InProgress)
{
return false;
}
return _moveableObject?.TryMoveObject(movementDirection) ?? false;
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectMonorail.MovementStrategy;
public interface IMovableObjects
{
/// <summary>
/// Получение координаты объекта
/// </summary>
ObjectParameters? GetObjectPosition { get; }
/// <summary>
/// Шаг объекта
/// </summary>
int GetStep { get; }
/// <summary>
/// Попытка переместить объект в заданном направлении
/// </summary>
/// <param name="direction">Направление</param>
/// <returns></returns>
bool TryMoveObject(MovementDirection direction);
}

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectMonorail.MovementStrategy;
public class MoveToBorder : AbstractStrategy
{
protected override bool IsTargetDestination()
{
ObjectParameters? objParams = GetObjectParameters;
if (objParams == null)
{
return false;
}
return objParams.RightBorder + GetStep() >= FieldWidth && objParams.DownBorder + GetStep() >= FieldHeight;
}
protected override void MoveToTarget()
{
ObjectParameters? objParams = GetObjectParameters;
if (objParams == null)
{
return;
}
int diffx = objParams.RightBorder - FieldWidth;
if (Math.Abs(diffx) > GetStep())
{
MoveRight();
}
int diffy = objParams.DownBorder - FieldHeight;
if (Math.Abs(diffy) > GetStep())
{
MoveDown();
}
}
}

View File

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectMonorail.MovementStrategy;
public class MoveToCenter : AbstractStrategy
{
protected override bool IsTargetDestination()
{
ObjectParameters? objParams = GetObjectParameters;
if (objParams == null)
{
return false;
}
return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth / 2 && objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2 && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
}
protected override void MoveToTarget()
{
ObjectParameters? objParams = GetObjectParameters;
if (objParams == null)
{
return;
}
int diffx = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
if (Math.Abs(diffx) > GetStep())
{
if (diffx > 0)
{
MoveLeft();
}
else
{
MoveRight();
}
}
int diffy = objParams.ObjectMiddleVertical - FieldHeight / 2;
if (Math.Abs(diffy) > GetStep())
{
if (diffy > 0)
{
MoveUp();
}
else
{
MoveDown();
}
}
}
}

View File

@ -0,0 +1,63 @@
using ProjectMonorail.Drawings;
namespace ProjectMonorail.MovementStrategy;
/// <summary>
/// Класс-реализация IMoveableObject с использованием DrawingTrain
/// </summary>
public class MoveableTrain : IMovableObjects
{
/// <summary>
/// Поле-объект класса DrawingTrain или его наследника
/// </summary>
private readonly DrawingTrain? _train = null;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="train">Объект класса DrawingTrain</param>
public MoveableTrain(DrawingTrain train)
{
_train = train;
}
public ObjectParameters? GetObjectPosition
{
get
{
if(_train == null || _train.EntityTrain == null || !_train.GetPosX.HasValue || !_train.GetPosY.HasValue)
{
return null;
}
return new ObjectParameters(_train.GetPosX.Value, _train.GetPosY.Value, _train.GetWidth, _train.GetHeight);
}
}
public int GetStep => (int)(_train?.EntityTrain?.Step ?? 0);
public bool TryMoveObject(MovementDirection direction)
{
if (_train == null || _train.EntityTrain == null)
{
return false;
}
return _train.MoveTransport(GetDirectionType(direction));
}
/// <summary>
/// Конвертация из MovementDirection в DirectionType
/// </summary>
/// <param name="direction">MovementDirection</param>
/// <returns>DirectionType</returns>
private static DirectionType GetDirectionType(MovementDirection direction)
{
return direction switch
{
MovementDirection.Up => DirectionType.Up,
MovementDirection.Down => DirectionType.Down,
MovementDirection.Left => DirectionType.Left,
MovementDirection.Right => DirectionType.Right,
_ => DirectionType.Unknown,
};
}
}

View File

@ -0,0 +1,27 @@
namespace ProjectMonorail.MovementStrategy;
/// <summary>
/// Направление перемещения
/// </summary>
public enum MovementDirection
{
/// <summary>
/// Вверх
/// </summary>
Up = 1,
/// <summary>
/// Вниз
/// </summary>
Down = 2,
/// <summary>
/// Влево
/// </summary>
Left = 3,
/// <summary>
/// Вправо
/// </summary>
Right = 4,
}

View File

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectMonorail.MovementStrategy;
public class ObjectParameters
{
/// <summary>
/// Координата X
/// </summary>
private readonly int _x;
/// <summary>
/// Координата Y
/// </summary>
private readonly int _y;
/// <summary>
/// Высота объекта
/// </summary>
private readonly int _height;
/// <summary>
/// Ширина объекта
/// </summary>
private readonly int _width;
/// <summary>
/// Левая граница
/// </summary>
public int LeftBorder => _x;
/// <summary>
/// Верхняя граница
/// </summary>
public int TobBorder => _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="height">Высота</param>
/// <param name="width">Ширина</param>
public ObjectParameters(int x, int y, int width, int height)
{
_x = x;
_y = y;
_height = height;
_width = width;
}
}

View File

@ -0,0 +1,22 @@
namespace ProjectMonorail.MovementStrategy;
/// <summary>
/// Статус выполнения операции перемещения
/// </summary>
public enum StrategyStatus
{
/// <summary>
/// Всё готово к началу
/// </summary>
NotInit,
/// <summary>
/// Выполняется
/// </summary>
InProgress,
/// <summary>
/// Завершено
/// </summary>
Finish
}

View File

@ -11,7 +11,7 @@ namespace ProjectMonorail
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(new FormMonorail());
}
}
}

View File

@ -0,0 +1,123 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectMonorail.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectMonorail.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_стрелка_50__1_ {
get {
object obj = ResourceManager.GetObject("icons8-стрелка-50 (1)", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_стрелка_50вверх {
get {
object obj = ResourceManager.GetObject("icons8-стрелка-50вверх", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_стрелка_50влево {
get {
object obj = ResourceManager.GetObject("icons8-стрелка-50влево", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_стрелка_50вниз {
get {
object obj = ResourceManager.GetObject("icons8-стрелка-50вниз", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap up {
get {
object obj = ResourceManager.GetObject("up", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap up1 {
get {
object obj = ResourceManager.GetObject("up1", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,139 @@
<?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="icons8-стрелка-50вниз" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-стрелка-50вниз.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8-стрелка-50вверх" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-стрелка-50вверх.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8-стрелка-50влево" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-стрелка-50влево.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="up" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="up1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\up1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8-стрелка-50 (1)" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons8-стрелка-50 (1).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: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@ -0,0 +1,5 @@
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

40
WindowsFormsApp1/Form1.Designer.cs generated Normal file
View File

@ -0,0 +1,40 @@
namespace WindowsFormsApp1
{
partial class Form1
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором форм Windows
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

20
WindowsFormsApp1/Form1.cs Normal file
View File

@ -0,0 +1,20 @@
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 WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
internal static class Program
{
/// <summary>
/// Главная точка входа для приложения.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанных со сборкой.
[assembly: AssemblyTitle("WindowsFormsApp1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WindowsFormsApp1")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, следует установить атрибут ComVisible в TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("63aecd52-fcbb-4900-a5fd-57b61edd33d0")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программным средством.
// Версия среды выполнения: 4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
// код создан повторно.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WindowsFormsApp1.Properties
{
/// <summary>
/// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
/// </summary>
// Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
// класс с помощью таких средств, как ResGen или Visual Studio.
// Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
// с параметром /str или заново постройте свой VS-проект.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.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 ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsFormsApp1.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;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <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 WindowsFormsApp1.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{63AECD52-FCBB-4900-A5FD-57B61EDD33D0}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>WindowsFormsApp1</RootNamespace>
<AssemblyName>WindowsFormsApp1</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34024.191
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsApp1", "WindowsFormsApp1.csproj", "{63AECD52-FCBB-4900-A5FD-57B61EDD33D0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{63AECD52-FCBB-4900-A5FD-57B61EDD33D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{63AECD52-FCBB-4900-A5FD-57B61EDD33D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63AECD52-FCBB-4900-A5FD-57B61EDD33D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{63AECD52-FCBB-4900-A5FD-57B61EDD33D0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E2E350C5-D465-419E-9B2D-7DF5DF76814C}
EndGlobalSection
EndGlobal