Compare commits

...

36 Commits

Author SHA1 Message Date
sqdselo
8d7324d52e Разрешены конфликты 2024-05-05 13:23:10 +04:00
sqdselo
f51c2c348f Борюсь с конфликтами 2024-05-05 13:08:21 +04:00
sqdselo
08c1734614 Готовая лаба 4 2024-05-05 00:20:13 +04:00
sqdselo
ad565c92f3 Готовая лаба3 2024-05-04 20:15:42 +04:00
sqdselo
7f4d7dfdce Готовая лабораторная работа 4 2024-05-04 15:59:20 +04:00
592fd5bea5 Готовая лабораторная работа 4 2024-04-29 12:00:25 +04:00
sqdselo
21f4acf2d5 Готовая лабораторная 4 2024-04-28 10:26:11 +04:00
sqdselo
0a9f5bcbb6 Готовая лабораторная работа 3 2024-04-28 00:31:52 +04:00
sqdselo
052b9929c1 Готовая 4 лабораторная работа 2024-04-28 00:20:54 +04:00
sqdselo
4de1bca002 Лабораторная 3 финал 2024-04-22 19:48:41 +04:00
sqdselo
f57496c459 доделать 2024-04-22 19:10:26 +04:00
ff1e1066b6 доделаю 2024-04-15 14:25:51 +04:00
5f5f61f51b лабораторная 3 2024-04-15 12:30:38 +04:00
sqdselo
50146d6d1b Лаба4 2024-04-14 21:43:46 +04:00
sqdselo
52b3bc2a87 Merge branch 'LabWork04' of http://student.git.athene.tech/sqdselo/pibd-12_Tangatarov.I.A._Base into LabWork04 2024-04-07 15:46:01 +04:00
sqdselo
486da066a1 Готово+- 2024-04-07 15:45:51 +04:00
sqdselo
46fb3ca9d8 доделаю 2024-04-04 15:14:16 +04:00
sqdselo
92f30977af Merge branch 'LabWork03' of http://student.git.athene.tech/sqdselo/pibd-12_Tangatarov.I.A._Base into LabWork03 2024-04-04 14:54:22 +04:00
sqdselo
feea0da22b Лабораторная работa 3 2024-04-04 14:53:50 +04:00
sqdselo
948209a130 доделать 2024-04-01 20:44:55 +04:00
4eeaacde4b Удалить 'Безымянный.png' 2024-04-01 18:39:17 +04:00
0b56d30241 Удалить "Безымянный png" 2024-04-01 18:38:51 +04:00
sqdselo
051ef5f863 доделаю 2024-04-01 18:36:14 +04:00
sqdselo
681e60fbd6 Лабораторная работка #3 2024-04-01 18:26:17 +04:00
dc01587054 Итоговая лабораторная работа 3 2024-04-01 14:05:34 +04:00
sqdselo
5c08bba55b прописать логику удаления элемента из коллекции 2024-04-01 02:15:50 +04:00
sqdselo
95a176686a не прописан функционал кнопок формы. допишу 2024-04-01 02:01:34 +04:00
sqdselo
b967200792 Теперь точно всё готово. Лабораторная работа 3 2024-04-01 01:15:33 +04:00
sqdselo
0be2471e88 Лабораторная работа №3 2024-03-31 22:08:27 +04:00
sqdselo
7fe1682f7b Коллекции объектов 2024-03-17 23:37:52 +04:00
sqdselo
b32311652f Лабораторная работа №2 2024-03-04 19:24:17 +04:00
b386a86150 Лабораторная работа №2 2024-03-04 13:07:36 +04:00
a1dab73b6d Лабораторная работа №2 2024-03-04 13:07:10 +04:00
sqdselo
534f994111 Добавление родителей и ввод конструкторов 2024-03-02 21:31:53 +04:00
83216e0433 Лабораторная работа №1 2024-02-19 13:55:12 +04:00
sqdselo
0455a1fe3f Лабораторная работа №1 2024-02-17 23:43:01 +04:00
37 changed files with 2551 additions and 51 deletions

View File

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

View File

@ -0,0 +1,88 @@
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);
}
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

@ -0,0 +1,8 @@
using System;
namespace HoistingCrane.CollectionGenericObjects
{
public enum CollectionType
{
None = 0, Massive = 1, List = 2
}
}

View File

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

@ -0,0 +1,40 @@
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);
/// <summary>
/// Получение объекта коллекции
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
T? Get(int position);
}
}

View File

@ -0,0 +1,74 @@
using System;
using System.CodeDom.Compiler;
using System.Windows.Forms.VisualStyles;
namespace HoistingCrane.CollectionGenericObjects
{
public class ListGenericObjects<T> : ICollectionGenericObjects<T> where T : class
{
/// <summary>
/// Список объектов, которые храним
/// </summary>
readonly List<T> list;
/// <summary>
/// Конструктор
/// </summary>
public ListGenericObjects()
{
list = new List<T>();
}
/// <summary>
/// Максимально допустимое число объектов в списке
/// </summary>
private int _maxCount;
public int Count
{
get { return list.Count; }
}
public int SetMaxCount
{
set
{
if(value > 0)
{
_maxCount = value;
}
}
}
public T? Get(int position)
{
if (position >= Count || position < 0) return null;
return list[position];
}
public int Insert(T obj)
{
if (Count == _maxCount)
{
return -1;
}
list.Add(obj);
return Count;
}
public int Insert(T obj, int position)
{
if (position < 0 || position >= Count || Count == _maxCount)
{
return -1;
}
list.Insert(position, obj);
return position;
}
public T? Remove(int position)
{
if(position >= 0 && position < list.Count)
{
T? temp = list[position];
list.RemoveAt(position);
return temp;
}
return null;
}
}
}

View File

@ -0,0 +1,89 @@
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)
{
if (position < 0 || position >= Count)
{
return -1;
}
int copyPos = position - 1;
while (position < Count)
{
if (arr[position] == null)
{
arr[position] = obj;
return position;
}
position++;
}
while (copyPos > 0)
{
if (arr[copyPos] == null)
{
arr[copyPos] = obj;
return copyPos;
}
copyPos--;
}
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

@ -0,0 +1,63 @@
using System;
namespace HoistingCrane.CollectionGenericObjects
{
public class StorageCollection<T> where T : class
{
/// <summary>
/// Словарь (хранилище) с коллекциями
/// </summary>
readonly Dictionary<string, ICollectionGenericObjects<T>> dict;
/// <summary>
/// Возвращение списка названий коллекций
/// </summary>
public List<string> Keys => dict.Keys.ToList();
/// <summary>
/// Конструктор
/// </summary>
public StorageCollection()
{
dict = new Dictionary<string, ICollectionGenericObjects<T>>();
}
/// <summary>
/// Добавление коллекции в хранилище
/// </summary>
/// <param name="name">Название коллекции</param>
/// <param name="collectionType">тип коллекции</param>
public void AddCollection(string name, CollectionType collectionType)
{
if (dict.ContainsKey(name)) return;
if (collectionType == CollectionType.None) return;
else if (collectionType == CollectionType.Massive)
dict[name] = new MassivGenericObjects<T>();
else if (collectionType == CollectionType.List)
dict[name] = new ListGenericObjects<T>();
}
/// <summary>
/// Удаление коллекции
/// </summary>
/// <param name="name">Название коллекции</param>
public void DelCollection(string name)
{
if(Keys.Contains(name))
{
dict.Remove(name);
}
}
/// <summary>
/// Доступ к коллекции
/// </summary>
/// <param name="name">Название коллекции</param>
/// <returns></returns>
public ICollectionGenericObjects<T>? this[string name]
{
get
{
if (dict.ContainsKey(name))
return dict[name];
return null;
}
}
}
}

View File

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

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

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

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

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

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

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

View File

@ -0,0 +1,302 @@
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();
buttonCreateCompany = new Button();
panelCompanyTool = new Panel();
buttonRefresh = new Button();
buttonGoToChek = new Button();
buttonCreateHoistingCrane = new Button();
buttonCreateTrackedVehicle = new Button();
buttonDeleteCar = new Button();
maskedTextBox = new MaskedTextBox();
panelStorage = new Panel();
buttonDeleteCollection = new Button();
listBoxCollection = new ListBox();
buttonCollectionAdd = new Button();
radioButtonList = new RadioButton();
radioButtonMassive = new RadioButton();
textBoxCollectionName = new TextBox();
labelCollectionName = new Label();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
groupBoxTools.SuspendLayout();
panelCompanyTool.SuspendLayout();
panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
SuspendLayout();
//
// groupBoxTools
//
groupBoxTools.Controls.Add(buttonCreateCompany);
groupBoxTools.Controls.Add(panelCompanyTool);
groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(759, 0);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(214, 509);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// buttonCreateCompany
//
buttonCreateCompany.Location = new Point(12, 288);
buttonCreateCompany.Name = "buttonCreateCompany";
buttonCreateCompany.Size = new Size(196, 23);
buttonCreateCompany.TabIndex = 7;
buttonCreateCompany.Text = "Создать компанию";
buttonCreateCompany.UseVisualStyleBackColor = true;
buttonCreateCompany.Click += buttonCreateCompany_Click;
//
// panelCompanyTool
//
panelCompanyTool.Anchor = AnchorStyles.None;
panelCompanyTool.Controls.Add(buttonRefresh);
panelCompanyTool.Controls.Add(buttonGoToChek);
panelCompanyTool.Controls.Add(buttonCreateHoistingCrane);
panelCompanyTool.Controls.Add(buttonCreateTrackedVehicle);
panelCompanyTool.Controls.Add(buttonDeleteCar);
panelCompanyTool.Controls.Add(maskedTextBox);
panelCompanyTool.Enabled = false;
panelCompanyTool.Location = new Point(3, 317);
panelCompanyTool.Name = "panelCompanyTool";
panelCompanyTool.Size = new Size(208, 238);
panelCompanyTool.TabIndex = 8;
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(9, 159);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(196, 27);
buttonRefresh.TabIndex = 5;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += buttonRefresh_Click;
//
// buttonGoToChek
//
buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToChek.Location = new Point(9, 119);
buttonGoToChek.Name = "buttonGoToChek";
buttonGoToChek.Size = new Size(196, 24);
buttonGoToChek.TabIndex = 6;
buttonGoToChek.Text = "Передать на тесты";
buttonGoToChek.UseVisualStyleBackColor = true;
buttonGoToChek.Click += buttonGoToChek_Click;
//
// buttonCreateHoistingCrane
//
buttonCreateHoistingCrane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonCreateHoistingCrane.Location = new Point(9, 3);
buttonCreateHoistingCrane.Name = "buttonCreateHoistingCrane";
buttonCreateHoistingCrane.Size = new Size(196, 22);
buttonCreateHoistingCrane.TabIndex = 0;
buttonCreateHoistingCrane.Text = "Добавить подъемный кран";
buttonCreateHoistingCrane.UseVisualStyleBackColor = true;
buttonCreateHoistingCrane.Click += buttonCreateHoistingCrane_Click;
//
// buttonCreateTrackedVehicle
//
buttonCreateTrackedVehicle.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonCreateTrackedVehicle.Location = new Point(9, 31);
buttonCreateTrackedVehicle.Name = "buttonCreateTrackedVehicle";
buttonCreateTrackedVehicle.Size = new Size(196, 24);
buttonCreateTrackedVehicle.TabIndex = 1;
buttonCreateTrackedVehicle.Text = "Добавить гусеничную машину";
buttonCreateTrackedVehicle.UseVisualStyleBackColor = true;
buttonCreateTrackedVehicle.Click += buttonCreateTrackedVehicle_Click;
//
// buttonDeleteCar
//
buttonDeleteCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonDeleteCar.Location = new Point(9, 90);
buttonDeleteCar.Name = "buttonDeleteCar";
buttonDeleteCar.Size = new Size(196, 23);
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(9, 61);
maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(196, 23);
maskedTextBox.TabIndex = 3;
//
// panelStorage
//
panelStorage.Controls.Add(buttonDeleteCollection);
panelStorage.Controls.Add(listBoxCollection);
panelStorage.Controls.Add(buttonCollectionAdd);
panelStorage.Controls.Add(radioButtonList);
panelStorage.Controls.Add(radioButtonMassive);
panelStorage.Controls.Add(textBoxCollectionName);
panelStorage.Controls.Add(labelCollectionName);
panelStorage.Dock = DockStyle.Top;
panelStorage.Location = new Point(3, 19);
panelStorage.Name = "panelStorage";
panelStorage.Size = new Size(208, 229);
panelStorage.TabIndex = 7;
//
// buttonDeleteCollection
//
buttonDeleteCollection.Location = new Point(9, 199);
buttonDeleteCollection.Name = "buttonDeleteCollection";
buttonDeleteCollection.Size = new Size(192, 27);
buttonDeleteCollection.TabIndex = 6;
buttonDeleteCollection.Text = "Удалить коллекцию";
buttonDeleteCollection.UseVisualStyleBackColor = true;
buttonDeleteCollection.Click += buttonDeleteCollection_Click;
//
// listBoxCollection
//
listBoxCollection.FormattingEnabled = true;
listBoxCollection.ItemHeight = 15;
listBoxCollection.Location = new Point(9, 118);
listBoxCollection.Name = "listBoxCollection";
listBoxCollection.Size = new Size(192, 79);
listBoxCollection.TabIndex = 5;
//
// buttonCollectionAdd
//
buttonCollectionAdd.Location = new Point(9, 81);
buttonCollectionAdd.Name = "buttonCollectionAdd";
buttonCollectionAdd.Size = new Size(192, 23);
buttonCollectionAdd.TabIndex = 4;
buttonCollectionAdd.Text = "Добавить коллекцию";
buttonCollectionAdd.UseVisualStyleBackColor = true;
buttonCollectionAdd.Click += buttonCollectionAdd_Click;
//
// radioButtonList
//
radioButtonList.AutoSize = true;
radioButtonList.Location = new Point(128, 56);
radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(66, 19);
radioButtonList.TabIndex = 3;
radioButtonList.TabStop = true;
radioButtonList.Text = "Список";
radioButtonList.UseVisualStyleBackColor = true;
//
// radioButtonMassive
//
radioButtonMassive.AutoSize = true;
radioButtonMassive.Location = new Point(18, 56);
radioButtonMassive.Name = "radioButtonMassive";
radioButtonMassive.Size = new Size(67, 19);
radioButtonMassive.TabIndex = 2;
radioButtonMassive.TabStop = true;
radioButtonMassive.Text = "Массив";
radioButtonMassive.UseVisualStyleBackColor = true;
//
// textBoxCollectionName
//
textBoxCollectionName.Location = new Point(9, 18);
textBoxCollectionName.Name = "textBoxCollectionName";
textBoxCollectionName.Size = new Size(192, 23);
textBoxCollectionName.TabIndex = 1;
//
// labelCollectionName
//
labelCollectionName.AutoSize = true;
labelCollectionName.Location = new Point(35, 0);
labelCollectionName.Name = "labelCollectionName";
labelCollectionName.Size = new Size(125, 15);
labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции:";
//
// 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, 259);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(196, 23);
comboBoxSelectorCompany.TabIndex = 2;
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged;
//
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(759, 509);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
// FormCarCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(973, 509);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Name = "FormCarCollection";
Text = "FormCarCollections";
groupBoxTools.ResumeLayout(false);
panelCompanyTool.ResumeLayout(false);
panelCompanyTool.PerformLayout();
panelStorage.ResumeLayout(false);
panelStorage.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;
private Panel panelStorage;
private RadioButton radioButtonList;
private RadioButton radioButtonMassive;
private TextBox textBoxCollectionName;
private Label labelCollectionName;
private Button buttonCreateCompany;
private Button buttonDeleteCollection;
private ListBox listBoxCollection;
private Button buttonCollectionAdd;
private Panel panelCompanyTool;
}
}

View File

@ -0,0 +1,188 @@
using HoistingCrane.CollectionGenericObjects;
using HoistingCrane.Drawning;
namespace HoistingCrane
{
public partial class FormCarCollection : Form
{
private AbstractCompany? _company = null;
private readonly StorageCollection<DrawningTrackedVehicle> _storageCollection;
public FormCarCollection()
{
InitializeComponent();
_storageCollection = new();
}
private void comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
{
panelCompanyTool.Enabled = false;
}
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();
}
/// <summary>
/// Обновление списка в listBoxCollection
/// </summary>
private void RerfreshListBoxItems()
{
listBoxCollection.Items.Clear();
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
{
string? colName = _storageCollection.Keys?[i];
if (!string.IsNullOrEmpty(colName))
{
listBoxCollection.Items.Add(colName);
}
}
}
private void buttonCollectionAdd_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked))
{
MessageBox.Show("Не все данные заполнены", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
CollectionType collectionType = CollectionType.None;
if (radioButtonMassive.Checked)
{
collectionType = CollectionType.Massive;
}
else if (radioButtonList.Checked)
{
collectionType = CollectionType.List;
}
_storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
RerfreshListBoxItems();
}
private void buttonDeleteCollection_Click(object sender, EventArgs e)
{
// TODO прописать логику удаления элемента из коллекции
// нужно убедиться, что есть выбранная коллекция
// спросить у пользователя через MessageBox, что он подтверждает, что хочет удалить запись
// удалить и обновить ListBox
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
{
MessageBox.Show("Коллекция не выбрана");
return;
}
if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
RerfreshListBoxItems();
}
private void buttonCreateCompany_Click(object sender, EventArgs e)
{
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
{
MessageBox.Show("Коллекция не выбрана");
return;
}
ICollectionGenericObjects<DrawningTrackedVehicle>? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
if (collection == null)
{
MessageBox.Show("Коллекция не проинициализирована");
return;
}
switch (comboBoxSelectorCompany.Text)
{
case "Хранилище":
_company = new Garage(pictureBox.Width, pictureBox.Height, collection);
break;
}
panelCompanyTool.Enabled = true;
RerfreshListBoxItems();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

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

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

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -8,4 +8,23 @@
<ImplicitUsings>enable</ImplicitUsings>
</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>

View File

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

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

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

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

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

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

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

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

View File

@ -11,7 +11,8 @@ namespace HoistingCrane
// 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 FormCarCollection());
}
}
}

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <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

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="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.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB