Compare commits
No commits in common. "LabWork08" and "main" have entirely different histories.
@ -1,25 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 17
|
|
||||||
VisualStudioVersion = 17.7.34024.191
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectDumpTruck", "ProjectDumpTruck\ProjectDumpTruck.csproj", "{0045C558-05F7-4B43-8DE8-C584B0F61ED9}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{0045C558-05F7-4B43-8DE8-C584B0F61ED9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{0045C558-05F7-4B43-8DE8-C584B0F61ED9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{0045C558-05F7-4B43-8DE8-C584B0F61ED9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{0045C558-05F7-4B43-8DE8-C584B0F61ED9}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {3D9D0B1A-F218-49F4-953E-48B3D60F206A}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
@ -1,127 +0,0 @@
|
|||||||
using ProjectDumpTruck.Drawnings;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.CollectionGenericObjects;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Абстракция компании, хранящий коллекцию автомобилей
|
|
||||||
/// </summary>
|
|
||||||
public abstract class AbstractCompany
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Размер места (ширина)
|
|
||||||
/// </summary>
|
|
||||||
protected readonly int _placeSizeWidth = 120;
|
|
||||||
/// <summary>
|
|
||||||
/// Размер места (высота)
|
|
||||||
/// </summary>
|
|
||||||
protected readonly int _placeSizeHeight = 120;
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина окна
|
|
||||||
/// </summary>
|
|
||||||
protected readonly int _pictureWidth;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота окна
|
|
||||||
/// </summary>
|
|
||||||
protected readonly int _pictureHeight;
|
|
||||||
/// <summary>
|
|
||||||
/// Коллекция автомобилей
|
|
||||||
/// </summary>
|
|
||||||
protected ICollectionGenericObjects<DrawningTruck>? _collection = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вычисление максимального количества элементов, который можно разместить в окне
|
|
||||||
/// </summary>
|
|
||||||
private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight);
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="picWidth">Ширина окна</param>
|
|
||||||
/// <param name="picHeight">Высота окна</param>
|
|
||||||
/// <param name="collection">Коллекция автомобилей</param>
|
|
||||||
public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects<DrawningTruck> collection)
|
|
||||||
{
|
|
||||||
_pictureWidth = picWidth;
|
|
||||||
_pictureHeight = picHeight;
|
|
||||||
_collection = collection;
|
|
||||||
_collection.MaxCount = GetMaxCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перегрузка оператора сложения для класса
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="company">Компания</param>
|
|
||||||
/// <param name="truck">Добавляемый объект</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static int operator +(AbstractCompany company, DrawningTruck truck)
|
|
||||||
{
|
|
||||||
return company._collection.Insert(truck, new DrawiningTruckEqutables());
|
|
||||||
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перегрузка оператора удаления для класса
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="company">Компания</param>
|
|
||||||
/// <param name="position">Номер удаляемого объекта</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static DrawningTruck operator -(AbstractCompany company, int position)
|
|
||||||
{
|
|
||||||
return company._collection.Remove(position);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение случайного объекта из коллекции
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public DrawningTruck? GetRandomObject()
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
return _collection?.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 < (_collection?.Count ?? 0); ++i)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DrawningTruck? obj = _collection?.Get(i);
|
|
||||||
obj?.DrawTransport(graphics);
|
|
||||||
}
|
|
||||||
catch (Exception) { }
|
|
||||||
}
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сортировка
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="comparer">Сравнитель объектов</param>
|
|
||||||
public void Sort(IComparer<DrawningTruck?> comparer) => _collection?.CollectionSort(comparer);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вывод заднего фона
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
protected abstract void DrawBackgound(Graphics g);
|
|
||||||
/// <summary>
|
|
||||||
/// Расстановка объектов
|
|
||||||
/// </summary>
|
|
||||||
protected abstract void SetObjectsPosition();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.CollectionGenericObjects;
|
|
||||||
|
|
||||||
public class CollectionInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Название
|
|
||||||
/// </summary>
|
|
||||||
public string Name { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Тип
|
|
||||||
/// </summary>
|
|
||||||
public CollectionType CollectionType { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Описание
|
|
||||||
/// </summary>
|
|
||||||
public string Description { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Разделитель для записи информации по объекту в файл
|
|
||||||
/// </summary>
|
|
||||||
private static readonly string _separator = "-";
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Название</param>
|
|
||||||
/// <param name="collectionType">Тип</param>
|
|
||||||
/// <param name="description">Описание</param>
|
|
||||||
public CollectionInfo(string name, CollectionType collectionType, string
|
|
||||||
description)
|
|
||||||
{
|
|
||||||
Name = name;
|
|
||||||
CollectionType = collectionType;
|
|
||||||
Description = description;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Создание объекта из строки
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="data">Строка</param>
|
|
||||||
/// <returns>Объект или null</returns>
|
|
||||||
public static CollectionInfo? GetCollectionInfo(string data)
|
|
||||||
{
|
|
||||||
string[] strs = data.Split(_separator, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
if (strs.Length < 1 || strs.Length > 3)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new CollectionInfo(strs[0], (CollectionType)Enum.Parse(typeof(CollectionType),
|
|
||||||
strs[1]), strs.Length > 2 ? strs[2] : string.Empty);
|
|
||||||
}
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return Name + _separator + CollectionType + _separator + Description;
|
|
||||||
}
|
|
||||||
public bool Equals(CollectionInfo? other)
|
|
||||||
{
|
|
||||||
return Name == other?.Name;
|
|
||||||
}
|
|
||||||
public override bool Equals(object? obj)
|
|
||||||
{
|
|
||||||
return Equals(obj as CollectionInfo);
|
|
||||||
}
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return Name.GetHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.CollectionGenericObjects;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Тип коллекции
|
|
||||||
/// </summary>
|
|
||||||
public enum CollectionType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Неопределено
|
|
||||||
/// </summary>
|
|
||||||
None = 0,
|
|
||||||
/// <summary>
|
|
||||||
/// Массив
|
|
||||||
/// </summary>
|
|
||||||
Massive = 1,
|
|
||||||
/// <summary>
|
|
||||||
/// Список
|
|
||||||
/// </summary>
|
|
||||||
List = 2
|
|
||||||
}
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
|||||||
using ProjectDumpTruck.Drawnings;
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.CollectionGenericObjects;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Интерфейс описания действий для набора хранимых объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
|
|
||||||
public interface ICollectionGenericObjects<T>
|
|
||||||
where T : class
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Количество объектов в коллекции
|
|
||||||
/// </summary>
|
|
||||||
int Count { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Установка максимального количества элементов
|
|
||||||
/// </summary>
|
|
||||||
int MaxCount { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление объекта в коллекцию
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">Добавляемый объект</param>
|
|
||||||
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
|
||||||
int Insert(T obj, IEqualityComparer<T?>? comparer = null);
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление объекта в коллекцию на конкретную позицию
|
|
||||||
/// </summary>
|
|
||||||
/// /// <param name="obj">Добавляемый объект</param>
|
|
||||||
/// <param name="position">Позиция</param>
|
|
||||||
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
|
||||||
int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null);
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление объекта из коллекции с конкретной позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="position">Позиция</param>
|
|
||||||
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
|
|
||||||
T Remove(int position);
|
|
||||||
/// <summary>
|
|
||||||
/// Получение объекта по позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="position">Позиция</param>
|
|
||||||
/// <returns>Объект</returns>
|
|
||||||
T? Get(int position);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение типа коллекции
|
|
||||||
/// </summary>
|
|
||||||
CollectionType GetCollectionType { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Получение объектов коллекции по одному
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Поэлементый вывод элементов коллекции</returns>
|
|
||||||
IEnumerable<T?> GetItems();
|
|
||||||
/// <summary>
|
|
||||||
/// Сортировка коллекции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="comparer">Сравнитель объектов</param>
|
|
||||||
void CollectionSort(IComparer<T?> comparer);
|
|
||||||
|
|
||||||
}
|
|
@ -1,123 +0,0 @@
|
|||||||
using ProjectDumpTruck.Drawnings;
|
|
||||||
using ProjectDumpTruck.Exceptions;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.CollectionGenericObjects;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Параметризованный набор объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
|
|
||||||
public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|
||||||
where T : class
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Список объектов, которые храним
|
|
||||||
/// </summary>
|
|
||||||
private readonly List<T?> _collection;
|
|
||||||
/// <summary>
|
|
||||||
/// Максимально допустимое число объектов в списке
|
|
||||||
/// </summary>
|
|
||||||
private int _maxCount;
|
|
||||||
public int Count => _collection.Count;
|
|
||||||
public int MaxCount
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _maxCount;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value > 0)
|
|
||||||
{
|
|
||||||
_maxCount = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CollectionType GetCollectionType => CollectionType.List;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
public ListGenericObjects()
|
|
||||||
{
|
|
||||||
_collection = new();
|
|
||||||
}
|
|
||||||
public T? Get(int position)
|
|
||||||
{
|
|
||||||
if (position < 0 || position >= MaxCount)
|
|
||||||
{
|
|
||||||
throw new PositionOutOfCollectionException(position);
|
|
||||||
}
|
|
||||||
return _collection[position];
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
|
|
||||||
{
|
|
||||||
if (comparer != null)
|
|
||||||
{
|
|
||||||
if (_collection.Contains(obj, comparer))
|
|
||||||
{
|
|
||||||
throw new ObjectsEqualException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_collection.Count >= _maxCount)
|
|
||||||
{
|
|
||||||
throw new CollectionOverflowException(MaxCount);
|
|
||||||
}
|
|
||||||
_collection.Add(obj);
|
|
||||||
return _collection.Count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
|
|
||||||
{
|
|
||||||
if (comparer != null)
|
|
||||||
{
|
|
||||||
if (_collection.Contains(obj, comparer))
|
|
||||||
{
|
|
||||||
throw new ObjectsEqualException(position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (position < 0 || position > _maxCount)
|
|
||||||
{
|
|
||||||
throw new PositionOutOfCollectionException(position);
|
|
||||||
}
|
|
||||||
if (_collection.Count >= _maxCount)
|
|
||||||
{
|
|
||||||
throw new CollectionOverflowException(MaxCount);
|
|
||||||
}
|
|
||||||
_collection.Insert(position, obj);
|
|
||||||
return position;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Remove(int position)
|
|
||||||
{
|
|
||||||
if (position < 0 || position > _maxCount)
|
|
||||||
{
|
|
||||||
throw new PositionOutOfCollectionException(position);
|
|
||||||
}
|
|
||||||
T temp = _collection[position];
|
|
||||||
_collection.RemoveAt(position);
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<T?> GetItems()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _maxCount; ++i)
|
|
||||||
{
|
|
||||||
yield return _collection[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CollectionSort(IComparer<T?> comparer)
|
|
||||||
{
|
|
||||||
_collection.Sort(comparer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,156 +0,0 @@
|
|||||||
using ProjectDumpTruck.Drawnings;
|
|
||||||
using ProjectDumpTruck.Exceptions;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.CollectionGenericObjects;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Параметризованный набор объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
|
|
||||||
public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|
||||||
where T : class
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Массив объектов, которые храним
|
|
||||||
/// </summary>
|
|
||||||
private T?[] _collection;
|
|
||||||
public int Count => _collection.Length;
|
|
||||||
public int MaxCount
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _collection.Length;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value > 0)
|
|
||||||
{
|
|
||||||
if (_collection.Length > 0)
|
|
||||||
{
|
|
||||||
Array.Resize(ref _collection, value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_collection = new T?[value];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CollectionType GetCollectionType => CollectionType.Massive;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
public MassiveGenericObjects()
|
|
||||||
{
|
|
||||||
_collection = Array.Empty<T?>();
|
|
||||||
}
|
|
||||||
public T? Get(int position)
|
|
||||||
{
|
|
||||||
if (position < 0 || position >= MaxCount)
|
|
||||||
{
|
|
||||||
throw new PositionOutOfCollectionException(position);
|
|
||||||
}
|
|
||||||
if (_collection[position] == null)
|
|
||||||
{
|
|
||||||
throw new ObjectNotFoundException(position);
|
|
||||||
}
|
|
||||||
return _collection[position];
|
|
||||||
}
|
|
||||||
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
|
|
||||||
{
|
|
||||||
if (comparer != null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < MaxCount; ++i)
|
|
||||||
{
|
|
||||||
if ((comparer as IEqualityComparer<DrawningTruck>).Equals(obj as DrawningTruck, _collection[i] as DrawningTruck))
|
|
||||||
{
|
|
||||||
throw new ObjectsEqualException(i);
|
|
||||||
}
|
|
||||||
if (_collection[i] == null)
|
|
||||||
{
|
|
||||||
_collection[i] = obj;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new CollectionOverflowException(Count);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
|
|
||||||
{
|
|
||||||
if (position < 0 || position >= MaxCount)
|
|
||||||
{
|
|
||||||
throw new PositionOutOfCollectionException(Count);
|
|
||||||
}
|
|
||||||
if (comparer != null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < position; i++)
|
|
||||||
{
|
|
||||||
if (_collection[i] != null)
|
|
||||||
{
|
|
||||||
if ((comparer as IEqualityComparer<DrawningTruck>).Equals(obj as DrawningTruck, _collection[i] as DrawningTruck))
|
|
||||||
{
|
|
||||||
throw new ObjectsEqualException(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_collection[position] == null)
|
|
||||||
{
|
|
||||||
_collection[position] = obj;
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
for (int i = position + 1; i < _collection.Length; ++i)
|
|
||||||
{
|
|
||||||
if (_collection[i] == null)
|
|
||||||
{
|
|
||||||
_collection[i] = obj;
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < position; ++i)
|
|
||||||
{
|
|
||||||
if (_collection[i] == null)
|
|
||||||
{
|
|
||||||
_collection[i] = obj;
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new CollectionOverflowException(Count);
|
|
||||||
}
|
|
||||||
public T Remove(int position)
|
|
||||||
{
|
|
||||||
if (position < 0 || position >= MaxCount)
|
|
||||||
{
|
|
||||||
throw new PositionOutOfCollectionException(position);
|
|
||||||
}
|
|
||||||
if (_collection[position] == null)
|
|
||||||
{
|
|
||||||
throw new ObjectNotFoundException(position);
|
|
||||||
}
|
|
||||||
T remove = _collection[position];
|
|
||||||
_collection[position]= null;
|
|
||||||
return remove;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<T?> GetItems()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _collection.Length; ++i)
|
|
||||||
{
|
|
||||||
yield return _collection[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CollectionSort(IComparer<T?> comparer)
|
|
||||||
{
|
|
||||||
Array.Sort(_collection, comparer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,233 +0,0 @@
|
|||||||
using ProjectDumpTruck.Drawnings;
|
|
||||||
using ProjectDumpTruck.Exceptions;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.CollectionGenericObjects;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-хранилище коллекций
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
public class StorageCollection<T>
|
|
||||||
where T : DrawningTruck
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Словарь (хранилище) с коллекциями
|
|
||||||
/// </summary>
|
|
||||||
readonly Dictionary<CollectionInfo, ICollectionGenericObjects<T>> _storages;
|
|
||||||
/// <summary>
|
|
||||||
/// Возвращение списка названий коллекций
|
|
||||||
/// </summary>
|
|
||||||
public List<CollectionInfo> Keys => _storages.Keys.ToList();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ключевое слово, с которого должен начинаться файл
|
|
||||||
/// </summary>
|
|
||||||
private readonly string _collectionKey = "CollectionsStorage";
|
|
||||||
/// <summary>
|
|
||||||
/// Разделитель для записи ключа и значения элемента словаря
|
|
||||||
/// </summary>
|
|
||||||
private readonly string _separatorForKeyValue = "|";
|
|
||||||
/// <summary>
|
|
||||||
/// Разделитель для записей коллекции данных в файл
|
|
||||||
/// </summary>
|
|
||||||
private readonly string _separatorItems = ";";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
public StorageCollection()
|
|
||||||
{
|
|
||||||
_storages = new Dictionary<CollectionInfo, ICollectionGenericObjects<T>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление коллекции в хранилище
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Название коллекции</param>
|
|
||||||
/// <param name="collectionType">тип коллекции</param>
|
|
||||||
public void AddCollection(string name, CollectionType collectionType)
|
|
||||||
{
|
|
||||||
CollectionInfo info = new CollectionInfo(name, collectionType, string.Empty);
|
|
||||||
if (_storages.ContainsKey(info))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (collectionType)
|
|
||||||
{
|
|
||||||
case CollectionType.None:
|
|
||||||
return;
|
|
||||||
case CollectionType.Massive:
|
|
||||||
_storages.Add(info, new MassiveGenericObjects<T>());
|
|
||||||
break;
|
|
||||||
case CollectionType.List:
|
|
||||||
_storages.Add(info, new ListGenericObjects<T>());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление коллекции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Название коллекции</param>
|
|
||||||
public void DelCollection(string name)
|
|
||||||
{
|
|
||||||
CollectionInfo info = new CollectionInfo(name, CollectionType.None, string.Empty);
|
|
||||||
if (_storages.ContainsKey(info))
|
|
||||||
{
|
|
||||||
_storages.Remove(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Доступ к коллекции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Название коллекции</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public ICollectionGenericObjects<T>? this[string name]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
CollectionInfo info = new CollectionInfo(name, CollectionType.None, string.Empty);
|
|
||||||
if (_storages.ContainsKey(info))
|
|
||||||
{
|
|
||||||
return _storages[info];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сохранение информации по грузовикам в хранилище в файл
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename">Путь и имя файла</param>
|
|
||||||
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
|
||||||
public void SaveData(string filename)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (_storages.Count == 0)
|
|
||||||
{
|
|
||||||
throw new Exception("В хранилище отсутствуют коллекции для сохранения");
|
|
||||||
|
|
||||||
}
|
|
||||||
if (File.Exists(filename))
|
|
||||||
{
|
|
||||||
File.Delete(filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
using StreamWriter wr = new StreamWriter(filename);
|
|
||||||
|
|
||||||
wr.Write(_collectionKey);
|
|
||||||
|
|
||||||
foreach (KeyValuePair<CollectionInfo, ICollectionGenericObjects<T>> value in _storages)
|
|
||||||
{
|
|
||||||
wr.Write(Environment.NewLine);
|
|
||||||
if (value.Value.Count == 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
wr.Write(value.Key.ToString());
|
|
||||||
wr.Write(_separatorForKeyValue);
|
|
||||||
wr.Write(value.Value.MaxCount);
|
|
||||||
wr.Write(_separatorForKeyValue);
|
|
||||||
foreach (T? item in value.Value.GetItems())
|
|
||||||
{
|
|
||||||
string data = item?.GetDataForSave() ?? string.Empty;
|
|
||||||
if (string.IsNullOrEmpty(data))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
wr.Write(data);
|
|
||||||
wr.Write(_separatorItems);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Загрузка информации по автомобилям в хранилище из файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename">Путь и имя файла</param>
|
|
||||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
|
||||||
public void LoadData(string filename)
|
|
||||||
{
|
|
||||||
if (!File.Exists(filename))
|
|
||||||
{
|
|
||||||
throw new Exception("Файл не существует");
|
|
||||||
}
|
|
||||||
using StreamReader rd = new StreamReader(filename);
|
|
||||||
|
|
||||||
|
|
||||||
UTF8Encoding temp = new(true);
|
|
||||||
string str = rd.ReadLine();
|
|
||||||
|
|
||||||
if (str == null)
|
|
||||||
{
|
|
||||||
throw new Exception("В файле нет данных");
|
|
||||||
}
|
|
||||||
if (!str.StartsWith(_collectionKey))
|
|
||||||
{
|
|
||||||
throw new Exception("В файле неверные данные");
|
|
||||||
}
|
|
||||||
|
|
||||||
_storages.Clear();
|
|
||||||
string strs = "";
|
|
||||||
while ((strs = rd.ReadLine()) != null)
|
|
||||||
{
|
|
||||||
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
if (record.Length != 3)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
CollectionInfo? col_info = CollectionInfo.GetCollectionInfo(record[0]) ??
|
|
||||||
throw new Exception("Не удалось определить информацию коллекции: " + record[0]); ;
|
|
||||||
|
|
||||||
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(col_info.CollectionType) ??
|
|
||||||
throw new Exception("Не удалось создать коллекцию");
|
|
||||||
if (collection == null)
|
|
||||||
{
|
|
||||||
throw new Exception("Не удалось создать коллекции");
|
|
||||||
}
|
|
||||||
collection.MaxCount = Convert.ToInt32(record[1]);
|
|
||||||
string[] set = record[2].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
foreach (string elem in set)
|
|
||||||
{
|
|
||||||
if (elem?.CreateDrawningTruck() is T truck)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (collection.Insert(truck) < 0)
|
|
||||||
{
|
|
||||||
throw new Exception("Объект не удалось добавить в коллекцию: " + record[3]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (CollectionOverflowException ex)
|
|
||||||
{
|
|
||||||
throw new Exception("Коллекция переполнена", ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_storages.Add(col_info, collection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание коллекции по типу
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="collectionType"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static ICollectionGenericObjects<T>?
|
|
||||||
CreateCollection(CollectionType collectionType)
|
|
||||||
{
|
|
||||||
return collectionType switch
|
|
||||||
{
|
|
||||||
CollectionType.Massive => new MassiveGenericObjects<T>(),
|
|
||||||
CollectionType.List => new ListGenericObjects<T>(),
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
using ProjectDumpTruck.Drawnings;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.CollectionGenericObjects;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Реализация абстрактной компании - тракшеринг
|
|
||||||
/// </summary>
|
|
||||||
public class TruckSharingService : AbstractCompany
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="picWidth"></param>
|
|
||||||
/// <param name="picHeight"></param>
|
|
||||||
/// <param name="collection"></param>
|
|
||||||
public TruckSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningTruck> collection) : base(picWidth, picHeight, collection)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private int start_width = 10, start_height = 20;
|
|
||||||
private int width_between = 60;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вывод заднего фона
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
protected override void DrawBackgound(Graphics g)
|
|
||||||
{
|
|
||||||
Pen pen = new(Color.Black, 5);
|
|
||||||
int height = 5, width = 5;
|
|
||||||
|
|
||||||
int maxWidth = _pictureWidth / (_placeSizeWidth + width_between);
|
|
||||||
int maxHeight = _pictureHeight / _placeSizeHeight;
|
|
||||||
|
|
||||||
for (int i = 0; i < maxWidth; i++)
|
|
||||||
{
|
|
||||||
height = 10;
|
|
||||||
for (int j = 0; j < maxHeight; j++)
|
|
||||||
{
|
|
||||||
g.DrawLine(pen, width, height, width + _placeSizeWidth, height);
|
|
||||||
g.DrawLine(pen, width, height, width, height + _placeSizeHeight);
|
|
||||||
height += _placeSizeHeight;
|
|
||||||
}
|
|
||||||
g.DrawLine(pen, width, height, width + _placeSizeWidth, height);
|
|
||||||
width = width + _placeSizeWidth + width_between;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Расстановка объектов
|
|
||||||
/// </summary>
|
|
||||||
protected override void SetObjectsPosition()
|
|
||||||
{
|
|
||||||
int maxWidth = _pictureWidth / (_placeSizeWidth + width_between);
|
|
||||||
int maxHeight = _pictureHeight / _placeSizeHeight;
|
|
||||||
int i_collection = 0;
|
|
||||||
int x_pos = start_width, y_pos = start_height;
|
|
||||||
|
|
||||||
|
|
||||||
if (_collection != null) {
|
|
||||||
for (int j = 0; j < maxHeight; j++)
|
|
||||||
{
|
|
||||||
x_pos = start_width;
|
|
||||||
for (int i = 0; i < maxWidth; i++)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_collection.Get(i_collection) != null)
|
|
||||||
{
|
|
||||||
_collection.Get(i_collection).SetPictureSize(_pictureWidth, _pictureHeight);
|
|
||||||
_collection.Get(i_collection).SetPosition(x_pos, y_pos);
|
|
||||||
x_pos += _placeSizeWidth + width_between;
|
|
||||||
i_collection++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception) { }
|
|
||||||
}
|
|
||||||
y_pos = y_pos + _placeSizeHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.Drawnings;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Напривление перемещения
|
|
||||||
/// </summary>
|
|
||||||
public enum DirectionType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Неизвестное направление
|
|
||||||
/// </summary>
|
|
||||||
Unknow = -1,
|
|
||||||
/// <summary>
|
|
||||||
/// Вверх
|
|
||||||
/// </summary>
|
|
||||||
Up = 1,
|
|
||||||
/// <summary>
|
|
||||||
/// Вниз
|
|
||||||
/// </summary>
|
|
||||||
Down = 2,
|
|
||||||
/// <summary>
|
|
||||||
/// Влево
|
|
||||||
/// </summary>
|
|
||||||
Left = 3,
|
|
||||||
/// <summary>
|
|
||||||
/// Вправо
|
|
||||||
/// </summary>
|
|
||||||
Right = 4,
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
using ProjectDumpTruck.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.Drawnings;
|
|
||||||
|
|
||||||
public class DrawiningTruckEqutables : IEqualityComparer<DrawningTruck?>
|
|
||||||
{
|
|
||||||
public bool Equals(DrawningTruck? x, DrawningTruck? y)
|
|
||||||
{
|
|
||||||
if (x == null || x.EntityTruck == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (y == null || y.EntityTruck == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (x.GetType().Name != y.GetType().Name)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (x.EntityTruck.Speed != y.EntityTruck.Speed)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (x.EntityTruck.Weight != y.EntityTruck.Weight)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (x.EntityTruck.BodyColor != y.EntityTruck.BodyColor)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (x is DrawningDumpTruck && y is DrawningDumpTruck)
|
|
||||||
{
|
|
||||||
EntityDumpTruck dump_truck_x = (EntityDumpTruck)x.EntityTruck;
|
|
||||||
EntityDumpTruck dump_truck_y = (EntityDumpTruck)y.EntityTruck;
|
|
||||||
if (dump_truck_x.Body != dump_truck_y.Body)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (dump_truck_x.Tent != dump_truck_y.Tent)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (dump_truck_x.AdditionalColor != dump_truck_y.AdditionalColor)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetHashCode([DisallowNull] DrawningTruck? obj)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ProjectDumpTruck.Entities;
|
|
||||||
using static System.Net.Mime.MediaTypeNames;
|
|
||||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.Drawnings;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс, отвечающий за прорисовку и перемещение
|
|
||||||
/// </summary>
|
|
||||||
public class DrawningDumpTruck : DrawningTruck
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// </summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
|
||||||
/// <param name="body">Признак наличия кузова</param>
|
|
||||||
/// <param name="tent">Признак наличия тента</param>
|
|
||||||
public DrawningDumpTruck(int speed, double weight, Color bodyColor, Color additionalColor, bool body, bool tent) : base(110, 100)
|
|
||||||
{
|
|
||||||
EntityTruck = new EntityDumpTruck(speed, weight, bodyColor, additionalColor, body, tent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DrawningDumpTruck(EntityDumpTruck dumpTruck) : base(110, 100)
|
|
||||||
{
|
|
||||||
EntityTruck = new EntityDumpTruck(dumpTruck.Speed, dumpTruck.Weight, dumpTruck.BodyColor,
|
|
||||||
dumpTruck.AdditionalColor, dumpTruck.Body, dumpTruck.Tent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (EntityTruck == null || EntityTruck is not EntityDumpTruck entityTruck || !_startPosX.HasValue || !_startPosY.HasValue)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_startPosX += 10;
|
|
||||||
base.DrawTransport(g);
|
|
||||||
_startPosX -= 10;
|
|
||||||
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
Brush additionalBrush = new SolidBrush(entityTruck.AdditionalColor);
|
|
||||||
|
|
||||||
Brush brBody = new SolidBrush(entityTruck.AdditionalColor);
|
|
||||||
|
|
||||||
if (entityTruck.Body)
|
|
||||||
{
|
|
||||||
Point[] body =
|
|
||||||
{
|
|
||||||
new Point (_startPosX.Value, _startPosY.Value + 15),
|
|
||||||
new Point (_startPosX.Value + 77, _startPosY.Value + 15),
|
|
||||||
new Point (_startPosX.Value + 77, _startPosY.Value + 50),
|
|
||||||
new Point (_startPosX.Value + 20, _startPosY.Value + 50)
|
|
||||||
};
|
|
||||||
g.DrawPolygon(pen, points: body);
|
|
||||||
|
|
||||||
g.FillPolygon(brBody, body);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entityTruck.Tent && entityTruck.Body)
|
|
||||||
{
|
|
||||||
Point[] tent =
|
|
||||||
{
|
|
||||||
new Point (_startPosX.Value, _startPosY.Value + 13),
|
|
||||||
new Point (_startPosX.Value + 39, _startPosY.Value),
|
|
||||||
new Point (_startPosX.Value + 77, _startPosY.Value + 13)
|
|
||||||
};
|
|
||||||
g.DrawPolygon(pen, points: tent);
|
|
||||||
|
|
||||||
g.FillPolygon(brBody, tent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,253 +0,0 @@
|
|||||||
using ProjectDumpTruck.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.Drawnings;
|
|
||||||
|
|
||||||
public class DrawningTruck
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-сущность
|
|
||||||
/// </summary>
|
|
||||||
public EntityTruck? EntityTruck { get; protected set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина окна
|
|
||||||
/// </summary>
|
|
||||||
private int? _pictureWidth;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота окна
|
|
||||||
/// </summary>
|
|
||||||
private int? _pictureHeight;
|
|
||||||
/// <summary>
|
|
||||||
/// Левая координата прорисовки автомобиля
|
|
||||||
/// </summary>
|
|
||||||
protected private int? _startPosX;
|
|
||||||
/// <summary>
|
|
||||||
/// Верхняя кооридната прорисовки автомобиля
|
|
||||||
/// </summary>
|
|
||||||
protected private int? _startPosY;
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина прорисовки самосвала
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _drawningTruckWidth = 100;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота прорисовки самосвала
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _drawningTruckHeight = 92;
|
|
||||||
/// <summary>
|
|
||||||
/// Координата Х объекта
|
|
||||||
/// </summary>
|
|
||||||
public int? GetPosX => _startPosX;
|
|
||||||
/// <summary>
|
|
||||||
/// Координата У объекта
|
|
||||||
/// </summary>
|
|
||||||
public int? GetPosY => _startPosY;
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetWidth => _drawningTruckWidth;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetHeight => _drawningTruckHeight;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Пустой конструктор
|
|
||||||
/// </summary>
|
|
||||||
private DrawningTruck()
|
|
||||||
{
|
|
||||||
_pictureWidth = null;
|
|
||||||
_pictureHeight = null;
|
|
||||||
_startPosX = null;
|
|
||||||
_startPosY = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// </summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
public DrawningTruck(int speed, double weight, Color bodyColor) : this()
|
|
||||||
{
|
|
||||||
EntityTruck = new EntityTruck(speed, weight, bodyColor);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public DrawningTruck(EntityTruck truck) : this()
|
|
||||||
{
|
|
||||||
EntityTruck = new EntityTruck(truck.Speed, truck.Weight, truck.BodyColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// </summary>
|
|
||||||
/// Конструктор для наследников
|
|
||||||
/// <param name="drawningTruckWidth">Ширина прорисовки самосвала</param>
|
|
||||||
/// <param name="drawningTruckHeight">Высота прорисовки самосвала</param>
|
|
||||||
protected DrawningTruck(int drawningTruckWidth, int drawningTruckHeight) : this()
|
|
||||||
{
|
|
||||||
_drawningTruckWidth = drawningTruckWidth;
|
|
||||||
_drawningTruckHeight = drawningTruckHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Установка границ поля
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="width">Ширина поля</param>
|
|
||||||
/// <param name="height">Высота поля</param>
|
|
||||||
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
|
|
||||||
public bool SetPictureSize(int width, int height)
|
|
||||||
{
|
|
||||||
if (_drawningTruckWidth > width || _drawningTruckHeight > height)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_pictureWidth.HasValue && width != _pictureWidth || _pictureHeight.HasValue && height != _pictureHeight)
|
|
||||||
{
|
|
||||||
if (_startPosX + _drawningTruckWidth > width)
|
|
||||||
{
|
|
||||||
_startPosX -= _drawningTruckWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_startPosY + _drawningTruckHeight > height)
|
|
||||||
{
|
|
||||||
_startPosY -= _drawningTruckHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Установка позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x">Координата X</param>
|
|
||||||
/// <param name="y">Координата Y</param>
|
|
||||||
public void SetPosition(int x, int y)
|
|
||||||
{
|
|
||||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x < 0)
|
|
||||||
{
|
|
||||||
x = 0;
|
|
||||||
}
|
|
||||||
if (x + _drawningTruckWidth > _pictureWidth)
|
|
||||||
{
|
|
||||||
x = (int)_pictureWidth - _drawningTruckWidth;
|
|
||||||
}
|
|
||||||
if (y < 0)
|
|
||||||
{
|
|
||||||
y = 0;
|
|
||||||
}
|
|
||||||
if (y + _drawningTruckHeight > _pictureHeight)
|
|
||||||
{
|
|
||||||
y = (int)_pictureHeight - _drawningTruckHeight;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
|
|
||||||
// то надо изменить координаты, чтобы он оставался в этих границах
|
|
||||||
_startPosX = x;
|
|
||||||
_startPosY = y;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Изменение направления перемещения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
/// <returns>true - перемещене выполнено, false - перемещение невозможно</returns>
|
|
||||||
public bool MoveTransport(DirectionType direction)
|
|
||||||
{
|
|
||||||
if (EntityTruck == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (direction)
|
|
||||||
{
|
|
||||||
//влево
|
|
||||||
case DirectionType.Left:
|
|
||||||
if (_startPosX.Value - EntityTruck.Step > 0)
|
|
||||||
{
|
|
||||||
_startPosX -= (int)EntityTruck.Step;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
//вверх
|
|
||||||
case DirectionType.Up:
|
|
||||||
if (_startPosY.Value - EntityTruck.Step > 0)
|
|
||||||
{
|
|
||||||
_startPosY -= (int)EntityTruck.Step;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
// вправо
|
|
||||||
case DirectionType.Right:
|
|
||||||
if (_startPosX.Value + _drawningTruckWidth < _pictureWidth)
|
|
||||||
{
|
|
||||||
_startPosX += (int)EntityTruck.Step;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
//вниз
|
|
||||||
case DirectionType.Down:
|
|
||||||
if (_startPosY.Value + _drawningTruckHeight < _pictureHeight)
|
|
||||||
{
|
|
||||||
_startPosY += (int)EntityTruck.Step;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Прорисовка объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
public virtual void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (EntityTruck == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
|
|
||||||
|
|
||||||
//Границы самосвала
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 53, 100, 13);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 70, _startPosY.Value + 15, 30, 36);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + 20, 20, 20);
|
|
||||||
|
|
||||||
// Колеса
|
|
||||||
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 67, 25, 25);
|
|
||||||
g.DrawEllipse(pen, _startPosX.Value + 28, _startPosY.Value + 67, 25, 25);
|
|
||||||
g.DrawEllipse(pen, _startPosX.Value + 73, _startPosY.Value + 67, 25, 25);
|
|
||||||
|
|
||||||
// Кузов
|
|
||||||
Brush br = new SolidBrush(EntityTruck.BodyColor);
|
|
||||||
g.FillRectangle(br, _startPosX.Value, _startPosY.Value + 53, 100, 13);
|
|
||||||
g.FillRectangle(br, _startPosX.Value + 70, _startPosY.Value + 15, 30, 36);
|
|
||||||
|
|
||||||
|
|
||||||
// Колеса
|
|
||||||
Brush brBlack = new SolidBrush(Color.Black);
|
|
||||||
g.FillEllipse(brBlack, _startPosX.Value, _startPosY.Value + 67, 25, 25);
|
|
||||||
g.FillEllipse(brBlack, _startPosX.Value + 28, _startPosY.Value + 67, 25, 25);
|
|
||||||
g.FillEllipse(brBlack, _startPosX.Value + 73, _startPosY.Value + 67, 25, 25);
|
|
||||||
|
|
||||||
//Окно
|
|
||||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
|
||||||
g.FillRectangle(brBlue, _startPosX.Value + 75, _startPosY.Value + 20, 20, 20);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.Drawnings;
|
|
||||||
|
|
||||||
public class DrawningTruckCompareByColor : IComparer<DrawningTruck?>
|
|
||||||
{
|
|
||||||
public int Compare(DrawningTruck? x, DrawningTruck? y)
|
|
||||||
{
|
|
||||||
if (x == null || x.EntityTruck == null)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y == null || y.EntityTruck == null)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
var bodycolorCompare = x.EntityTruck.BodyColor.Name.CompareTo(y.EntityTruck.BodyColor.Name);
|
|
||||||
if (bodycolorCompare != 0)
|
|
||||||
{
|
|
||||||
return bodycolorCompare;
|
|
||||||
}
|
|
||||||
var speedCompare = x.EntityTruck.Speed.CompareTo(y.EntityTruck.Speed);
|
|
||||||
if (speedCompare != 0)
|
|
||||||
{
|
|
||||||
return speedCompare;
|
|
||||||
}
|
|
||||||
return x.EntityTruck.Weight.CompareTo(y.EntityTruck.Weight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.Drawnings;
|
|
||||||
|
|
||||||
public class DrawningTruckCompareByType : IComparer<DrawningTruck?>
|
|
||||||
{
|
|
||||||
public int Compare(DrawningTruck? x, DrawningTruck? y)
|
|
||||||
{
|
|
||||||
if (x == null || x.EntityTruck == null)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (y == null || y.EntityTruck == null)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (x.GetType().Name != y.GetType().Name)
|
|
||||||
{
|
|
||||||
return x.GetType().Name.CompareTo(y.GetType().Name);
|
|
||||||
}
|
|
||||||
var speedCompare = x.EntityTruck.Speed.CompareTo(y.EntityTruck.Speed);
|
|
||||||
if (speedCompare != 0)
|
|
||||||
{
|
|
||||||
return speedCompare;
|
|
||||||
}
|
|
||||||
return x.EntityTruck.Weight.CompareTo(y.EntityTruck.Weight);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
using ProjectDumpTruck.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.Drawnings;
|
|
||||||
|
|
||||||
public static class ExtentionDrawningTruck
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Разделитель для записи информации по объекту в файл
|
|
||||||
/// </summary>
|
|
||||||
private static readonly string _separatorForObject = ":";
|
|
||||||
/// <summary>
|
|
||||||
/// Создание объекта из строки
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info">Строка с данными для создания объекта</param>
|
|
||||||
/// <returns>Объект</returns>
|
|
||||||
public static DrawningTruck? CreateDrawningTruck(this string info)
|
|
||||||
{
|
|
||||||
string[] strs = info.Split(_separatorForObject);
|
|
||||||
EntityTruck? truck = EntityDumpTruck.CreateEntityDumpTruck(strs);
|
|
||||||
if (truck != null)
|
|
||||||
{
|
|
||||||
return new DrawningDumpTruck((EntityDumpTruck)truck);
|
|
||||||
}
|
|
||||||
truck = EntityTruck.CreateEntityTruck(strs);
|
|
||||||
if (truck != null)
|
|
||||||
{
|
|
||||||
return new DrawningTruck(truck);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Получение данных для сохранения в файл
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="drawningTruck">Сохраняемый объект</param>
|
|
||||||
/// <returns>Строка с данными по объекту</returns>
|
|
||||||
public static string GetDataForSave(this DrawningTruck drawningTruck)
|
|
||||||
{
|
|
||||||
string[]? array = drawningTruck?.EntityTruck?.GetStringRepresentation();
|
|
||||||
if (array == null)
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
return string.Join(_separatorForObject, array);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.Entities;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-сущность Самосвала
|
|
||||||
/// </summary>
|
|
||||||
public class EntityDumpTruck : EntityTruck
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Дополнительный цвет (для опциональных элементов)
|
|
||||||
/// </summary>
|
|
||||||
public Color AdditionalColor { get; private set; }
|
|
||||||
|
|
||||||
public void SetAdditionalColor(Color color) { AdditionalColor = color; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Наличие кузова
|
|
||||||
/// </summary>
|
|
||||||
public bool Body { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Наличие тента
|
|
||||||
/// </summary>
|
|
||||||
public bool Tent { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес самосвала</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
|
||||||
/// <param name="body">Признак наличия кузова</param>
|
|
||||||
/// <param name="tent">Признак наличия тента</param>
|
|
||||||
public EntityDumpTruck(int speed, double weight, Color bodyColor, Color additionalColor, bool body, bool tent) : base(speed, weight, bodyColor: bodyColor)
|
|
||||||
{
|
|
||||||
AdditionalColor = additionalColor;
|
|
||||||
Body = body;
|
|
||||||
Tent = tent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение строк со значениями свойств объекта класса-сущности
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public override string[] GetStringRepresentation()
|
|
||||||
{
|
|
||||||
return new[] { nameof(EntityDumpTruck), Speed.ToString(), Weight.ToString(), BodyColor.Name,
|
|
||||||
AdditionalColor.Name, Body.ToString(), Tent.ToString() };
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание объекта из массива строк
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="strs"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static EntityTruck? CreateEntityDumpTruck(string[] strs)
|
|
||||||
{
|
|
||||||
if (strs.Length != 7 || strs[0] != nameof(EntityDumpTruck))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new EntityDumpTruck(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]),
|
|
||||||
Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.Entities;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-сущность "Грузовик"
|
|
||||||
/// </summary>
|
|
||||||
public class EntityTruck
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Скорость
|
|
||||||
/// </summary>
|
|
||||||
public int Speed { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Вес
|
|
||||||
/// </summary>
|
|
||||||
public double Weight { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Основной цвет
|
|
||||||
/// </summary>
|
|
||||||
public Color BodyColor { get; private set; }
|
|
||||||
|
|
||||||
public void SetBodyColor(Color color) { BodyColor = color; }
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг перемещения самосвала
|
|
||||||
/// </summary>
|
|
||||||
public double Step => Speed * 100 / Weight;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор сущности
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес самосвала</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
|
|
||||||
public EntityTruck(int speed, double weight, Color bodyColor)
|
|
||||||
{
|
|
||||||
Speed = speed;
|
|
||||||
Weight = weight;
|
|
||||||
BodyColor = bodyColor;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение строк со значениями свойств объекта класса-сущности
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public virtual string[] GetStringRepresentation()
|
|
||||||
{
|
|
||||||
return new[] { nameof(EntityTruck), Speed.ToString(), Weight.ToString(), BodyColor.Name };
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Создание объекта из массива строк
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="strs"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static EntityTruck? CreateEntityTruck(string[] strs)
|
|
||||||
{
|
|
||||||
if (strs.Length != 4 || strs[0] != nameof(EntityTruck))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new EntityTruck(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.Exceptions;
|
|
||||||
/// <summary>
|
|
||||||
/// Класс, описывающий ошибку переполнения коллекции
|
|
||||||
/// </summary>
|
|
||||||
[Serializable]
|
|
||||||
public class CollectionOverflowException : ApplicationException
|
|
||||||
{
|
|
||||||
public CollectionOverflowException(int count) : base("В коллекции превышено допустимое количество: " + count) { }
|
|
||||||
public CollectionOverflowException() : base() { }
|
|
||||||
public CollectionOverflowException(string message) : base(message) { }
|
|
||||||
public CollectionOverflowException(string message, Exception exception) : base(message, exception) { }
|
|
||||||
protected CollectionOverflowException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
|
||||||
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.Exceptions;
|
|
||||||
|
|
||||||
public class ObjectNotFoundException : ApplicationException
|
|
||||||
{
|
|
||||||
public ObjectNotFoundException(int i) : base("Не найден объект по позиции " + i) { }
|
|
||||||
public ObjectNotFoundException() : base() { }
|
|
||||||
public ObjectNotFoundException(string message) : base(message) { }
|
|
||||||
public ObjectNotFoundException(string message, Exception exception) : base(message, exception) { }
|
|
||||||
protected ObjectNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.Exceptions;
|
|
||||||
|
|
||||||
public class ObjectsEqualException : ApplicationException
|
|
||||||
{
|
|
||||||
public ObjectsEqualException(int i) : base("В коллекции находится такой же элемент на позиции " + i) { }
|
|
||||||
public ObjectsEqualException() : base( "В коллекции находится такой же элемент") { }
|
|
||||||
public ObjectsEqualException(string message) : base(message) { }
|
|
||||||
public ObjectsEqualException(string message, Exception exception) : base(message, exception) { }
|
|
||||||
protected ObjectsEqualException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.Exceptions;
|
|
||||||
|
|
||||||
public class PositionOutOfCollectionException : ApplicationException
|
|
||||||
{
|
|
||||||
public PositionOutOfCollectionException(int i) : base("Выход за границы коллекции.Позиция " + i) { }
|
|
||||||
public PositionOutOfCollectionException() : base() { }
|
|
||||||
public PositionOutOfCollectionException(string message) : base(message) { }
|
|
||||||
public PositionOutOfCollectionException(string message, Exception exception) : base(message, exception) { }
|
|
||||||
protected PositionOutOfCollectionException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
|
||||||
|
|
||||||
}
|
|
@ -1,148 +0,0 @@
|
|||||||
namespace ProjectDumpTruck
|
|
||||||
{
|
|
||||||
partial class FormDumpTruck
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
pictureBoxDumpTruck = new PictureBox();
|
|
||||||
buttonLeft = new Button();
|
|
||||||
buttonUp = new Button();
|
|
||||||
buttonDown = new Button();
|
|
||||||
buttonRight = new Button();
|
|
||||||
comboBoxStrategy = new ComboBox();
|
|
||||||
buttonStrategyStep = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxDumpTruck).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// pictureBoxDumpTruck
|
|
||||||
//
|
|
||||||
pictureBoxDumpTruck.Dock = DockStyle.Fill;
|
|
||||||
pictureBoxDumpTruck.Location = new Point(0, 0);
|
|
||||||
pictureBoxDumpTruck.Name = "pictureBoxDumpTruck";
|
|
||||||
pictureBoxDumpTruck.Size = new Size(894, 545);
|
|
||||||
pictureBoxDumpTruck.TabIndex = 0;
|
|
||||||
pictureBoxDumpTruck.TabStop = false;
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonLeft.BackgroundImage = Properties.Resources.Left;
|
|
||||||
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonLeft.Location = new Point(761, 500);
|
|
||||||
buttonLeft.Name = "buttonLeft";
|
|
||||||
buttonLeft.Size = new Size(35, 35);
|
|
||||||
buttonLeft.TabIndex = 2;
|
|
||||||
buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
buttonLeft.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonUp.BackgroundImage = Properties.Resources.Up;
|
|
||||||
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonUp.Location = new Point(803, 460);
|
|
||||||
buttonUp.Name = "buttonUp";
|
|
||||||
buttonUp.Size = new Size(35, 35);
|
|
||||||
buttonUp.TabIndex = 3;
|
|
||||||
buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
buttonUp.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonDown.BackgroundImage = Properties.Resources.Down;
|
|
||||||
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonDown.Location = new Point(803, 500);
|
|
||||||
buttonDown.Name = "buttonDown";
|
|
||||||
buttonDown.Size = new Size(35, 35);
|
|
||||||
buttonDown.TabIndex = 4;
|
|
||||||
buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
buttonDown.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonRight.BackgroundImage = Properties.Resources.Right;
|
|
||||||
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonRight.Location = new Point(844, 500);
|
|
||||||
buttonRight.Name = "buttonRight";
|
|
||||||
buttonRight.Size = new Size(35, 35);
|
|
||||||
buttonRight.TabIndex = 5;
|
|
||||||
buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
buttonRight.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// comboBoxStrategy
|
|
||||||
//
|
|
||||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxStrategy.FormattingEnabled = true;
|
|
||||||
comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" });
|
|
||||||
comboBoxStrategy.Location = new Point(731, 12);
|
|
||||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
|
||||||
comboBoxStrategy.Size = new Size(151, 28);
|
|
||||||
comboBoxStrategy.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// buttonStrategyStep
|
|
||||||
//
|
|
||||||
buttonStrategyStep.Location = new Point(785, 46);
|
|
||||||
buttonStrategyStep.Name = "buttonStrategyStep";
|
|
||||||
buttonStrategyStep.Size = new Size(94, 29);
|
|
||||||
buttonStrategyStep.TabIndex = 8;
|
|
||||||
buttonStrategyStep.Text = "Шаг";
|
|
||||||
buttonStrategyStep.UseVisualStyleBackColor = true;
|
|
||||||
buttonStrategyStep.Click += ВuttonStrategyStep_Click;
|
|
||||||
//
|
|
||||||
// FormDumpTruck
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(894, 545);
|
|
||||||
Controls.Add(buttonStrategyStep);
|
|
||||||
Controls.Add(comboBoxStrategy);
|
|
||||||
Controls.Add(buttonRight);
|
|
||||||
Controls.Add(buttonDown);
|
|
||||||
Controls.Add(buttonUp);
|
|
||||||
Controls.Add(buttonLeft);
|
|
||||||
Controls.Add(pictureBoxDumpTruck);
|
|
||||||
Name = "FormDumpTruck";
|
|
||||||
Text = "Самосвал";
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxDumpTruck).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private PictureBox pictureBoxDumpTruck;
|
|
||||||
private Button buttonLeft;
|
|
||||||
private Button buttonUp;
|
|
||||||
private Button buttonDown;
|
|
||||||
private Button buttonRight;
|
|
||||||
private ComboBox comboBoxStrategy;
|
|
||||||
private Button buttonStrategyStep;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,141 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using ProjectDumpTruck.Drawnings;
|
|
||||||
using ProjectDumpTruck.MovementStrategy;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck;
|
|
||||||
|
|
||||||
public partial class FormDumpTruck : Form
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Поле
|
|
||||||
/// объект для прорисовки объекта
|
|
||||||
/// </summary>
|
|
||||||
private DrawningTruck? _drawningTruck;
|
|
||||||
/// <summary>
|
|
||||||
/// Стратегия перемещения
|
|
||||||
/// </summary>
|
|
||||||
private AbstractStrategy? _strategy;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение объекта
|
|
||||||
/// </summary>
|
|
||||||
public DrawningTruck SetTruck
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_drawningTruck = value;
|
|
||||||
_drawningTruck.SetPictureSize(pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height);
|
|
||||||
comboBoxStrategy.Enabled = true;
|
|
||||||
_strategy = null;
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор формы
|
|
||||||
/// </summary>
|
|
||||||
public FormDumpTruck()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_strategy = null;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Метод прорисовки машины
|
|
||||||
/// </summary>
|
|
||||||
private void Draw()
|
|
||||||
{
|
|
||||||
if (_drawningTruck == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bitmap bmp = new(pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_drawningTruck.DrawTransport(gr);
|
|
||||||
pictureBoxDumpTruck.Image = bmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение объекта по форме (нажатие кнопок навигации)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawningTruck == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
||||||
bool result = false;
|
|
||||||
switch (name)
|
|
||||||
{
|
|
||||||
case "buttonUp":
|
|
||||||
result =
|
|
||||||
_drawningTruck.MoveTransport(DirectionType.Up);
|
|
||||||
break;
|
|
||||||
case "buttonDown":
|
|
||||||
result =
|
|
||||||
_drawningTruck.MoveTransport(DirectionType.Down);
|
|
||||||
break;
|
|
||||||
case "buttonLeft":
|
|
||||||
result =
|
|
||||||
_drawningTruck.MoveTransport(DirectionType.Left);
|
|
||||||
break;
|
|
||||||
case "buttonRight":
|
|
||||||
result =
|
|
||||||
_drawningTruck.MoveTransport(DirectionType.Right);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ВuttonStrategyStep_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawningTruck == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxStrategy.Enabled)
|
|
||||||
{
|
|
||||||
_strategy = comboBoxStrategy.SelectedIndex switch
|
|
||||||
{
|
|
||||||
0 => new MoveToCenter(),
|
|
||||||
1 => new MoveToBorder(),
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
if (_strategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_strategy.SetData(new MoveableTruck(_drawningTruck), pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height);
|
|
||||||
}
|
|
||||||
if (_strategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
comboBoxStrategy.Enabled = false;
|
|
||||||
_strategy.MakeStep();
|
|
||||||
Draw();
|
|
||||||
if (_strategy.GetStatus() == StrategyStatus.Finish)
|
|
||||||
{
|
|
||||||
comboBoxStrategy.Enabled = true;
|
|
||||||
_strategy = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -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>
|
|
@ -1,370 +0,0 @@
|
|||||||
namespace ProjectDumpTruck
|
|
||||||
{
|
|
||||||
partial class FormTruckCollection
|
|
||||||
{
|
|
||||||
/// <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();
|
|
||||||
panelCompanyTools = new Panel();
|
|
||||||
buttonAddTruck = new Button();
|
|
||||||
buttonRefresh = new Button();
|
|
||||||
maskedTextBoxPosition = new MaskedTextBox();
|
|
||||||
buttonGoToChek = new Button();
|
|
||||||
buttonRemoveTruck = new Button();
|
|
||||||
buttonCreateCompany = new Button();
|
|
||||||
panelStorage = new Panel();
|
|
||||||
buttonCollectionDel = 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();
|
|
||||||
menuStrip = new MenuStrip();
|
|
||||||
файлToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
saveToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
loadToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
saveFileDialog = new SaveFileDialog();
|
|
||||||
openFileDialog = new OpenFileDialog();
|
|
||||||
buttonSortByColor = new Button();
|
|
||||||
buttonSortByType = new Button();
|
|
||||||
groupBoxTools.SuspendLayout();
|
|
||||||
panelCompanyTools.SuspendLayout();
|
|
||||||
panelStorage.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
|
||||||
menuStrip.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// groupBoxTools
|
|
||||||
//
|
|
||||||
groupBoxTools.Controls.Add(panelCompanyTools);
|
|
||||||
groupBoxTools.Controls.Add(buttonCreateCompany);
|
|
||||||
groupBoxTools.Controls.Add(panelStorage);
|
|
||||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
|
||||||
groupBoxTools.Dock = DockStyle.Right;
|
|
||||||
groupBoxTools.Location = new Point(832, 28);
|
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
|
||||||
groupBoxTools.Size = new Size(250, 925);
|
|
||||||
groupBoxTools.TabIndex = 0;
|
|
||||||
groupBoxTools.TabStop = false;
|
|
||||||
groupBoxTools.Text = "Инструменты";
|
|
||||||
//
|
|
||||||
// panelCompanyTools
|
|
||||||
//
|
|
||||||
panelCompanyTools.Controls.Add(buttonSortByColor);
|
|
||||||
panelCompanyTools.Controls.Add(buttonSortByType);
|
|
||||||
panelCompanyTools.Controls.Add(buttonAddTruck);
|
|
||||||
panelCompanyTools.Controls.Add(buttonRefresh);
|
|
||||||
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
|
|
||||||
panelCompanyTools.Controls.Add(buttonGoToChek);
|
|
||||||
panelCompanyTools.Controls.Add(buttonRemoveTruck);
|
|
||||||
panelCompanyTools.Dock = DockStyle.Bottom;
|
|
||||||
panelCompanyTools.Location = new Point(3, 479);
|
|
||||||
panelCompanyTools.Name = "panelCompanyTools";
|
|
||||||
panelCompanyTools.Size = new Size(244, 443);
|
|
||||||
panelCompanyTools.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// buttonAddTruck
|
|
||||||
//
|
|
||||||
buttonAddTruck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonAddTruck.Location = new Point(15, 13);
|
|
||||||
buttonAddTruck.Name = "buttonAddTruck";
|
|
||||||
buttonAddTruck.Size = new Size(220, 57);
|
|
||||||
buttonAddTruck.TabIndex = 1;
|
|
||||||
buttonAddTruck.Text = "Добавление грузовика";
|
|
||||||
buttonAddTruck.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddTruck.Click += ButtonAddTruck_Click;
|
|
||||||
//
|
|
||||||
// buttonRefresh
|
|
||||||
//
|
|
||||||
buttonRefresh.Location = new Point(15, 245);
|
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
|
||||||
buttonRefresh.Size = new Size(220, 57);
|
|
||||||
buttonRefresh.TabIndex = 7;
|
|
||||||
buttonRefresh.Text = "Обновить";
|
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
|
||||||
buttonRefresh.Click += ButtonRefresh_Click;
|
|
||||||
//
|
|
||||||
// maskedTextBoxPosition
|
|
||||||
//
|
|
||||||
maskedTextBoxPosition.Location = new Point(15, 85);
|
|
||||||
maskedTextBoxPosition.Mask = "00";
|
|
||||||
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
|
||||||
maskedTextBoxPosition.Size = new Size(223, 27);
|
|
||||||
maskedTextBoxPosition.TabIndex = 4;
|
|
||||||
maskedTextBoxPosition.ValidatingType = typeof(int);
|
|
||||||
//
|
|
||||||
// buttonGoToChek
|
|
||||||
//
|
|
||||||
buttonGoToChek.Location = new Point(15, 181);
|
|
||||||
buttonGoToChek.Name = "buttonGoToChek";
|
|
||||||
buttonGoToChek.Size = new Size(220, 57);
|
|
||||||
buttonGoToChek.TabIndex = 6;
|
|
||||||
buttonGoToChek.Text = "Передать на тесты";
|
|
||||||
buttonGoToChek.UseVisualStyleBackColor = true;
|
|
||||||
buttonGoToChek.Click += ButtonGoToChek_Click;
|
|
||||||
//
|
|
||||||
// buttonRemoveTruck
|
|
||||||
//
|
|
||||||
buttonRemoveTruck.Location = new Point(15, 118);
|
|
||||||
buttonRemoveTruck.Name = "buttonRemoveTruck";
|
|
||||||
buttonRemoveTruck.Size = new Size(220, 57);
|
|
||||||
buttonRemoveTruck.TabIndex = 5;
|
|
||||||
buttonRemoveTruck.Text = "Удаление грузовика";
|
|
||||||
buttonRemoveTruck.UseVisualStyleBackColor = true;
|
|
||||||
buttonRemoveTruck.Click += ButtonRemoveTruck_Click;
|
|
||||||
//
|
|
||||||
// buttonCreateCompany
|
|
||||||
//
|
|
||||||
buttonCreateCompany.Location = new Point(18, 410);
|
|
||||||
buttonCreateCompany.Name = "buttonCreateCompany";
|
|
||||||
buttonCreateCompany.Size = new Size(220, 29);
|
|
||||||
buttonCreateCompany.TabIndex = 9;
|
|
||||||
buttonCreateCompany.Text = "Создать компанию";
|
|
||||||
buttonCreateCompany.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateCompany.Click += ButtonCreateCompany_Click;
|
|
||||||
//
|
|
||||||
// panelStorage
|
|
||||||
//
|
|
||||||
panelStorage.Controls.Add(buttonCollectionDel);
|
|
||||||
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, 23);
|
|
||||||
panelStorage.Name = "panelStorage";
|
|
||||||
panelStorage.Size = new Size(244, 310);
|
|
||||||
panelStorage.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// buttonCollectionDel
|
|
||||||
//
|
|
||||||
buttonCollectionDel.Location = new Point(3, 265);
|
|
||||||
buttonCollectionDel.Name = "buttonCollectionDel";
|
|
||||||
buttonCollectionDel.Size = new Size(238, 29);
|
|
||||||
buttonCollectionDel.TabIndex = 6;
|
|
||||||
buttonCollectionDel.Text = "Удалить коллекцию";
|
|
||||||
buttonCollectionDel.UseVisualStyleBackColor = true;
|
|
||||||
buttonCollectionDel.Click += ButtonCollectionDel_Click;
|
|
||||||
//
|
|
||||||
// listBoxCollection
|
|
||||||
//
|
|
||||||
listBoxCollection.FormattingEnabled = true;
|
|
||||||
listBoxCollection.ItemHeight = 20;
|
|
||||||
listBoxCollection.Location = new Point(3, 135);
|
|
||||||
listBoxCollection.Name = "listBoxCollection";
|
|
||||||
listBoxCollection.Size = new Size(238, 124);
|
|
||||||
listBoxCollection.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// buttonCollectionAdd
|
|
||||||
//
|
|
||||||
buttonCollectionAdd.Location = new Point(3, 100);
|
|
||||||
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
|
||||||
buttonCollectionAdd.Size = new Size(238, 29);
|
|
||||||
buttonCollectionAdd.TabIndex = 4;
|
|
||||||
buttonCollectionAdd.Text = "Добавить коллекцию";
|
|
||||||
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
|
||||||
buttonCollectionAdd.Click += ButtonCollectionAdd_Click;
|
|
||||||
//
|
|
||||||
// radioButtonList
|
|
||||||
//
|
|
||||||
radioButtonList.AutoSize = true;
|
|
||||||
radioButtonList.Location = new Point(142, 70);
|
|
||||||
radioButtonList.Name = "radioButtonList";
|
|
||||||
radioButtonList.Size = new Size(80, 24);
|
|
||||||
radioButtonList.TabIndex = 3;
|
|
||||||
radioButtonList.TabStop = true;
|
|
||||||
radioButtonList.Text = "Список";
|
|
||||||
radioButtonList.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// radioButtonMassive
|
|
||||||
//
|
|
||||||
radioButtonMassive.AutoSize = true;
|
|
||||||
radioButtonMassive.Location = new Point(15, 70);
|
|
||||||
radioButtonMassive.Name = "radioButtonMassive";
|
|
||||||
radioButtonMassive.Size = new Size(82, 24);
|
|
||||||
radioButtonMassive.TabIndex = 2;
|
|
||||||
radioButtonMassive.TabStop = true;
|
|
||||||
radioButtonMassive.Text = "Массив";
|
|
||||||
radioButtonMassive.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// textBoxCollectionName
|
|
||||||
//
|
|
||||||
textBoxCollectionName.Location = new Point(3, 37);
|
|
||||||
textBoxCollectionName.Name = "textBoxCollectionName";
|
|
||||||
textBoxCollectionName.Size = new Size(238, 27);
|
|
||||||
textBoxCollectionName.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// labelCollectionName
|
|
||||||
//
|
|
||||||
labelCollectionName.AutoSize = true;
|
|
||||||
labelCollectionName.Location = new Point(38, 14);
|
|
||||||
labelCollectionName.Name = "labelCollectionName";
|
|
||||||
labelCollectionName.Size = new Size(155, 20);
|
|
||||||
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(18, 361);
|
|
||||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
|
||||||
comboBoxSelectorCompany.Size = new Size(220, 28);
|
|
||||||
comboBoxSelectorCompany.TabIndex = 0;
|
|
||||||
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
|
|
||||||
//
|
|
||||||
// pictureBox
|
|
||||||
//
|
|
||||||
pictureBox.Dock = DockStyle.Fill;
|
|
||||||
pictureBox.Location = new Point(0, 28);
|
|
||||||
pictureBox.Name = "pictureBox";
|
|
||||||
pictureBox.Size = new Size(832, 925);
|
|
||||||
pictureBox.TabIndex = 3;
|
|
||||||
pictureBox.TabStop = false;
|
|
||||||
//
|
|
||||||
// menuStrip
|
|
||||||
//
|
|
||||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
|
||||||
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
|
||||||
menuStrip.Location = new Point(0, 0);
|
|
||||||
menuStrip.Name = "menuStrip";
|
|
||||||
menuStrip.Size = new Size(1082, 28);
|
|
||||||
menuStrip.TabIndex = 4;
|
|
||||||
menuStrip.Text = "menuStrip1";
|
|
||||||
//
|
|
||||||
// файлToolStripMenuItem
|
|
||||||
//
|
|
||||||
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
|
|
||||||
файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
|
||||||
файлToolStripMenuItem.Size = new Size(59, 24);
|
|
||||||
файлToolStripMenuItem.Text = "Файл";
|
|
||||||
//
|
|
||||||
// saveToolStripMenuItem
|
|
||||||
//
|
|
||||||
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
|
||||||
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
|
||||||
saveToolStripMenuItem.Size = new Size(227, 26);
|
|
||||||
saveToolStripMenuItem.Text = "Сохранение";
|
|
||||||
saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// loadToolStripMenuItem
|
|
||||||
//
|
|
||||||
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
|
||||||
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
|
|
||||||
loadToolStripMenuItem.Size = new Size(227, 26);
|
|
||||||
loadToolStripMenuItem.Text = "Загрузка";
|
|
||||||
loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// saveFileDialog
|
|
||||||
//
|
|
||||||
saveFileDialog.Filter = "txt file | *.txt";
|
|
||||||
//
|
|
||||||
// openFileDialog
|
|
||||||
//
|
|
||||||
openFileDialog.FileName = "openFileDialog1";
|
|
||||||
openFileDialog.Filter = "txt file | *.txt";
|
|
||||||
//
|
|
||||||
// buttonSortByColor
|
|
||||||
//
|
|
||||||
buttonSortByColor.Location = new Point(15, 371);
|
|
||||||
buttonSortByColor.Name = "buttonSortByColor";
|
|
||||||
buttonSortByColor.Size = new Size(220, 57);
|
|
||||||
buttonSortByColor.TabIndex = 8;
|
|
||||||
buttonSortByColor.Text = "Сортировка по цвету";
|
|
||||||
buttonSortByColor.UseVisualStyleBackColor = true;
|
|
||||||
buttonSortByColor.Click += buttonSortByColor_Click;
|
|
||||||
//
|
|
||||||
// buttonSortByType
|
|
||||||
//
|
|
||||||
buttonSortByType.Location = new Point(15, 308);
|
|
||||||
buttonSortByType.Name = "buttonSortByType";
|
|
||||||
buttonSortByType.Size = new Size(220, 57);
|
|
||||||
buttonSortByType.TabIndex = 7;
|
|
||||||
buttonSortByType.Text = "Сортировка по типу";
|
|
||||||
buttonSortByType.UseVisualStyleBackColor = true;
|
|
||||||
buttonSortByType.Click += buttonSortByType_Click;
|
|
||||||
//
|
|
||||||
// FormTruckCollection
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(1082, 953);
|
|
||||||
Controls.Add(pictureBox);
|
|
||||||
Controls.Add(groupBoxTools);
|
|
||||||
Controls.Add(menuStrip);
|
|
||||||
MainMenuStrip = menuStrip;
|
|
||||||
Name = "FormTruckCollection";
|
|
||||||
Text = "Коллекция грузовиков";
|
|
||||||
groupBoxTools.ResumeLayout(false);
|
|
||||||
panelCompanyTools.ResumeLayout(false);
|
|
||||||
panelCompanyTools.PerformLayout();
|
|
||||||
panelStorage.ResumeLayout(false);
|
|
||||||
panelStorage.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
|
||||||
menuStrip.ResumeLayout(false);
|
|
||||||
menuStrip.PerformLayout();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private GroupBox groupBoxTools;
|
|
||||||
private Button buttonAddTruck;
|
|
||||||
private ComboBox comboBoxSelectorCompany;
|
|
||||||
private Button buttonRemoveTruck;
|
|
||||||
private MaskedTextBox maskedTextBoxPosition;
|
|
||||||
private PictureBox pictureBox;
|
|
||||||
private Button buttonRefresh;
|
|
||||||
private Button buttonGoToChek;
|
|
||||||
private Panel panelStorage;
|
|
||||||
private RadioButton radioButtonList;
|
|
||||||
private RadioButton radioButtonMassive;
|
|
||||||
private TextBox textBoxCollectionName;
|
|
||||||
private Label labelCollectionName;
|
|
||||||
private Button buttonCollectionAdd;
|
|
||||||
private Button buttonCreateCompany;
|
|
||||||
private Button buttonCollectionDel;
|
|
||||||
private ListBox listBoxCollection;
|
|
||||||
private Panel panelCompanyTools;
|
|
||||||
private MenuStrip menuStrip;
|
|
||||||
private ToolStripMenuItem файлToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem saveToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem loadToolStripMenuItem;
|
|
||||||
private SaveFileDialog saveFileDialog;
|
|
||||||
private OpenFileDialog openFileDialog;
|
|
||||||
private Button buttonSortByColor;
|
|
||||||
private Button buttonSortByType;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,334 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using ProjectDumpTruck.CollectionGenericObjects;
|
|
||||||
using ProjectDumpTruck.Drawnings;
|
|
||||||
using ProjectDumpTruck.Exceptions;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http.Headers;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck;
|
|
||||||
|
|
||||||
public partial class FormTruckCollection : Form
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Хранилише коллекций
|
|
||||||
/// </summary>
|
|
||||||
private readonly StorageCollection<DrawningTruck> _storageCollection;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Компания
|
|
||||||
/// </summary>
|
|
||||||
private AbstractCompany? _company = null;
|
|
||||||
/// <summary>
|
|
||||||
/// Логер
|
|
||||||
/// </summary>
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
|
|
||||||
public FormTruckCollection(ILogger<FormTruckCollection> logger)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_storageCollection = new();
|
|
||||||
_logger = logger;
|
|
||||||
_logger.LogInformation("Форма загрузилась");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Выбор компании
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
panelCompanyTools.Enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление грузовика
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonAddTruck_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
FormTruckConfig form = new();
|
|
||||||
form.AddEvent(SetTruck);
|
|
||||||
form.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление автомобиля в коллекцию
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="truck"></param>
|
|
||||||
private void SetTruck(DrawningTruck? truck)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_company == null || truck == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_company + truck >= 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
pictureBox.Image = _company.Show();
|
|
||||||
_logger.LogInformation("Объект добавлен");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ObjectNotFoundException) { }
|
|
||||||
catch (CollectionOverflowException ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Коллекция переполнена");
|
|
||||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
|
||||||
}
|
|
||||||
catch (ObjectsEqualException ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Такой объект уже существует в коллекции");
|
|
||||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonRemoveTruck_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
|
||||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_company - pos != null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект удален");
|
|
||||||
pictureBox.Image = _company.Show();
|
|
||||||
_logger.LogInformation("Объект удален");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
|
||||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Передача объекта в другую форму
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonGoToChek_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_company == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DrawningTruck? truck = null;
|
|
||||||
int counter = 100;
|
|
||||||
while (truck == null)
|
|
||||||
{
|
|
||||||
truck = _company.GetRandomObject();
|
|
||||||
counter--;
|
|
||||||
if (counter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (truck == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FormDumpTruck form = new()
|
|
||||||
{
|
|
||||||
SetTruck = truck
|
|
||||||
};
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перерисовка коллекции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonRefresh_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_company == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pictureBox.Image = _company.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление коллекции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></par
|
|
||||||
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);
|
|
||||||
_logger.LogInformation("Коллекция добавлена " + textBoxCollectionName.Text);
|
|
||||||
RerfreshListBoxItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Обновление списка в listBoxCollection
|
|
||||||
/// </summary>
|
|
||||||
private void RerfreshListBoxItems()
|
|
||||||
{
|
|
||||||
listBoxCollection.Items.Clear();
|
|
||||||
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
|
|
||||||
{
|
|
||||||
string? colName = _storageCollection.Keys?[i].Name;
|
|
||||||
if (!string.IsNullOrEmpty(colName))
|
|
||||||
{
|
|
||||||
listBoxCollection.Items.Add(colName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCollectionDel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItems == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Коллекция не выбрана");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
|
|
||||||
_logger.LogInformation("Коллекция с название: " + listBoxCollection.SelectedItem.ToString() + " удалена");
|
|
||||||
RerfreshListBoxItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание компании
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCreateCompany_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Коллекция не выбрана");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ICollectionGenericObjects<DrawningTruck>? collection =
|
|
||||||
_storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
|
|
||||||
if (collection == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Коллекция не проинициализирована");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (comboBoxSelectorCompany.Text)
|
|
||||||
{
|
|
||||||
case "Хранилище":
|
|
||||||
_company = new TruckSharingService(pictureBox.Width,
|
|
||||||
pictureBox.Height, collection);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
panelCompanyTools.Enabled = true;
|
|
||||||
RerfreshListBoxItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия "Сохранение"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_storageCollection.SaveData(saveFileDialog.FileName);
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
_logger.LogInformation("Сохранение в файл: {filename}", saveFileDialog.FileName);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_storageCollection.LoadData(openFileDialog.FileName);
|
|
||||||
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
RerfreshListBoxItems();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
_logger.LogError("Ошибка: {Message}", ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonSortByType_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CompareTrucks(new DrawningTruckCompareByType());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonSortByColor_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CompareTrucks(new DrawningTruckCompareByColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сортировка по сравнителю
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="comparer">Сравнитель объектов</param>
|
|
||||||
private void CompareTrucks(IComparer<DrawningTruck?> comparer)
|
|
||||||
{
|
|
||||||
if (_company == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_company.Sort(comparer);
|
|
||||||
pictureBox.Image = _company.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,132 +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>
|
|
||||||
<metadata name="buttonRefresh.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>145, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>310, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
@ -1,357 +0,0 @@
|
|||||||
namespace ProjectDumpTruck
|
|
||||||
{
|
|
||||||
partial class FormTruckConfig
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
groupBoxConfig = new GroupBox();
|
|
||||||
groupBoxColors = new GroupBox();
|
|
||||||
panelPurple = new Panel();
|
|
||||||
panelYellow = new Panel();
|
|
||||||
panelBlack = new Panel();
|
|
||||||
panelBlue = new Panel();
|
|
||||||
panelGray = new Panel();
|
|
||||||
panelWhite = new Panel();
|
|
||||||
panelGreen = new Panel();
|
|
||||||
panelRed = new Panel();
|
|
||||||
checkBoxTent = new CheckBox();
|
|
||||||
checkBoxBody = new CheckBox();
|
|
||||||
numericUpDownWeight = new NumericUpDown();
|
|
||||||
labelWeight = new Label();
|
|
||||||
numericUpDownSpeed = new NumericUpDown();
|
|
||||||
labelSpeed = new Label();
|
|
||||||
labelModifiedObject = new Label();
|
|
||||||
labelSimpleObject = new Label();
|
|
||||||
pictureBoxObject = new PictureBox();
|
|
||||||
buttonAdd = new Button();
|
|
||||||
panelObject = new Panel();
|
|
||||||
labelAdditionalColor = new Label();
|
|
||||||
labelBodyColor = new Label();
|
|
||||||
buttonCancel = new Button();
|
|
||||||
groupBoxConfig.SuspendLayout();
|
|
||||||
groupBoxColors.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
|
||||||
panelObject.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// groupBoxConfig
|
|
||||||
//
|
|
||||||
groupBoxConfig.Controls.Add(groupBoxColors);
|
|
||||||
groupBoxConfig.Controls.Add(checkBoxTent);
|
|
||||||
groupBoxConfig.Controls.Add(checkBoxBody);
|
|
||||||
groupBoxConfig.Controls.Add(numericUpDownWeight);
|
|
||||||
groupBoxConfig.Controls.Add(labelWeight);
|
|
||||||
groupBoxConfig.Controls.Add(numericUpDownSpeed);
|
|
||||||
groupBoxConfig.Controls.Add(labelSpeed);
|
|
||||||
groupBoxConfig.Controls.Add(labelModifiedObject);
|
|
||||||
groupBoxConfig.Controls.Add(labelSimpleObject);
|
|
||||||
groupBoxConfig.Dock = DockStyle.Left;
|
|
||||||
groupBoxConfig.Location = new Point(0, 0);
|
|
||||||
groupBoxConfig.Name = "groupBoxConfig";
|
|
||||||
groupBoxConfig.Size = new Size(615, 305);
|
|
||||||
groupBoxConfig.TabIndex = 0;
|
|
||||||
groupBoxConfig.TabStop = false;
|
|
||||||
groupBoxConfig.Text = "Параметры";
|
|
||||||
//
|
|
||||||
// groupBoxColors
|
|
||||||
//
|
|
||||||
groupBoxColors.Controls.Add(panelPurple);
|
|
||||||
groupBoxColors.Controls.Add(panelYellow);
|
|
||||||
groupBoxColors.Controls.Add(panelBlack);
|
|
||||||
groupBoxColors.Controls.Add(panelBlue);
|
|
||||||
groupBoxColors.Controls.Add(panelGray);
|
|
||||||
groupBoxColors.Controls.Add(panelWhite);
|
|
||||||
groupBoxColors.Controls.Add(panelGreen);
|
|
||||||
groupBoxColors.Controls.Add(panelRed);
|
|
||||||
groupBoxColors.Location = new Point(280, 23);
|
|
||||||
groupBoxColors.Name = "groupBoxColors";
|
|
||||||
groupBoxColors.Size = new Size(292, 167);
|
|
||||||
groupBoxColors.TabIndex = 1;
|
|
||||||
groupBoxColors.TabStop = false;
|
|
||||||
groupBoxColors.Text = "Цвета";
|
|
||||||
//
|
|
||||||
// panelPurple
|
|
||||||
//
|
|
||||||
panelPurple.BackColor = Color.Purple;
|
|
||||||
panelPurple.Location = new Point(219, 94);
|
|
||||||
panelPurple.Name = "panelPurple";
|
|
||||||
panelPurple.Size = new Size(45, 43);
|
|
||||||
panelPurple.TabIndex = 11;
|
|
||||||
//
|
|
||||||
// panelYellow
|
|
||||||
//
|
|
||||||
panelYellow.BackColor = Color.Yellow;
|
|
||||||
panelYellow.Location = new Point(219, 26);
|
|
||||||
panelYellow.Name = "panelYellow";
|
|
||||||
panelYellow.Size = new Size(45, 43);
|
|
||||||
panelYellow.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// panelBlack
|
|
||||||
//
|
|
||||||
panelBlack.BackColor = Color.Black;
|
|
||||||
panelBlack.Location = new Point(155, 94);
|
|
||||||
panelBlack.Name = "panelBlack";
|
|
||||||
panelBlack.Size = new Size(45, 43);
|
|
||||||
panelBlack.TabIndex = 12;
|
|
||||||
//
|
|
||||||
// panelBlue
|
|
||||||
//
|
|
||||||
panelBlue.BackColor = Color.Blue;
|
|
||||||
panelBlue.Location = new Point(155, 26);
|
|
||||||
panelBlue.Name = "panelBlue";
|
|
||||||
panelBlue.Size = new Size(45, 43);
|
|
||||||
panelBlue.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// panelGray
|
|
||||||
//
|
|
||||||
panelGray.BackColor = Color.Gray;
|
|
||||||
panelGray.Location = new Point(88, 94);
|
|
||||||
panelGray.Name = "panelGray";
|
|
||||||
panelGray.Size = new Size(45, 43);
|
|
||||||
panelGray.TabIndex = 13;
|
|
||||||
//
|
|
||||||
// panelWhite
|
|
||||||
//
|
|
||||||
panelWhite.BackColor = Color.White;
|
|
||||||
panelWhite.Location = new Point(17, 94);
|
|
||||||
panelWhite.Name = "panelWhite";
|
|
||||||
panelWhite.Size = new Size(45, 43);
|
|
||||||
panelWhite.TabIndex = 10;
|
|
||||||
//
|
|
||||||
// panelGreen
|
|
||||||
//
|
|
||||||
panelGreen.BackColor = Color.Green;
|
|
||||||
panelGreen.Location = new Point(88, 26);
|
|
||||||
panelGreen.Name = "panelGreen";
|
|
||||||
panelGreen.Size = new Size(45, 43);
|
|
||||||
panelGreen.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// panelRed
|
|
||||||
//
|
|
||||||
panelRed.BackColor = Color.Red;
|
|
||||||
panelRed.Location = new Point(17, 26);
|
|
||||||
panelRed.Name = "panelRed";
|
|
||||||
panelRed.Size = new Size(45, 43);
|
|
||||||
panelRed.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// checkBoxTent
|
|
||||||
//
|
|
||||||
checkBoxTent.AutoSize = true;
|
|
||||||
checkBoxTent.Location = new Point(12, 245);
|
|
||||||
checkBoxTent.Name = "checkBoxTent";
|
|
||||||
checkBoxTent.Size = new Size(195, 24);
|
|
||||||
checkBoxTent.TabIndex = 7;
|
|
||||||
checkBoxTent.Text = "Признак наличия тента";
|
|
||||||
checkBoxTent.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxBody
|
|
||||||
//
|
|
||||||
checkBoxBody.AutoSize = true;
|
|
||||||
checkBoxBody.Location = new Point(12, 206);
|
|
||||||
checkBoxBody.Name = "checkBoxBody";
|
|
||||||
checkBoxBody.Size = new Size(204, 24);
|
|
||||||
checkBoxBody.TabIndex = 6;
|
|
||||||
checkBoxBody.Text = "Признак наличия кузова";
|
|
||||||
checkBoxBody.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// numericUpDownWeight
|
|
||||||
//
|
|
||||||
numericUpDownWeight.Location = new Point(94, 69);
|
|
||||||
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
|
||||||
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
|
||||||
numericUpDownWeight.Name = "numericUpDownWeight";
|
|
||||||
numericUpDownWeight.Size = new Size(97, 27);
|
|
||||||
numericUpDownWeight.TabIndex = 5;
|
|
||||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
|
||||||
//
|
|
||||||
// labelWeight
|
|
||||||
//
|
|
||||||
labelWeight.AutoSize = true;
|
|
||||||
labelWeight.Location = new Point(12, 76);
|
|
||||||
labelWeight.Name = "labelWeight";
|
|
||||||
labelWeight.Size = new Size(36, 20);
|
|
||||||
labelWeight.TabIndex = 4;
|
|
||||||
labelWeight.Text = "Вес:";
|
|
||||||
//
|
|
||||||
// numericUpDownSpeed
|
|
||||||
//
|
|
||||||
numericUpDownSpeed.Location = new Point(94, 23);
|
|
||||||
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
|
||||||
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
|
||||||
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
|
||||||
numericUpDownSpeed.Size = new Size(97, 27);
|
|
||||||
numericUpDownSpeed.TabIndex = 3;
|
|
||||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
|
||||||
//
|
|
||||||
// labelSpeed
|
|
||||||
//
|
|
||||||
labelSpeed.AutoSize = true;
|
|
||||||
labelSpeed.Location = new Point(12, 23);
|
|
||||||
labelSpeed.Name = "labelSpeed";
|
|
||||||
labelSpeed.Size = new Size(76, 20);
|
|
||||||
labelSpeed.TabIndex = 2;
|
|
||||||
labelSpeed.Text = "Скорость:";
|
|
||||||
//
|
|
||||||
// labelModifiedObject
|
|
||||||
//
|
|
||||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelModifiedObject.Location = new Point(431, 226);
|
|
||||||
labelModifiedObject.Name = "labelModifiedObject";
|
|
||||||
labelModifiedObject.Size = new Size(141, 44);
|
|
||||||
labelModifiedObject.TabIndex = 1;
|
|
||||||
labelModifiedObject.Text = "Продвинутый";
|
|
||||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
|
||||||
//
|
|
||||||
// labelSimpleObject
|
|
||||||
//
|
|
||||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelSimpleObject.Location = new Point(275, 226);
|
|
||||||
labelSimpleObject.Name = "labelSimpleObject";
|
|
||||||
labelSimpleObject.Size = new Size(141, 44);
|
|
||||||
labelSimpleObject.TabIndex = 0;
|
|
||||||
labelSimpleObject.Text = "Простой";
|
|
||||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
|
||||||
//
|
|
||||||
// pictureBoxObject
|
|
||||||
//
|
|
||||||
pictureBoxObject.Location = new Point(26, 56);
|
|
||||||
pictureBoxObject.Name = "pictureBoxObject";
|
|
||||||
pictureBoxObject.Size = new Size(206, 124);
|
|
||||||
pictureBoxObject.TabIndex = 1;
|
|
||||||
pictureBoxObject.TabStop = false;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
buttonAdd.Location = new Point(621, 264);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
|
||||||
buttonAdd.Size = new Size(94, 29);
|
|
||||||
buttonAdd.TabIndex = 2;
|
|
||||||
buttonAdd.Text = "Добавить";
|
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
buttonAdd.Click += ButtonAdd_Click;
|
|
||||||
//
|
|
||||||
// panelObject
|
|
||||||
//
|
|
||||||
panelObject.AllowDrop = true;
|
|
||||||
panelObject.Controls.Add(labelAdditionalColor);
|
|
||||||
panelObject.Controls.Add(pictureBoxObject);
|
|
||||||
panelObject.Controls.Add(labelBodyColor);
|
|
||||||
panelObject.Location = new Point(621, 39);
|
|
||||||
panelObject.Name = "panelObject";
|
|
||||||
panelObject.Size = new Size(260, 217);
|
|
||||||
panelObject.TabIndex = 4;
|
|
||||||
panelObject.DragDrop += PanelObject_DragDrop;
|
|
||||||
panelObject.DragEnter += PanelObject_DragEnter;
|
|
||||||
//
|
|
||||||
// labelAdditionalColor
|
|
||||||
//
|
|
||||||
labelAdditionalColor.AllowDrop = true;
|
|
||||||
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelAdditionalColor.Location = new Point(132, 10);
|
|
||||||
labelAdditionalColor.Name = "labelAdditionalColor";
|
|
||||||
labelAdditionalColor.Size = new Size(101, 32);
|
|
||||||
labelAdditionalColor.TabIndex = 9;
|
|
||||||
labelAdditionalColor.Text = "Доп. цвет";
|
|
||||||
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelAdditionalColor.DragDrop += LabelAdditionalColor_DragDrop;
|
|
||||||
labelAdditionalColor.DragEnter += LabelAdditionalColor_DragEnter;
|
|
||||||
//
|
|
||||||
// labelBodyColor
|
|
||||||
//
|
|
||||||
labelBodyColor.AllowDrop = true;
|
|
||||||
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelBodyColor.Location = new Point(26, 10);
|
|
||||||
labelBodyColor.Name = "labelBodyColor";
|
|
||||||
labelBodyColor.Size = new Size(100, 32);
|
|
||||||
labelBodyColor.TabIndex = 8;
|
|
||||||
labelBodyColor.Text = "Цвет";
|
|
||||||
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelBodyColor.DragDrop += LabelBodyColor_DragDrop;
|
|
||||||
labelBodyColor.DragEnter += LabelBodyColor_DragEnter;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
buttonCancel.Location = new Point(787, 264);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(94, 29);
|
|
||||||
buttonCancel.TabIndex = 5;
|
|
||||||
buttonCancel.Text = "Отмена";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// FormTruckConfig
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(908, 305);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(panelObject);
|
|
||||||
Controls.Add(buttonAdd);
|
|
||||||
Controls.Add(groupBoxConfig);
|
|
||||||
Name = "FormTruckConfig";
|
|
||||||
Text = "Создание объекта";
|
|
||||||
groupBoxConfig.ResumeLayout(false);
|
|
||||||
groupBoxConfig.PerformLayout();
|
|
||||||
groupBoxColors.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
|
||||||
panelObject.ResumeLayout(false);
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private GroupBox groupBoxConfig;
|
|
||||||
private Label labelSimpleObject;
|
|
||||||
private Label labelSpeed;
|
|
||||||
private Label labelModifiedObject;
|
|
||||||
private Label labelWeight;
|
|
||||||
private NumericUpDown numericUpDownSpeed;
|
|
||||||
private NumericUpDown numericUpDownWeight;
|
|
||||||
private CheckBox checkBoxBody;
|
|
||||||
private CheckBox checkBoxTent;
|
|
||||||
private GroupBox groupBoxColors;
|
|
||||||
private Panel panelRed;
|
|
||||||
private Panel panelYellow;
|
|
||||||
private Panel panelBlue;
|
|
||||||
private Panel panelGreen;
|
|
||||||
private Panel panelPurple;
|
|
||||||
private Panel panelBlack;
|
|
||||||
private Panel panelGray;
|
|
||||||
private Panel panelWhite;
|
|
||||||
private PictureBox pictureBoxObject;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private Panel panelObject;
|
|
||||||
private Label labelBodyColor;
|
|
||||||
private Label labelAdditionalColor;
|
|
||||||
private Button buttonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,169 +0,0 @@
|
|||||||
using ProjectDumpTruck.Drawnings;
|
|
||||||
using ProjectDumpTruck.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Форма конфигурации самосвала
|
|
||||||
/// </summary>
|
|
||||||
public partial class FormTruckConfig : Form
|
|
||||||
{
|
|
||||||
private event Action<DrawningTruck> DrawningTruckEvent;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Объект - прорисовка грузовика
|
|
||||||
/// </summary>
|
|
||||||
private DrawningTruck _truck;
|
|
||||||
|
|
||||||
public FormTruckConfig()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
|
|
||||||
panelRed.MouseDown += Panel_MouseDown;
|
|
||||||
panelGreen.MouseDown += Panel_MouseDown;
|
|
||||||
panelBlue.MouseDown += Panel_MouseDown;
|
|
||||||
panelYellow.MouseDown += Panel_MouseDown;
|
|
||||||
panelWhite.MouseDown += Panel_MouseDown;
|
|
||||||
panelBlack.MouseDown += Panel_MouseDown;
|
|
||||||
panelPurple.MouseDown += Panel_MouseDown;
|
|
||||||
panelGray.MouseDown += Panel_MouseDown;
|
|
||||||
|
|
||||||
buttonCancel.Click += (object sender, EventArgs e) => Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Привязка внешнего метода к событию
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="truckDelegate"></param>
|
|
||||||
public void AddEvent(Action<DrawningTruck> truckDelegate)
|
|
||||||
{
|
|
||||||
DrawningTruckEvent += truckDelegate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Прорисовка объекта
|
|
||||||
/// </summary>
|
|
||||||
private void DrawObject()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_truck?.SetPictureSize(pictureBoxObject.Width,
|
|
||||||
pictureBoxObject.Height);
|
|
||||||
_truck?.SetPosition(15, 15);
|
|
||||||
_truck?.DrawTransport(gr);
|
|
||||||
pictureBoxObject.Image = bmp;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Передаем информацию при нажатии на Label
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></paramlabelSimpleObject>
|
|
||||||
private void LabelObject_MouseDown(object sender, MouseEventArgs elabelSimpleObject)
|
|
||||||
{
|
|
||||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name ??
|
|
||||||
string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ?
|
|
||||||
DragDropEffects.Copy : DragDropEffects.None;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Действия при приеме перетаскиваемой информации
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
|
|
||||||
{
|
|
||||||
case "labelSimpleObject":
|
|
||||||
_truck = new DrawningTruck((int)numericUpDownSpeed.Value,
|
|
||||||
(double)numericUpDownWeight.Value, Color.White);
|
|
||||||
break;
|
|
||||||
case "labelModifiedObject":
|
|
||||||
_truck = new
|
|
||||||
DrawningDumpTruck((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value,
|
|
||||||
Color.White,
|
|
||||||
Color.Black, checkBoxBody.Checked,
|
|
||||||
checkBoxTent.Checked);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
DrawObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void Panel_MouseDown(object? sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
(sender as Control).DoDragDrop((sender as Control).BackColor,
|
|
||||||
DragDropEffects.Move | DragDropEffects.Copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelBodyColor_DragEnter(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Data.GetDataPresent(typeof(Color)))
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.Copy;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelBodyColor_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
_truck?.EntityTruck.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
|
||||||
|
|
||||||
DrawObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (_truck is DrawningDumpTruck)
|
|
||||||
{
|
|
||||||
if (e.Data.GetDataPresent(typeof(Color)))
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.Copy;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (_truck.EntityTruck is EntityDumpTruck _dumpTruck)
|
|
||||||
{
|
|
||||||
_dumpTruck.SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
|
||||||
}
|
|
||||||
DrawObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_truck != null)
|
|
||||||
{
|
|
||||||
DrawningTruckEvent?.Invoke(_truck);
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
@ -1,125 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.MovementStrategy;
|
|
||||||
|
|
||||||
public abstract class AbstractStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещаемый объект
|
|
||||||
/// </summary>
|
|
||||||
private IMoveableObject? _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>
|
|
||||||
public StrategyStatus GetStatus() { return _state; }
|
|
||||||
/// <summary>
|
|
||||||
/// Установка данных
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="moveableObject">Перемещаемый объект</param>
|
|
||||||
/// <param name="width">Ширина поля</param>
|
|
||||||
/// <param name="height">Высота поля</param>
|
|
||||||
public void SetData(IMoveableObject moveableObject, int width, int height)
|
|
||||||
{
|
|
||||||
if (moveableObject == null)
|
|
||||||
{
|
|
||||||
_state = StrategyStatus.NotInit;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_state = StrategyStatus.InProgress;
|
|
||||||
_moveableObject = moveableObject;
|
|
||||||
FieldWidth = width;
|
|
||||||
FieldHeight = height;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг перемещения
|
|
||||||
/// </summary>
|
|
||||||
public void MakeStep()
|
|
||||||
{
|
|
||||||
if (_state != StrategyStatus.InProgress)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (IsTargetDestinaion())
|
|
||||||
{
|
|
||||||
_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 IsTargetDestinaion();
|
|
||||||
/// <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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.MovementStrategy;
|
|
||||||
|
|
||||||
public interface IMoveableObject
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Получение координаты объекта
|
|
||||||
/// </summary>
|
|
||||||
ObjectParameters? GetObjectPosition { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг объекта
|
|
||||||
/// </summary>
|
|
||||||
int GetStep { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Попытка переместить объект в указанном направлении
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
/// <returns>true - объект перемещен, false - перемещение невозможно</returns>
|
|
||||||
bool TryMoveObject(MovementDirection direction);
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.MovementStrategy;
|
|
||||||
|
|
||||||
public class MoveToBorder : AbstractStrategy
|
|
||||||
{
|
|
||||||
protected override bool IsTargetDestinaion()
|
|
||||||
{
|
|
||||||
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 = FieldWidth - objParams.RightBorder;
|
|
||||||
if (Math.Abs(diffX) > GetStep())
|
|
||||||
{
|
|
||||||
MoveRight();
|
|
||||||
}
|
|
||||||
|
|
||||||
int diffY = FieldHeight - objParams.DownBorder;
|
|
||||||
if (Math.Abs(diffY) > GetStep())
|
|
||||||
{
|
|
||||||
MoveDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.MovementStrategy;
|
|
||||||
|
|
||||||
public class MoveToCenter : AbstractStrategy
|
|
||||||
{
|
|
||||||
protected override bool IsTargetDestinaion()
|
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
using ProjectDumpTruck.Drawnings;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ProjectDumpTruck.MovementStrategy;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.MovementStrategy;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-реализация IMoveableObject с использованием DrawningCar
|
|
||||||
/// </summary>
|
|
||||||
public class MoveableTruck : IMoveableObject
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Поле-объект класса DrawningCar или его наследника
|
|
||||||
/// </summary>
|
|
||||||
private readonly DrawningTruck? _truck = null;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="truck">Объект класса DrawningCar</param>
|
|
||||||
public MoveableTruck(DrawningTruck truck)
|
|
||||||
{
|
|
||||||
_truck = truck;
|
|
||||||
}
|
|
||||||
public ObjectParameters? GetObjectPosition
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_truck == null || _truck.EntityTruck == null ||
|
|
||||||
!_truck.GetPosX.HasValue || !_truck.GetPosY.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new ObjectParameters(_truck.GetPosX.Value, _truck.GetPosY.Value, _truck.GetWidth, _truck.GetHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetStep => (int)(_truck?.EntityTruck?.Step ?? 0);
|
|
||||||
public bool TryMoveObject(MovementDirection direction)
|
|
||||||
{
|
|
||||||
if (_truck == null || _truck.EntityTruck == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return _truck.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,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.MovementStrategy;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Направление перемещения
|
|
||||||
/// </summary>
|
|
||||||
public enum MovementDirection
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Вверх
|
|
||||||
/// </summary>
|
|
||||||
Up = 1,
|
|
||||||
/// <summary>
|
|
||||||
/// Вниз
|
|
||||||
/// </summary>
|
|
||||||
Down = 2,
|
|
||||||
/// <summary>
|
|
||||||
/// Влево
|
|
||||||
/// </summary>
|
|
||||||
Left = 3,
|
|
||||||
/// <summary>
|
|
||||||
/// Вправо
|
|
||||||
/// </summary>
|
|
||||||
Right = 4
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.MovementStrategy;
|
|
||||||
|
|
||||||
public class ObjectParameters
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Координата X
|
|
||||||
/// </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 TopBorder => _y;
|
|
||||||
/// <summary>
|
|
||||||
/// Правая граница
|
|
||||||
/// </summary>
|
|
||||||
public int RightBorder => _x + _width;
|
|
||||||
/// <summary>
|
|
||||||
/// Нижняя граница
|
|
||||||
/// </summary>
|
|
||||||
public int DownBorder => _y + _height;
|
|
||||||
/// <summary>
|
|
||||||
/// Середина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
|
||||||
/// <summary>
|
|
||||||
/// Середина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int ObjectMiddleVertical => _y + _height / 2;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x">Координата X</param>
|
|
||||||
/// <param name="y">Координата Y</param>
|
|
||||||
/// <param name="width">Ширина объекта</param>
|
|
||||||
/// <param name="height">Высота объекта</param>
|
|
||||||
public ObjectParameters(int x, int y, int width, int height)
|
|
||||||
{
|
|
||||||
_x = x;
|
|
||||||
_y = y;
|
|
||||||
_width = width;
|
|
||||||
_height = height;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.MovementStrategy;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Статус выполнения операции перемещения
|
|
||||||
/// </summary>
|
|
||||||
public enum StrategyStatus
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Все готово к началу
|
|
||||||
/// </summary>
|
|
||||||
NotInit,
|
|
||||||
/// <summary>
|
|
||||||
/// Выполняется
|
|
||||||
/// </summary>
|
|
||||||
InProgress,
|
|
||||||
/// <summary>
|
|
||||||
/// Завершено
|
|
||||||
/// </summary>
|
|
||||||
Finish
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
using Serilog;
|
|
||||||
|
|
||||||
using Serilog.Extensions.Logging;
|
|
||||||
using Serilog.Settings.Configuration;
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck
|
|
||||||
{
|
|
||||||
internal static class Program
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The main entry point for the application.
|
|
||||||
/// </summary>
|
|
||||||
[STAThread]
|
|
||||||
static void Main()
|
|
||||||
{
|
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
|
||||||
// see https://aka.ms/applicationconfiguration.
|
|
||||||
ServiceCollection services = new();
|
|
||||||
ConfigureServices(services);
|
|
||||||
ApplicationConfiguration.Initialize();
|
|
||||||
using ServiceProvider serviceProvider = services.BuildServiceProvider();
|
|
||||||
Application.Run(serviceProvider.GetRequiredService<FormTruckCollection>());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Êîíôèãóðàöèÿ ñåðâèñà DI
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="services"></param>
|
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddSingleton<FormTruckCollection>()
|
|
||||||
.AddLogging(option =>
|
|
||||||
{
|
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
|
||||||
option.AddSerilog(new LoggerConfiguration()
|
|
||||||
.WriteTo.File("log.txt")
|
|
||||||
.CreateLogger());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>WinExe</OutputType>
|
|
||||||
<TargetFramework>net7.0-windows</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
|
||||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
|
||||||
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
|
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
|
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
|
||||||
</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>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="nlog.config">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,103 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// Этот код создан программой.
|
|
||||||
// Исполняемая версия:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
|
||||||
// повторной генерации кода.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace ProjectDumpTruck.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("ProjectDumpTruck.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
|
||||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap Down {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("Down", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap Left {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("Left", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap Right {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("Right", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap Up {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("Up", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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="Left" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="Up" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="Down" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="Right" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
Binary file not shown.
Before Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 9.2 KiB |
@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<configuration>
|
|
||||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
autoReload="true" internalLogLevel="Info">
|
|
||||||
<targets>
|
|
||||||
<target xsi:type="File" name="tofile" fileName="carlog- ${shortdate}.log" />
|
|
||||||
</targets>
|
|
||||||
<rules>
|
|
||||||
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
|
||||||
</rules>
|
|
||||||
</nlog>
|
|
||||||
</configuration>
|
|
Loading…
Reference in New Issue
Block a user