Compare commits

..

No commits in common. "LabWork03" and "main" have entirely different histories.

34 changed files with 51 additions and 2198 deletions

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.7.34221.43 VisualStudioVersion = 17.7.34221.43
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HoistingCrane", "HoistingCrane\HoistingCrane.csproj", "{915BDF62-D64D-4AB9-BA2D-8E228E803B7F}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HoistingCrane", "HoistingCrane\HoistingCrane.csproj", "{915BDF62-D64D-4AB9-BA2D-8E228E803B7F}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -1,88 +0,0 @@
using HoistingCrane.Drawning;
namespace HoistingCrane.CollectionGenericObjects
{
public abstract class AbstractCompany
{
/// <summary>
/// Ширина ячейки гаража
/// </summary>
protected readonly int _placeSizeWidth = 150;
/// <summary>
/// Высота ячейки гаража
/// </summary>
protected readonly int _placeSizeHeight = 90;
/// <summary>
/// Ширина окна
/// </summary>
protected readonly int pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
protected readonly int pictureHeight;
/// <summary>
/// Коллекция автомобилей
/// </summary>
protected ICollectionGenericObjects<DrawningTrackedVehicle>? arr = null;
/// <summary>
/// Максимальное количество гаражей
/// </summary>
private int GetMaxCount
{
get
{
return (pictureWidth * pictureHeight) / (_placeSizeHeight * _placeSizeWidth)-3;
}
}
public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects<DrawningTrackedVehicle> array)
{
pictureWidth = picWidth;
pictureHeight = picHeight;
arr = array;
arr.SetMaxCount = GetMaxCount;
}
public static int operator +(AbstractCompany company, DrawningTrackedVehicle car)
{
return company.arr?.Insert(car) ?? -1;
}
public static DrawningTrackedVehicle operator -(AbstractCompany company, int position)
{
return company.arr?.Remove(position) ?? null;
}
public DrawningTrackedVehicle? GetRandomObject()
{
Random rnd = new();
return arr?.Get(rnd.Next(GetMaxCount));
}
/// <summary>
/// Вывод всей коллекции
/// </summary>
/// <returns></returns>
public Bitmap? Show()
{
Bitmap bitmap = new(pictureWidth, pictureHeight);
Graphics graphics = Graphics.FromImage(bitmap);
DrawBackgound(graphics);
SetObjectsPosition();
for (int i = 0; i < (arr?.Count ?? 0); i++)
{
DrawningTrackedVehicle? obj = arr?.Get(i);
obj?.DrawTransport(graphics);
}
return bitmap;
}
/// <summary>
/// Вывод заднего фона
/// </summary>
/// <param name="g"></param>
protected abstract void DrawBackgound(Graphics g);
/// <summary>
/// Расстановка объектов
/// </summary>
protected abstract void SetObjectsPosition();
}
}

View File

@ -1,56 +0,0 @@
using HoistingCrane.Drawning;
namespace HoistingCrane.CollectionGenericObjects
{
public class Garage : AbstractCompany
{
public Garage(int picWidth, int picHeight, ICollectionGenericObjects<DrawningTrackedVehicle> array) : base(picWidth, picHeight, array)
{
}
protected override void DrawBackgound(Graphics g)
{
int width = pictureWidth / _placeSizeWidth;
int height = pictureHeight / _placeSizeHeight;
Pen pen = new(Color.Black, 3);
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height + 1; ++j)
{
g.DrawLine(pen, i * _placeSizeWidth + 15, j * _placeSizeHeight, i * _placeSizeWidth + 15 + _placeSizeWidth - 55, j * _placeSizeHeight);
g.DrawLine(pen, i * _placeSizeWidth + 15, j * _placeSizeHeight, i * _placeSizeWidth + 15, j * _placeSizeHeight - _placeSizeHeight);
}
}
}
protected override void SetObjectsPosition()
{
int countWidth = pictureWidth / _placeSizeWidth;
int countHeight = pictureHeight / _placeSizeHeight;
int currentPosWidth = countWidth - 1;
int currentPosHeight = countHeight - 1;
for (int i = 0; i < (arr?.Count ?? 0); i++)
{
if (arr?.Get(i) != null)
{
arr?.Get(i)?.SetPictureSize(pictureWidth, pictureHeight);
arr?.Get(i)?.SetPosition(_placeSizeWidth * currentPosWidth + 25, _placeSizeHeight * currentPosHeight + 15);
}
if (currentPosWidth > 0)
currentPosWidth--;
else
{
currentPosWidth = countWidth - 1;
currentPosHeight--;
}
if (currentPosHeight < 0)
{
break;
}
}
}
}
}

View File

@ -1,35 +0,0 @@
namespace HoistingCrane.CollectionGenericObjects
{
public interface ICollectionGenericObjects<T>
where T: class
{
/// <summary>
/// Кол-во объектов в коллекции
/// </summary>
int Count { get; }
/// <summary>
/// Максимальное количество элементов
/// </summary>
int SetMaxCount { set; }
/// <summary>
/// Добавление элемента в коллекцию
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
int Insert(T obj);
/// <summary>
/// Добавление элемента в коллекцию на определенную позицию
/// </summary>
/// <param name="obj"></param>
/// <param name="position"></param>
/// <returns></returns>
int Insert(T obj, int position);
/// <summary>
/// Удаление элемента из коллекции по его позиции
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
T? Remove(int position);
T? Get(int position);
}
}

View File

@ -1,84 +0,0 @@
using System;
namespace HoistingCrane.CollectionGenericObjects
{
public class MassivGenericObjects<T> : ICollectionGenericObjects<T> where T : class
{
private T?[] arr;
public MassivGenericObjects()
{
arr = Array.Empty<T?>();
}
public int Count
{
get { return arr.Length; }
}
public int SetMaxCount
{
set
{
if (value > 0)
{
if (arr.Length > 0)
{
Array.Resize(ref arr, value);
}
else
{
arr = new T?[value];
}
}
}
}
public T? Get(int position)
{
if (position >= 0 && position < arr.Length)
{
return arr[position];
}
return null;
}
public int Insert(T obj)
{
return Insert(obj, 0);
}
public int Insert(T obj, int position)
{
//todo Проверка позиции
if (position < 0 || position > Count)
{
return -1;
}
if (arr[position] == null)
{
arr[position] = obj;
return position;
}
else
{
if (Insert(obj, position + 1) != -1)
{
return position;
}
if (Insert(obj, position - 1) != -1)
{
return position;
}
}
return -1;
}
public T? Remove(int position)
{
if (position >= 0 && position < Count)
{
T? temp = arr[position];
arr[position] = null;
return temp;
}
return null;
}
}
}

View File

@ -1,27 +0,0 @@
namespace HoistingCrane.Drawning;
public enum DirectionType //Создали не класс(class), а перечисление (enum)
{
//Перечислим основные траектории движния нашего автомобиля. Сразу же зададим значения.
/// <summary>
/// Неизвестное направление
/// </summary>
Unknow = -1,
/// <summary>
/// Вверх
/// </summary>
Up = 1,
/// <summary>
/// Вниз
/// </summary>
Down,
/// <summary>
/// Влево
/// </summary>
Left,
/// <summary>
/// Вправо
/// </summary>
Right
}

View File

@ -1,84 +0,0 @@
using HoistingCrane.Entities;
using System.Configuration;
namespace HoistingCrane.Drawning;
//В данном классе мы будем думать над полем игры, размерами персонажа, размерами объектов и т.д.
public class DrawningHoistingCrane : DrawningTrackedVehicle
{
/// <summary>
/// Ширина окна
/// </summary>
private int? _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
private int? _pictureHeight;
/// <summary>
/// Ширина прорисовки автомобиля
/// </summary>
private readonly int _drawingCarWidth = 115;
/// <summary>
/// Высота прорисовки автомобиля
/// </summary>
private readonly int _drawingCarHeight = 63;
/// <summary>
/// конструктор класса отрисовки крана
/// </summary>
/// <param name="AdditionalColor">Дополнительный цвет</param>
/// <param name="Counterweight">Противовес</param>
/// <param name="Platform">Платформа</param>
public DrawningHoistingCrane(int speed, int weight, Color bodyColor, Color additionalColor, bool counterweight, bool platform) : base(115, 63)
{
EntityTrackedVehicle = new EntityHoistingCrane(speed, weight, bodyColor, additionalColor, counterweight, platform);
}
/// <summary>
/// Метод отрисовки объекта
/// </summary>
/// <param name="gr"></param>
public override void DrawTransport(Graphics gr)
{
if (EntityTrackedVehicle == null || EntityTrackedVehicle is not EntityHoistingCrane EntityHoistingCrane || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
base.DrawTransport(gr);
Brush b = new SolidBrush(EntityHoistingCrane.AdditionalColor);
Pen pen = new Pen(EntityHoistingCrane.AdditionalColor);
Pen penBase = new Pen(EntityHoistingCrane.BodyColor);
if (EntityHoistingCrane.Counterweight)
{
//противовес
gr.DrawRectangle(pen, _startPosX.Value + 69, _startPosY.Value + 3, 10, 10);
gr.DrawLine(pen, _startPosX.Value + 68, _startPosY.Value + 3, _startPosX.Value + 78, _startPosY.Value + 12);
gr.DrawLine(pen, _startPosX.Value + 68, _startPosY.Value + 7, _startPosX.Value + 78, _startPosY.Value + 3);
}
if (EntityHoistingCrane.Platform) {
//Наличие спусковой платформы
gr.FillRectangle(b, _startPosX.Value + 101, _startPosY.Value + 40, 15, 5);
gr.FillRectangle(b, _startPosX.Value + 116, _startPosY.Value + 35, 4, 5);
gr.FillRectangle(b, _startPosX.Value + 97, _startPosY.Value + 35, 4, 5);
}
//Отрисовка крана, на котором держится платформа и противовес
gr.FillRectangle(b, _startPosX.Value + 65, _startPosY.Value, 5, 26);
gr.FillRectangle(b, _startPosX.Value + 65, _startPosY.Value, 50, 4);
gr.DrawLine(penBase, _startPosX.Value + 115, _startPosY.Value + 4, _startPosX.Value + 108, _startPosY.Value + 40);
}
}

View File

@ -1,263 +0,0 @@
using HoistingCrane.Entities;
namespace HoistingCrane.Drawning
{
//В данном классе мы будем думать над полем игры, размерами персонажа, размерами объектов и т.д.
public class DrawningTrackedVehicle
{
/// <summary>
/// Класс - сущность
/// </summary>
public EntityTrackedVehicle? EntityTrackedVehicle { get; protected set; }
/// <summary>
/// Ширина окна
/// </summary>
private int? _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
private int? _pictureHeight;
/// <summary>
/// Стартовая позиция по х
/// </summary>
protected int? _startPosX;
/// <summary>
/// Стартовая позиция по у
/// </summary>
protected int? _startPosY;
/// <summary>
/// Ширина прорисовки автомобиля
/// </summary>
private readonly int _drawingCarWidth = 83;
/// <summary>
/// Высота прорисовки автомобиля
/// </summary>
private readonly int _drawingCarHeight = 63;
public int? GetPosX => _startPosX;
public int? GetPosY => _startPosY;
public int GetWidth => _drawingCarWidth;
public int GetHeight => _drawingCarHeight;
/// <summary>
/// Конструктор класса, который принимает параметры автомобиля(скорость, вес и цвет) и создает объект класса с данными параметрами
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Цвет</param>
public DrawningTrackedVehicle(int speed, double weight, Color bodyColor) : this()
{
EntityTrackedVehicle = new EntityTrackedVehicle(speed, weight, bodyColor);
}
/// <summary>
/// Конструктор, при вызове которого можем менять границы транспорта
/// </summary>
/// <param name="_drawingCarWidth">Ширина прорисовки автомобиля</param>
/// <param name="_drawingCarHeight">Высота прорисовки автомобиля</param>
protected DrawningTrackedVehicle(int _drawingCarWidth, int _drawingCarHeight) : this()
{
this._drawingCarWidth = _drawingCarWidth;
this._drawingCarHeight = _drawingCarHeight;
}
/// <summary>
/// Приватный конструктор, который делает значения границ окна = null и стартовую позицию = null
/// </summary>
private DrawningTrackedVehicle()
{
_pictureWidth = null;
_pictureHeight = null;
_startPosX = null;
_startPosY = null;
}
/// <summary>
/// Метод отрисовки игрового поля
/// </summary>
/// <param name="width">Ширина поля</param>
/// <param name="height">Высота поля</param>
/// <returns></returns>
public bool SetPictureSize(int width, int height)
{
// TODO проверка, что объект "влезает" в размеры поля
// если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена ✔
if (_drawingCarHeight > height || _drawingCarWidth > width)
{
return false;
}
_pictureHeight = height;
_pictureWidth = width;
if (_startPosX.HasValue && _startPosX.Value + _drawingCarWidth > _pictureWidth)
{
_startPosX = _pictureWidth - _drawingCarWidth;
}
if (_startPosY.HasValue && _startPosY.Value + _drawingCarHeight > _pictureHeight)
{
_startPosY = _pictureHeight - _drawingCarHeight;
}
return true;
}
/// <summary>
/// Установим позицию игрока
/// </summary>
/// <param name="x">Координата по Х</param>
/// <param name="y">Координата по У</param>
public void SetPosition(int x, int y)
{
//Если размеры были заданы, то присваиваем х и у, иначе выходим из метода
if (x < 0)
x = -x;
if (y < 0)
y = -y;
if (x + _drawingCarWidth > _pictureWidth)
{
_startPosX = _pictureWidth - _drawingCarWidth;
}
else
{
_startPosX = x;
}
if (y + _drawingCarHeight > _pictureHeight)
{
_startPosY = _pictureHeight - _drawingCarHeight;
}
else
{
_startPosY = y;
}
}
/// <summary>
/// Перемещение машины
/// </summary>
/// <param name="direction"></param>
/// <returns></returns>
public bool MoveTransport(DirectionType direction) //Подключили модив\фикатор virtual для переопределения в дочернем классе
{
if (EntityTrackedVehicle == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return false;
}
switch (direction)
{
//влево
case DirectionType.Left:
if (_startPosX.Value - EntityTrackedVehicle.Step > 0)
{
_startPosX -= (int)EntityTrackedVehicle.Step;
}
return true;
//вверх
case DirectionType.Up:
if (_startPosY.Value - EntityTrackedVehicle.Step > 0)
{
_startPosY -= (int)EntityTrackedVehicle.Step;
}
return true;
//вправо
case DirectionType.Right:
if (_startPosX.Value + EntityTrackedVehicle.Step + _drawingCarWidth < _pictureWidth)
{
_startPosX += (int)EntityTrackedVehicle.Step;
}
return true;
//вниз
case DirectionType.Down:
if (_startPosY.Value + EntityTrackedVehicle.Step + _drawingCarHeight < _pictureHeight)
{
_startPosY += (int)EntityTrackedVehicle.Step;
}
return true;
default: return false;
}
}
/// <summary>
/// Метод отрисовки объекта
/// </summary>
/// <param name="gr"></param>
public virtual void DrawTransport(Graphics gr)
{
if (EntityTrackedVehicle == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new Pen(Color.Black);
//границы
gr.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 25, 75, 20);
gr.DrawRectangle(pen, _startPosX.Value, _startPosY.Value, 25, 25);
gr.DrawRectangle(pen, _startPosX.Value + 4, _startPosY.Value + 4, 17, 17);
gr.DrawRectangle(pen, _startPosX.Value + 52, _startPosY.Value + 7, 6, 18);
gr.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 45, 20, 20);
gr.DrawEllipse(pen, _startPosX.Value + 63, _startPosY.Value + 45, 20, 20);
gr.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value + 45, 68, 20);
gr.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 46, 18, 18);
gr.DrawEllipse(pen, _startPosX.Value + 62, _startPosY.Value + 46, 18, 18);
gr.DrawEllipse(pen, _startPosX.Value + 20, _startPosY.Value + 53, 10, 10);
gr.DrawEllipse(pen, _startPosX.Value + 35, _startPosY.Value + 53, 10, 10);
gr.DrawEllipse(pen, _startPosX.Value + 50, _startPosY.Value + 53, 10, 10);
gr.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value + 45, 4, 6);
gr.DrawRectangle(pen, _startPosX.Value + 45, _startPosY.Value + 45, 4, 6);
//корпус
Brush br = new SolidBrush(EntityTrackedVehicle.BodyColor);
gr.FillRectangle(br, _startPosX.Value, _startPosY.Value + 25, 75, 25);
gr.FillRectangle(br, _startPosX.Value, _startPosY.Value, 25, 25);
//окно
Brush brq = new SolidBrush(Color.AliceBlue);
gr.FillRectangle(brq, _startPosX.Value + 4, _startPosY.Value + 4, 17, 17);
//выхлопная труба
Brush brBlack = new SolidBrush(Color.Black);
gr.FillRectangle(brBlack, _startPosX.Value + 52, _startPosY.Value + 7, 6, 18);
//гусеница
Brush brDarkGray = new SolidBrush(Color.DarkGray);
gr.FillEllipse(brDarkGray, _startPosX.Value - 5, _startPosY.Value + 45, 20, 20);
gr.FillEllipse(brDarkGray, _startPosX.Value + 63, _startPosY.Value + 45, 20, 20);
gr.FillRectangle(brDarkGray, _startPosX.Value + 5, _startPosY.Value + 45, 68, 20);
gr.FillEllipse(brq, _startPosX.Value - 1, _startPosY.Value + 46, 18, 18);
gr.FillEllipse(brq, _startPosX.Value + 62, _startPosY.Value + 46, 18, 18);
gr.FillEllipse(brq, _startPosX.Value + 20, _startPosY.Value + 53, 10, 10);
gr.FillEllipse(brq, _startPosX.Value + 35, _startPosY.Value + 53, 10, 10);
gr.FillEllipse(brq, _startPosX.Value + 50, _startPosY.Value + 53, 10, 10);
gr.FillRectangle(brq, _startPosX.Value + 30, _startPosY.Value + 45, 4, 6);
gr.FillRectangle(brq, _startPosX.Value + 45, _startPosY.Value + 45, 4, 6);
}
}
}

View File

@ -1,41 +0,0 @@
namespace HoistingCrane.Entities;
/// <summary>
/// Êëàññ-ñóùíîñòü (Ïîäúåìíûé êðàí) Êëàññ íàñëåäíèê
/// </summary>
public class EntityHoistingCrane : EntityTrackedVehicle
{
/// <summary>
/// Äîïîëíèòåëüíûé öâåò îáúåêòà
/// </summary>
public Color AdditionalColor { get; protected set; }
/// <summary>
/// Íàëè÷èå ïðîòèâîâåñà
/// </summary>
public bool Counterweight { get; protected set; }
/// <summary>
/// Íàëè÷èå ïëàòôîðìû
/// </summary>
public bool Platform { get; protected set; }
/// <summary>
/// Ìåòîä çàäà÷è ïàðàìåòðîâ
/// </summary>
/// <param name="AdditionalColor">Äîï. öâåò</param>
/// <param name="Counterweight">Ãðóç äëÿ ðàâíîâåñèÿ</param>
/// <param name="Platform">Ïëàòôîðìà íà âåðåâêå</param>
// Äîïîëíÿåò íåäîñòîþùèå ýëåìåíòû èç ðîä. êëàññà
public EntityHoistingCrane(int Speed, int Weight, Color BodyColor, Color AdditionalColor, bool Counterweight, bool Platform) : base(Speed, Weight, BodyColor)
{
this.AdditionalColor = AdditionalColor;
this.Counterweight = Counterweight;
this.Platform = Platform;
}
}

View File

@ -1,49 +0,0 @@
namespace HoistingCrane.Entities
{
/// <summary>
/// Класс-сущность (Гусеничная машина) Родительский класс
/// </summary>
public class EntityTrackedVehicle
{
/// <summary>
/// Скорость, которой обладает объект
/// </summary>
public int Speed { get; protected set; }
/// <summary>
/// Вес, которым обладает объект
/// </summary>
public double Weight { get; protected set; }
/// <summary>
/// Основной цвет объекта
/// </summary>
public Color BodyColor { get; protected set; }
/// <summary>
/// Шаг движения
/// </summary>
public double Step => Speed * 100 / Weight;
/// <summary>
/// Конструктор сущности
/// </summary>
/// <param name="Speed">Скорость</param>
/// <param name="Weight">Вес</param>
/// <param name="BodyColor">Основной цвет</param>
public EntityTrackedVehicle(int Speed, double Weight, Color BodyColor)
{
this.Speed = Speed;
this.Weight = Weight;
this.BodyColor = BodyColor;
}
}
}

View File

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

View File

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

View File

@ -1,173 +0,0 @@
namespace HoistingCrane
{
partial class FormCarCollection
{
/// <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()
{
groupBoxTools = new GroupBox();
buttonGoToChek = new Button();
buttonRefresh = new Button();
buttonDeleteCar = new Button();
maskedTextBox = new MaskedTextBox();
comboBoxSelectorCompany = new ComboBox();
buttonCreateTrackedVehicle = new Button();
buttonCreateHoistingCrane = new Button();
pictureBox = new PictureBox();
groupBoxTools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
SuspendLayout();
//
// groupBoxTools
//
groupBoxTools.Controls.Add(buttonGoToChek);
groupBoxTools.Controls.Add(buttonRefresh);
groupBoxTools.Controls.Add(buttonDeleteCar);
groupBoxTools.Controls.Add(maskedTextBox);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Controls.Add(buttonCreateTrackedVehicle);
groupBoxTools.Controls.Add(buttonCreateHoistingCrane);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(716, 0);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(210, 450);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// buttonGoToChek
//
buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToChek.Location = new Point(12, 298);
buttonGoToChek.Name = "buttonGoToChek";
buttonGoToChek.Size = new Size(192, 34);
buttonGoToChek.TabIndex = 6;
buttonGoToChek.Text = "Передать на тесты";
buttonGoToChek.UseVisualStyleBackColor = true;
buttonGoToChek.Click += buttonGoToChek_Click;
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(12, 375);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(192, 34);
buttonRefresh.TabIndex = 5;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += buttonRefresh_Click;
//
// buttonDeleteCar
//
buttonDeleteCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonDeleteCar.Location = new Point(12, 233);
buttonDeleteCar.Name = "buttonDeleteCar";
buttonDeleteCar.Size = new Size(192, 34);
buttonDeleteCar.TabIndex = 4;
buttonDeleteCar.Text = "Удалить автомобиль";
buttonDeleteCar.UseVisualStyleBackColor = true;
buttonDeleteCar.Click += buttonDeleteCar_Click;
//
// maskedTextBox
//
maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
maskedTextBox.Location = new Point(12, 204);
maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(192, 23);
maskedTextBox.TabIndex = 3;
//
// comboBoxSelectorCompany
//
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(12, 28);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(192, 23);
comboBoxSelectorCompany.TabIndex = 2;
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged_1;
//
// buttonCreateTrackedVehicle
//
buttonCreateTrackedVehicle.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonCreateTrackedVehicle.Location = new Point(12, 129);
buttonCreateTrackedVehicle.Name = "buttonCreateTrackedVehicle";
buttonCreateTrackedVehicle.Size = new Size(192, 34);
buttonCreateTrackedVehicle.TabIndex = 1;
buttonCreateTrackedVehicle.Text = "Добавить гусеничную машину";
buttonCreateTrackedVehicle.UseVisualStyleBackColor = true;
buttonCreateTrackedVehicle.Click += buttonCreateTrackedVehicle_Click;
//
// buttonCreateHoistingCrane
//
buttonCreateHoistingCrane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonCreateHoistingCrane.Location = new Point(12, 89);
buttonCreateHoistingCrane.Name = "buttonCreateHoistingCrane";
buttonCreateHoistingCrane.Size = new Size(192, 34);
buttonCreateHoistingCrane.TabIndex = 0;
buttonCreateHoistingCrane.Text = "Добавить подъемный кран";
buttonCreateHoistingCrane.UseVisualStyleBackColor = true;
buttonCreateHoistingCrane.Click += buttonCreateHoistingCrane_Click;
//
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(716, 450);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
// FormCarCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(926, 450);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Name = "FormCarCollection";
Text = "FormCarCollections";
groupBoxTools.ResumeLayout(false);
groupBoxTools.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxTools;
private Button buttonCreateHoistingCrane;
private Button buttonCreateTrackedVehicle;
private ComboBox comboBoxSelectorCompany;
private Button buttonRefresh;
private Button buttonDeleteCar;
private MaskedTextBox maskedTextBox;
private PictureBox pictureBox;
private Button buttonGoToChek;
}
}

View File

@ -1,118 +0,0 @@
using HoistingCrane.CollectionGenericObjects;
using HoistingCrane.Drawning;
namespace HoistingCrane
{
public partial class FormCarCollection : Form
{
private AbstractCompany? _company;
public FormCarCollection()
{
InitializeComponent();
}
private void comboBoxSelectorCompany_SelectedIndexChanged_1(object sender, EventArgs e)
{
switch (comboBoxSelectorCompany.Text)
{
case "Хранилище":
_company = new Garage(pictureBox.Width, pictureBox.Height, new MassivGenericObjects<DrawningTrackedVehicle>());
break;
}
}
private void CreateObject(string type)
{
DrawningTrackedVehicle drawning;
if (_company == null) return;
Random rand = new();
switch (type)
{
case nameof(DrawningHoistingCrane):
drawning = new DrawningHoistingCrane(rand.Next(100, 300), rand.Next(1000, 3000), GetColor(rand), GetColor(rand), true, true);
break;
case nameof(DrawningTrackedVehicle):
drawning = new DrawningTrackedVehicle(rand.Next(100, 300), rand.Next(1000, 3000), GetColor(rand));
break;
default:
return;
}
if ((_company + drawning) != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
private static Color GetColor(Random random)
{
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;
}
return color;
}
private void buttonCreateHoistingCrane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningHoistingCrane));
private void buttonCreateTrackedVehicle_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTrackedVehicle));
private void buttonDeleteCar_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
{
return;
}
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = Convert.ToInt32(maskedTextBox.Text);
if ((_company - pos) != null)
{
MessageBox.Show("Объект удален!");
pictureBox.Image = _company.Show();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
private void buttonRefresh_Click(object sender, EventArgs e)
{
if (_company == null) return;
pictureBox.Image = _company.Show();
}
private void buttonGoToChek_Click(object sender, EventArgs e)
{
if (_company == null) return;
DrawningTrackedVehicle? car = null;
int count = 100;
while (car == null)
{
car = _company.GetRandomObject();
count--;
if (count <= 0) break;
}
if (car == null) return;
FormHoistingCrane form = new()
{
SetCar = car
};
form.ShowDialog();
}
}
}

View File

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

@ -1,138 +0,0 @@
using Microsoft.VisualBasic.ApplicationServices;
using System.ComponentModel.Design;
using System.Resources;
namespace HoistingCrane
{
partial class FormHoistingCrane
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
pictureBoxHoistingCrane = new PictureBox();
ButtonLeft = new Button();
ButtonRight = new Button();
ButtonUp = new Button();
ButtonDown = new Button();
comboStrategy = new ComboBox();
buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxHoistingCrane).BeginInit();
SuspendLayout();
//
// pictureBoxHoistingCrane
//
pictureBoxHoistingCrane.Dock = DockStyle.Fill;
pictureBoxHoistingCrane.Location = new Point(0, 0);
pictureBoxHoistingCrane.Name = "pictureBoxHoistingCrane";
pictureBoxHoistingCrane.Size = new Size(818, 515);
pictureBoxHoistingCrane.TabIndex = 0;
pictureBoxHoistingCrane.TabStop = false;
//
// ButtonLeft
//
ButtonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
ButtonLeft.BackgroundImage = Properties.Resources.left_arrow;
ButtonLeft.BackgroundImageLayout = ImageLayout.Stretch;
ButtonLeft.Location = new Point(642, 475);
ButtonLeft.Name = "ButtonLeft";
ButtonLeft.Size = new Size(40, 40);
ButtonLeft.TabIndex = 2;
ButtonLeft.UseVisualStyleBackColor = true;
ButtonLeft.Click += ButtonMove_Click;
//
// ButtonRight
//
ButtonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
ButtonRight.BackgroundImage = Properties.Resources.right_arrow;
ButtonRight.BackgroundImageLayout = ImageLayout.Stretch;
ButtonRight.Location = new Point(734, 475);
ButtonRight.Name = "ButtonRight";
ButtonRight.Size = new Size(40, 40);
ButtonRight.TabIndex = 3;
ButtonRight.UseVisualStyleBackColor = true;
ButtonRight.Click += ButtonMove_Click;
//
// ButtonUp
//
ButtonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
ButtonUp.BackgroundImage = Properties.Resources.up_arrow;
ButtonUp.BackgroundImageLayout = ImageLayout.Stretch;
ButtonUp.Location = new Point(688, 429);
ButtonUp.Name = "ButtonUp";
ButtonUp.Size = new Size(40, 40);
ButtonUp.TabIndex = 4;
ButtonUp.UseVisualStyleBackColor = true;
ButtonUp.Click += ButtonMove_Click;
//
// ButtonDown
//
ButtonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
ButtonDown.BackgroundImage = Properties.Resources.arrow_down_sign_to_navigate;
ButtonDown.BackgroundImageLayout = ImageLayout.Stretch;
ButtonDown.Location = new Point(688, 475);
ButtonDown.Name = "ButtonDown";
ButtonDown.Size = new Size(40, 40);
ButtonDown.TabIndex = 5;
ButtonDown.UseVisualStyleBackColor = true;
ButtonDown.Click += ButtonMove_Click;
//
// comboStrategy
//
comboStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
comboStrategy.FormattingEnabled = true;
comboStrategy.Items.AddRange(new object[] { "К центру", "К краю" });
comboStrategy.Location = new Point(697, 42);
comboStrategy.Name = "comboStrategy";
comboStrategy.Size = new Size(121, 23);
comboStrategy.TabIndex = 7;
//
// buttonStrategyStep
//
buttonStrategyStep.Location = new Point(743, 71);
buttonStrategyStep.Name = "buttonStrategyStep";
buttonStrategyStep.Size = new Size(75, 23);
buttonStrategyStep.TabIndex = 8;
buttonStrategyStep.Text = "Шаг";
buttonStrategyStep.UseVisualStyleBackColor = true;
buttonStrategyStep.Click += ButtonStrategyStep_Click;
//
// FormHoistingCrane
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(818, 515);
Controls.Add(buttonStrategyStep);
Controls.Add(comboStrategy);
Controls.Add(ButtonDown);
Controls.Add(ButtonUp);
Controls.Add(ButtonRight);
Controls.Add(ButtonLeft);
Controls.Add(pictureBoxHoistingCrane);
Name = "FormHoistingCrane";
Text = "Подъемный кран";
((System.ComponentModel.ISupportInitialize)pictureBoxHoistingCrane).EndInit();
ResumeLayout(false);
}
// #endregion
private PictureBox pictureBoxHoistingCrane;
private Button ButtonLeft;
private Button ButtonRight;
private Button ButtonUp;
private Button ButtonDown;
private ComboBox comboStrategy;
private Button buttonStrategyStep;
}
}

View File

@ -1,102 +0,0 @@
using HoistingCrane.Drawning;
using HoistingCrane.MovementStrategy;
namespace HoistingCrane
{
public partial class FormHoistingCrane : Form
{
private DrawningTrackedVehicle? _drawning;
private AbstractStrategy? _abstractStrategy;
public FormHoistingCrane()
{
InitializeComponent();
_abstractStrategy = null;
}
public DrawningTrackedVehicle? SetCar
{
set
{
_drawning = value;
_drawning?.SetPictureSize(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
comboStrategy.Enabled = true;
Draw();
}
}
private void Draw()
{
Bitmap bmp = new(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawning?.DrawTransport(gr);
pictureBoxHoistingCrane.Image = bmp;
}
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_drawning == null) { return; }
String name = ((Button)sender)?.Name ?? string.Empty;
bool result = false;
switch (name)
{
case "ButtonUp":
result = _drawning.MoveTransport(DirectionType.Up);
break;
case "ButtonDown":
result = _drawning.MoveTransport(DirectionType.Down);
break;
case "ButtonRight":
result = _drawning.MoveTransport(DirectionType.Right);
break;
case "ButtonLeft":
result = _drawning.MoveTransport(DirectionType.Left);
break;
}
if (result)
{
Draw();
}
}
private void ButtonStrategyStep_Click(object sender, EventArgs e)
{
if (_drawning == null)
{
return;
}
if (comboStrategy.Enabled)
{
_abstractStrategy = comboStrategy.SelectedIndex switch
{
0 => new MoveToCenter(),
1 => new MoveToBorder(),
_ => null,
};
if (_abstractStrategy == null)
{
return;
}
_abstractStrategy.SetData(new MoveableCar(_drawning), pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height);
}
if (_abstractStrategy == null)
{
return;
}
comboStrategy.Enabled = false;
_abstractStrategy.MakeStep();
Draw();
if (_abstractStrategy.GetStatus() == StrategyStatus.Finish)
{
comboStrategy.Enabled = true;
_abstractStrategy = null;
}
}
}
}

View File

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

@ -8,23 +8,4 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Remove="CollectionGenericObjects\MassivGenericObjects.cs~RF2955bcc.TMP" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project> </Project>

View File

@ -1,137 +0,0 @@
namespace HoistingCrane.MovementStrategy
{
public abstract class AbstractStrategy
{
/// <summary>
/// Перемещаемый объект
/// </summary>
private IMoveableObjects? _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="moveableObject">Перемещаемый объект</param>
/// <param name="width">Ширина поля</param>
/// <param name="height">Высота поля</param>
public void SetData(IMoveableObjects moveableObject, int width, int height)
{
if (moveableObject == null)
{
_state = StrategyStatus.NotInit;
return;
}
_state = StrategyStatus.InProgress;
_moveableObject = moveableObject;
FieldWidth = width;
FieldHeight = height;
}
/// <summary>
/// Шаг перемещения
/// </summary>
public void MakeStep()
{
if (_state != StrategyStatus.InProgress)
{
return;
}
if (IsTargetDestination())
{
_state = StrategyStatus.Finish;
return;
}
MoveToTarget();
}
/// <summary>
/// Перемещение влево
/// </summary>
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
protected bool MoveLeft() => MoveTo(MovementDirection.Left);
/// <summary>
/// Перемещение вправо
/// </summary>
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
protected bool MoveRight() => MoveTo(MovementDirection.Right);
/// <summary>
/// Перемещение вверх
/// </summary>
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
protected bool MoveUp() => MoveTo(MovementDirection.Up);
/// <summary>
/// Перемещение вниз
/// </summary>
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</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();
/// <summary>
/// Попытка перемещения в требуемом направлении
/// </summary>
/// <param name="movementDirection">Направление</param>
/// <returns>Результат попытки (true - удалось, false - неудача)</returns>
private bool MoveTo(MovementDirection movementDirection)
{
if (_state != StrategyStatus.InProgress)
{
return false;
}
return _moveableObject?.TryMoveObject(movementDirection) ?? false;
}
}
}

View File

@ -1,24 +0,0 @@
namespace HoistingCrane.MovementStrategy
{
public interface IMoveableObjects
{
/// <summary>
/// Получение позиции объекта
/// </summary>
ObjectParameters? GetObjectPosition { get; }
/// <summary>
/// Получение шага объекта
/// </summary>
int GetStep { get; }
/// <summary>
/// Попытка переместить объект в указанном направлении
/// </summary>
/// <param name="direction">направление</param>
/// <returns></returns>
bool TryMoveObject(MovementDirection direction);
}
}

View File

@ -1,52 +0,0 @@
using System.Configuration;
namespace HoistingCrane.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())
{
if (diffX > 0)
{
MoveLeft();
}
else
{
MoveRight();
}
}
int diffY = objParams.DownBorder - FieldHeight;
if (Math.Abs(diffY) > GetStep())
{
if (diffY > 0)
{
MoveUp();
}
else
{
MoveDown();
}
}
}
}
}

View File

@ -1,52 +0,0 @@
namespace HoistingCrane.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

@ -1,62 +0,0 @@
using HoistingCrane.Drawning;
namespace HoistingCrane.MovementStrategy
{
public class MoveableCar : IMoveableObjects
{
/// <summary>
/// Поле-объект класса DrawningAirplane или его наследника
/// </summary>
private readonly DrawningTrackedVehicle? drawningTrackedVehicle = null;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="airplane">Объект класса DrawningAirplane</param>
public MoveableCar(DrawningTrackedVehicle drawningTrackedVehicle)
{
this.drawningTrackedVehicle = drawningTrackedVehicle;
}
public ObjectParameters? GetObjectPosition
{
get
{
if (drawningTrackedVehicle == null || drawningTrackedVehicle.EntityTrackedVehicle == null || !drawningTrackedVehicle.GetPosX.HasValue || !drawningTrackedVehicle.GetPosY.HasValue)
{
return null;
}
return new ObjectParameters(drawningTrackedVehicle.GetPosX.Value, drawningTrackedVehicle.GetPosY.Value, drawningTrackedVehicle.GetWidth, drawningTrackedVehicle.GetHeight);
}
}
public int GetStep => (int)(drawningTrackedVehicle?.EntityTrackedVehicle?.Step ?? 0);
public bool TryMoveObject(MovementDirection direction)
{
if (drawningTrackedVehicle == null || drawningTrackedVehicle.EntityTrackedVehicle == null)
{
return false;
}
return drawningTrackedVehicle.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.Left => DirectionType.Left,
MovementDirection.Right => DirectionType.Right,
MovementDirection.Up => DirectionType.Up,
MovementDirection.Down => DirectionType.Down,
_ => DirectionType.Unknow,
};
}
}
}

View File

@ -1,24 +0,0 @@
namespace HoistingCrane.MovementStrategy
{
public enum MovementDirection
{
//Перечислим основные траектории движния нашего автомобиля. Сразу же зададим значения.
/// <summary>
/// Вверх1
/// </summary>
Up = 1,
/// <summary>
/// Вниз
/// </summary>
Down = 2,
/// <summary>
/// Влево
/// </summary>
Left = 3,
/// <summary>
/// Вправо
/// </summary>
Right = 4
}
}

View File

@ -1,70 +0,0 @@
namespace HoistingCrane.MovementStrategy
{
public class ObjectParameters
{
/// <summary>
/// Начальная координата х
/// </summary>
private readonly int _x;
/// <summary>
/// Начальная координата y
/// </summary>
private readonly int _y;
/// <summary>
/// Ширина объекта
/// </summary>
private readonly int _width;
/// <summary>
/// Высота объекта
/// </summary>
private readonly int _height;
/// <summary>
/// Левая граница
/// </summary>
public int LeftBorder => _x;
/// <summary>
/// Правая граница
/// </summary>
public int RightBorder => _x + _width;
/// <summary>
/// Верхняя граница
/// </summary>
public int TopBorder => _y;
/// <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">Координата по х</param>
/// <param name="_y">Координата по у</param>
/// <param name="_width">Ширина объекта</param>
/// <param name="_height">Высота объекта</param>
public ObjectParameters(int _x, int _y, int _width, int _height)
{
this._x = _x;
this._y = _y;
this._width = _width;
this._height = _height;
}
}
}

View File

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

View File

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

View File

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

View File

@ -1,133 +0,0 @@
<?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="right-arrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\right-arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="left-arrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\left-arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="up-arrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\up-arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrow-down-sign-to-navigate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrow-down-sign-to-navigate.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB