Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ddc93735f8 | ||
|
0022f3d3b7 | ||
|
dd1829520c | ||
|
948640a1ea | ||
|
4947aac3ca | ||
|
85e47206a8 | ||
|
e5262ac123 | ||
|
adc31a5780 | ||
|
b26c69667b | ||
|
58deca3522 | ||
|
083d88469d | ||
|
59fc016821 |
@ -1,9 +1,9 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34622.214
|
||||
VisualStudioVersion = 17.8.34330.188
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Projectc", "Projectc\Projectc.csproj", "{9D9C70C9-8CF4-47AD-80A1-24FD6C137D95}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectStormtrooper", "ProjectStormtrooper\ProjectStormtrooper.csproj", "{B3757440-93E9-45FA-9CD7-729B997A5CCF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -11,15 +11,15 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9D9C70C9-8CF4-47AD-80A1-24FD6C137D95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9D9C70C9-8CF4-47AD-80A1-24FD6C137D95}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9D9C70C9-8CF4-47AD-80A1-24FD6C137D95}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9D9C70C9-8CF4-47AD-80A1-24FD6C137D95}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B3757440-93E9-45FA-9CD7-729B997A5CCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B3757440-93E9-45FA-9CD7-729B997A5CCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B3757440-93E9-45FA-9CD7-729B997A5CCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B3757440-93E9-45FA-9CD7-729B997A5CCF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {67E4C089-495F-462B-9EF3-04B590A2108E}
|
||||
SolutionGuid = {78BFA3C9-3BCC-4037-9217-9197133D11B5}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
10
ProjectStormtrooper/AirplaneDelegate.cs
Normal file
10
ProjectStormtrooper/AirplaneDelegate.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using ProjectStormtrooper.Drawnings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectStormtrooper;
|
||||
|
||||
public delegate void AirplaneDelegate(DrawningAirplane airplane);
|
116
ProjectStormtrooper/CollectionGenericObjects/AbstractCompany.cs
Normal file
116
ProjectStormtrooper/CollectionGenericObjects/AbstractCompany.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using ProjectStormtrooper.Drawnings;
|
||||
|
||||
namespace ProjectStormtrooper.CollectionGenericObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Абстракция компании, хранящий коллекцию автомобилей
|
||||
/// </summary>
|
||||
public abstract class AbstractCompany
|
||||
{
|
||||
/// <summary>
|
||||
/// Размер места (ширина)
|
||||
/// </summary>
|
||||
protected readonly int _placeSizeWidth = 210;
|
||||
|
||||
/// <summary>
|
||||
/// Размер места (высота)
|
||||
/// </summary>
|
||||
protected readonly int _placeSizeHeight = 120;
|
||||
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
protected readonly int _pictureWidth;
|
||||
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
protected readonly int _pictureHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Коллекция самолетов
|
||||
/// </summary>
|
||||
protected ICollectionGenericObjects<DrawningAirplane>? _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<DrawningAirplane> collection)
|
||||
{
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_collection = collection;
|
||||
_collection.SetMaxCount = GetMaxCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перегрузка оператора сложения для класса
|
||||
/// </summary>
|
||||
/// <param name="company">Компания</param>
|
||||
/// <param name="car">Добавляемый объект</param>
|
||||
/// <returns></returns>
|
||||
public static int operator +(AbstractCompany company, DrawningAirplane airplane)
|
||||
{
|
||||
return company._collection.Insert(airplane);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перегрузка оператора удаления для класса
|
||||
/// </summary>
|
||||
/// <param name="company">Компания</param>
|
||||
/// <param name="position">Номер удаляемого объекта</param>
|
||||
/// <returns></returns>
|
||||
public static DrawningAirplane operator -(AbstractCompany company, int position)
|
||||
{
|
||||
return company._collection?.Remove(position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение случайного объекта из коллекции
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DrawningAirplane? 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)
|
||||
{
|
||||
DrawningAirplane? obj = _collection?.Get(i);
|
||||
obj?.DrawTransport(graphics);
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Вывод заднего фона
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
protected abstract void DrawBackgound(Graphics g);
|
||||
|
||||
/// <summary>
|
||||
/// Расстановка объектов
|
||||
/// </summary>
|
||||
protected abstract void SetObjectsPosition();
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
using ProjectStormtrooper.Drawnings;
|
||||
using System.Drawing;
|
||||
|
||||
namespace ProjectStormtrooper.CollectionGenericObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Реализация абстрактной компании - каршеринг
|
||||
/// </summary>
|
||||
public class AirplaneSharingService : AbstractCompany
|
||||
{
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="picWidth"></param>
|
||||
/// <param name="picHeight"></param>
|
||||
/// <param name="collection"></param>
|
||||
public AirplaneSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningAirplane> collection) : base(picWidth, picHeight, collection)
|
||||
{
|
||||
}
|
||||
protected override void DrawBackgound(Graphics g)
|
||||
{
|
||||
//рисуем пристань
|
||||
int width = _pictureWidth / _placeSizeWidth;
|
||||
int height = _pictureHeight / _placeSizeHeight;
|
||||
Pen pen = new(Color.Black, 3);
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height + 1; ++j)
|
||||
{
|
||||
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth - 5, j * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetObjectsPosition()
|
||||
{
|
||||
int width = _pictureWidth / _placeSizeWidth;
|
||||
int height = _pictureHeight / _placeSizeHeight;
|
||||
|
||||
int curWidth = width - 1;
|
||||
int curHeight = 0;
|
||||
|
||||
for (int i = 0; i < (_collection?.Count ?? 0); i++)
|
||||
{
|
||||
if (_collection.Get(i) != null)
|
||||
{
|
||||
_collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
|
||||
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 20, curHeight * _placeSizeHeight + 4);
|
||||
}
|
||||
if (curWidth > 0)
|
||||
curWidth--;
|
||||
else
|
||||
{
|
||||
curWidth = width - 1;
|
||||
curHeight++;
|
||||
}
|
||||
if (curHeight > height)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
namespace ProjectStormtrooper.CollectionGenericObjects;
|
||||
public enum CollectionType
|
||||
{
|
||||
/// <summary>
|
||||
/// Неопределено
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Массив
|
||||
/// </summary>
|
||||
Massive = 1,
|
||||
/// <summary>
|
||||
/// Список
|
||||
/// </summary>
|
||||
List = 2
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
namespace ProjectStormtrooper.CollectionGenericObjects;
|
||||
|
||||
public interface ICollectionGenericObjects<T>
|
||||
where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Количество объектов в коллекции
|
||||
/// </summary>
|
||||
int Count { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Установка максимального количества элементов
|
||||
/// </summary>
|
||||
int SetMaxCount { set; }
|
||||
|
||||
/// <summary>
|
||||
/// Добавление объекта в коллекцию
|
||||
/// </summary>
|
||||
/// <param name="obj">Добавляемый объект</param>
|
||||
/// <returns>Код результата вставки</returns>
|
||||
int Insert(T obj);
|
||||
|
||||
/// <summary>
|
||||
/// Добавление объекта в коллекцию на конкретную позицию
|
||||
/// </summary>
|
||||
/// <param name="obj">Добавляемый объект</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns>Код результата вставки</returns>
|
||||
int Insert(T obj, int position);
|
||||
|
||||
/// <summary>
|
||||
/// Удаление объекта из коллекции с конкретной позиции
|
||||
/// </summary>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns>Код результата удаления</returns>
|
||||
T Remove(int position);
|
||||
|
||||
/// <summary>
|
||||
/// Получение объекта по позиции
|
||||
/// </summary>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns>Объект</returns>
|
||||
T? Get(int position);
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
namespace ProjectStormtrooper.CollectionGenericObjects;
|
||||
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 SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public ListGenericObjects()
|
||||
{
|
||||
_collection = new();
|
||||
}
|
||||
public T? Get(int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
if (position >= Count || position < 0) return null;
|
||||
return _collection[position];
|
||||
}
|
||||
public int Insert(T obj)
|
||||
{
|
||||
// TODO проверка, что не превышено максимальное количество элементов
|
||||
// TODO вставка в конец набора
|
||||
if (Count == _maxCount) return -1;
|
||||
_collection.Add(obj);
|
||||
return Count;
|
||||
}
|
||||
public int Insert(T obj, int position)
|
||||
{
|
||||
// TODO проверка, что не превышено максимальное количество элементов
|
||||
// TODO проверка позиции
|
||||
// TODO вставка по позиции
|
||||
if (Count == _maxCount) return -1;
|
||||
if (position >= Count || position < 0) return -1;
|
||||
_collection.Insert(position, obj);
|
||||
return position;
|
||||
}
|
||||
public T Remove(int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
// TODO удаление объекта из списка
|
||||
if (position >= Count || position < 0) return null;
|
||||
T obj = _collection[position];
|
||||
_collection.RemoveAt(position);
|
||||
return obj;
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
using ProjectStormtrooper.CollectionGenericObjects;
|
||||
|
||||
namespace ProjectStormtrooper.CollectionGenericObjects;
|
||||
|
||||
public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Массив объектов, которые храним
|
||||
/// </summary>
|
||||
private T?[] _collection;
|
||||
public int Count => _collection.Length;
|
||||
public int SetMaxCount
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value > 0)
|
||||
{
|
||||
if (_collection.Length > 0)
|
||||
{
|
||||
Array.Resize(ref _collection, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_collection = new T?[value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public MassiveGenericObjects()
|
||||
{
|
||||
_collection = Array.Empty<T?>();
|
||||
}
|
||||
|
||||
public T? Get(int position) // получение с позиции
|
||||
{
|
||||
// TODO проверка позиции
|
||||
if (position >= _collection.Length || position < 0)
|
||||
return null;
|
||||
return _collection[position];
|
||||
}
|
||||
public int Insert(T obj)
|
||||
{
|
||||
// TODO вставка в свободное место набора
|
||||
int index = 0;
|
||||
while (index < _collection.Length)
|
||||
{
|
||||
if (_collection[index] == null)
|
||||
{
|
||||
_collection[index] = obj;
|
||||
return index;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public int Insert(T obj, int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
|
||||
// ищется свободное место после этой позиции и идет вставка туда
|
||||
// если нет после, ищем до
|
||||
// TODO вставка
|
||||
if (position >= _collection.Length || position < 0)
|
||||
return -1;
|
||||
if (_collection[position] == null)
|
||||
{
|
||||
_collection[position] = obj;
|
||||
return position;
|
||||
}
|
||||
int index = position + 1;
|
||||
while (index < _collection.Length)
|
||||
{
|
||||
if (_collection[index] == null)
|
||||
{
|
||||
_collection[index] = obj;
|
||||
return index;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
index = position - 1;
|
||||
while (index >= 0)
|
||||
{
|
||||
if (_collection[index] == null)
|
||||
{
|
||||
_collection[index] = obj;
|
||||
return index;
|
||||
}
|
||||
--index;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public T Remove(int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
// TODO удаление объекта из массива, присвоив элементу массива значение null
|
||||
if (position >= _collection.Length || position < 0)
|
||||
return null;
|
||||
T obj = _collection[position];
|
||||
_collection[position] = null;
|
||||
return obj;
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
using ProjectStormtrooper.Drawnings;
|
||||
|
||||
namespace ProjectStormtrooper.CollectionGenericObjects;
|
||||
|
||||
public class StorageCollection<T>
|
||||
where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Словарь (хранилище) с коллекциями
|
||||
/// </summary>
|
||||
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
|
||||
/// <summary>
|
||||
/// Возвращение списка названий коллекций
|
||||
/// </summary>
|
||||
public List<string> Keys => _storages.Keys.ToList();
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public StorageCollection()
|
||||
{
|
||||
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление коллекции в хранилище
|
||||
/// </summary>
|
||||
/// <param name="name">Название коллекции</param>
|
||||
/// <param name="collectionType">тип коллекции</param>
|
||||
public void AddCollection(string name, CollectionType collectionType)
|
||||
{
|
||||
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
|
||||
// TODO Прописать логику для добавления
|
||||
if (_storages.ContainsKey(name)) return;
|
||||
if (collectionType == CollectionType.None) return;
|
||||
else if (collectionType == CollectionType.Massive)
|
||||
_storages[name] = new MassiveGenericObjects<T>();
|
||||
else if (collectionType == CollectionType.List)
|
||||
_storages[name] = new ListGenericObjects<T>();
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление коллекции
|
||||
/// </summary>
|
||||
/// <param name="name">Название коллекции</param>
|
||||
public void DelCollection(string name)
|
||||
{
|
||||
|
||||
// TODO Прописать логику для удаления коллекции
|
||||
if (_storages.ContainsKey(name))
|
||||
_storages.Remove(name);
|
||||
}
|
||||
/// <summary>
|
||||
/// Доступ к коллекции
|
||||
/// </summary>
|
||||
/// <param name="name">Название коллекции</param>
|
||||
/// <returns></returns>
|
||||
public ICollectionGenericObjects<T>? this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO Продумать логику получения объекта
|
||||
if (_storages.ContainsKey(name))
|
||||
return _storages[name];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
31
ProjectStormtrooper/Drawnings/DirectionType.cs
Normal file
31
ProjectStormtrooper/Drawnings/DirectionType.cs
Normal file
@ -0,0 +1,31 @@
|
||||
namespace ProjectStormtrooper.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
|
||||
}
|
269
ProjectStormtrooper/Drawnings/DrawningAirplane.cs
Normal file
269
ProjectStormtrooper/Drawnings/DrawningAirplane.cs
Normal file
@ -0,0 +1,269 @@
|
||||
using ProjectStormtrooper.Entites;
|
||||
|
||||
namespace ProjectStormtrooper.Drawnings;
|
||||
|
||||
public class DrawningAirplane
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityAirplane? EntityAirplane { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
private int? _pictureWidth;
|
||||
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
private int? _pictureHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки самолета
|
||||
/// </summary>
|
||||
protected int? _startPosX;
|
||||
|
||||
/// <summary>
|
||||
/// Верхняя кооридната прорисовки самолета
|
||||
/// </summary>
|
||||
protected int? _startPosY;
|
||||
|
||||
/// <summary>
|
||||
/// Ширина прорисовки самолета
|
||||
/// </summary>
|
||||
private readonly int _drawningAirplaneWidth = 153;
|
||||
|
||||
/// <summary>
|
||||
/// Высота прорисовки самолета
|
||||
/// </summary>
|
||||
private readonly int _drawningAirplaneHeight = 110;
|
||||
|
||||
/// <summary>
|
||||
/// Координата X объекта
|
||||
/// </summary>
|
||||
public int? GetPosX => _startPosX;
|
||||
|
||||
/// <summary>
|
||||
/// Координата Y объекта
|
||||
/// </summary>
|
||||
public int? GetPosY => _startPosY;
|
||||
|
||||
/// <summary>
|
||||
/// Ширина объекта
|
||||
/// </summary>
|
||||
public int GetWidth => _drawningAirplaneWidth;
|
||||
|
||||
/// <summary>
|
||||
/// Высота объекта
|
||||
/// </summary>
|
||||
public int GetHeight => _drawningAirplaneHeight;
|
||||
|
||||
/// <summary>
|
||||
/// пустой конструктор
|
||||
/// </summary>
|
||||
private DrawningAirplane()
|
||||
{
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
|
||||
public DrawningAirplane(int speed, double weight, Color bodyColor) : this()
|
||||
{
|
||||
EntityAirplane = new EntityAirplane(speed, weight, bodyColor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// конструктор для наследников
|
||||
/// </summary>
|
||||
/// <param name="drawningAirplaneWidth">Ширина прорисовки самолета</param>
|
||||
/// <param name="drawningAirplaneHeight">Высота прорисовки самолета</param>
|
||||
protected DrawningAirplane(int drawningAirplaneWidth, int drawningAirplaneHeight) : this()
|
||||
{
|
||||
this._drawningAirplaneWidth = drawningAirplaneWidth;
|
||||
this._pictureHeight = drawningAirplaneHeight;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Установка границ поля
|
||||
/// </summary>
|
||||
/// <param name="width">Ширина поля</param>
|
||||
/// <param name="height">Высота поля</param>
|
||||
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
|
||||
public bool SetPictureSize(int width, int height)
|
||||
{
|
||||
// TODO проверка, что объект "влезает" в размеры поля
|
||||
// если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
|
||||
if (width < _drawningAirplaneWidth || height < _drawningAirplaneHeight) return false;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
if (_startPosX != null || _startPosY != null)
|
||||
{
|
||||
if (_startPosX + _drawningAirplaneWidth > _pictureWidth)
|
||||
{
|
||||
_startPosX = _startPosX - (_startPosX + _drawningAirplaneWidth - _pictureWidth);
|
||||
}
|
||||
else if (_startPosX < 0) _startPosX = 0;
|
||||
if (_startPosY + _drawningAirplaneHeight > _pictureHeight)
|
||||
{
|
||||
_startPosY = _startPosY - (_startPosY + _drawningAirplaneHeight - _pictureHeight);
|
||||
}
|
||||
else if (_startPosY < 0) _startPosY = 0;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
// TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
|
||||
// то надо изменить координаты, чтобы он оставался в этих границах
|
||||
if (x + _drawningAirplaneWidth > _pictureWidth)
|
||||
{
|
||||
_startPosX = x - (x + _drawningAirplaneWidth - _pictureWidth);
|
||||
}
|
||||
else if (x < 0) _startPosX = 0;
|
||||
else _startPosX = x;
|
||||
if (y + _drawningAirplaneHeight > _pictureHeight)
|
||||
{
|
||||
_startPosY = y - (y + _drawningAirplaneHeight - _pictureHeight);
|
||||
}
|
||||
else if (y < 0) _startPosY = 0;
|
||||
else _startPosY = y;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Изменение направления перемещения
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
/// <returns>true - перемещене выполнено, false - перемещение невозможно</returns>
|
||||
public bool MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityAirplane == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
//влево
|
||||
case DirectionType.Left:
|
||||
if (_startPosX.Value - EntityAirplane.Step > 0)
|
||||
_startPosX -= (int)EntityAirplane.Step;
|
||||
return true;
|
||||
//вверх
|
||||
case DirectionType.Up:
|
||||
if (_startPosY.Value - EntityAirplane.Step > 0)
|
||||
_startPosY -= (int)EntityAirplane.Step;
|
||||
return true;
|
||||
// вправо
|
||||
case DirectionType.Right:
|
||||
if (_startPosX.Value + _drawningAirplaneWidth + EntityAirplane.Step < _pictureWidth)
|
||||
_startPosX += (int)EntityAirplane.Step;
|
||||
return true;
|
||||
//вниз
|
||||
case DirectionType.Down:
|
||||
if (_startPosY.Value + _drawningAirplaneHeight + EntityAirplane.Step < _pictureHeight)
|
||||
_startPosY += (int)EntityAirplane.Step;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityAirplane == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
|
||||
///отрисовка носа
|
||||
Point p = new Point(_startPosX.Value, _startPosY.Value + 50);
|
||||
Point p2 = new Point(_startPosX.Value + 20, _startPosY.Value + 40);
|
||||
Point p3 = new Point(_startPosX.Value + 20, _startPosY.Value + 60);
|
||||
Point p4 = new Point(_startPosX.Value, _startPosY.Value + 50);
|
||||
|
||||
Brush bortBrush = new SolidBrush(EntityAirplane.BodyColor);
|
||||
|
||||
///отрисовка борта
|
||||
g.FillRectangle(bortBrush, _startPosX.Value + 20, _startPosY.Value + 40, 120, 20);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 40, 120, 20);
|
||||
|
||||
///отрисовка вепхнего крыла
|
||||
Point p5 = new Point(_startPosX.Value + 40, _startPosY.Value);
|
||||
Point p6 = new Point(_startPosX.Value + 55, _startPosY.Value);
|
||||
Point p7 = new Point(_startPosX.Value + 70, _startPosY.Value + 40);
|
||||
Point p8 = new Point(_startPosX.Value + 40, _startPosY.Value + 40);
|
||||
Point p9 = new Point(_startPosX.Value + 40, _startPosY.Value);
|
||||
|
||||
///отрисовка нижнего крыла
|
||||
Point p10 = new Point(_startPosX.Value + 40, _startPosY.Value + 60);
|
||||
Point p11 = new Point(_startPosX.Value + 70, _startPosY.Value + 60);
|
||||
Point p12 = new Point(_startPosX.Value + 55, _startPosY.Value + 110);
|
||||
Point p13 = new Point(_startPosX.Value + 40, _startPosY.Value + 110);
|
||||
Point p14 = new Point(_startPosX.Value + 40, _startPosY.Value + 60);
|
||||
|
||||
///отрисовка верхнего хвоста
|
||||
Point p15 = new Point(_startPosX.Value + 115, _startPosY.Value + 40);
|
||||
Point p16 = new Point(_startPosX.Value + 115, _startPosY.Value + 27);
|
||||
Point p17 = new Point(_startPosX.Value + 140, _startPosY.Value + 10);
|
||||
Point p18 = new Point(_startPosX.Value + 140, _startPosY.Value + 40);
|
||||
Point p19 = new Point(_startPosX.Value + 115, _startPosY.Value + 40);
|
||||
|
||||
///отрисовка нижнего хвоста
|
||||
Point p20 = new Point(_startPosX.Value + 115, _startPosY.Value + 60);
|
||||
Point p21 = new Point(_startPosX.Value + 115, _startPosY.Value + 73);
|
||||
Point p22 = new Point(_startPosX.Value + 140, _startPosY.Value + 90);
|
||||
Point p23 = new Point(_startPosX.Value + 140, _startPosY.Value + 60);
|
||||
Point p24 = new Point(_startPosX.Value + 115, _startPosY.Value + 60);
|
||||
|
||||
|
||||
|
||||
Point[] p_nos = { p, p2, p3, p4, };
|
||||
Point[] p_krilo1 = { p5, p6, p7, p8, p9 };
|
||||
Point[] p_krilo2 = { p10, p11, p12, p13, p14 };
|
||||
Point[] p_hvost1 = { p15, p16, p17, p18, p19 };
|
||||
Point[] p_hvost2 = { p20, p21, p22, p23, p24 };
|
||||
|
||||
|
||||
g.FillPolygon(bortBrush, p_nos);
|
||||
g.FillPolygon(bortBrush, p_krilo1);
|
||||
g.FillPolygon(bortBrush, p_krilo2);
|
||||
g.FillPolygon(bortBrush, p_hvost1);
|
||||
g.FillPolygon(bortBrush, p_hvost2);
|
||||
|
||||
g.DrawPolygon(pen, p_nos);
|
||||
g.DrawPolygon(pen, p_krilo1);
|
||||
g.DrawPolygon(pen, p_krilo2);
|
||||
g.DrawPolygon(pen, p_hvost1);
|
||||
g.DrawPolygon(pen, p_hvost2);
|
||||
|
||||
}
|
||||
}
|
89
ProjectStormtrooper/Drawnings/DrawningStormtrooper.cs
Normal file
89
ProjectStormtrooper/Drawnings/DrawningStormtrooper.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using ProjectStormtrooper.Entites;
|
||||
|
||||
namespace ProjectStormtrooper.Drawnings;
|
||||
|
||||
/// <summary>
|
||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawningStormtrooper : DrawningAirplane
|
||||
{
|
||||
/// <summary>
|
||||
/// конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="dvigatel">Признак наличия обвеса</param>
|
||||
/// <param name="vint">Признак наличия антикрыла</param>
|
||||
public DrawningStormtrooper(int speed, double weight, Color bodyColor, Color additionalColor, bool dvigatel, bool vint) : base(153, 110)
|
||||
{
|
||||
EntityAirplane = new EntityStormtrooper(speed, weight, bodyColor, additionalColor, dvigatel, vint);
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityAirplane == null || EntityAirplane is not EntityStormtrooper stormtrooper || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(stormtrooper.AdditionalColor);
|
||||
|
||||
if (stormtrooper.Vint)
|
||||
{
|
||||
///отрисовка винта
|
||||
Point p25 = new Point(_startPosX.Value + 10, _startPosY.Value + 60);
|
||||
Point p26 = new Point(_startPosX.Value + 5, _startPosY.Value + 35);
|
||||
Point p27 = new Point(_startPosX.Value + 15, _startPosY.Value + 35);
|
||||
Point p28 = new Point(_startPosX.Value + 10, _startPosY.Value + 60);
|
||||
|
||||
|
||||
|
||||
Point p29 = new Point(_startPosX.Value + 10, _startPosY.Value + 60);
|
||||
Point p30 = new Point(_startPosX.Value + 5, _startPosY.Value + 85);
|
||||
Point p31 = new Point(_startPosX.Value + 15, _startPosY.Value + 85);
|
||||
Point p32 = new Point(_startPosX.Value + 10, _startPosY.Value + 60);
|
||||
Point[] p_vint = { p25, p26, p27, p28, p29, p30, p31, p32 };
|
||||
g.DrawPolygon(pen, p_vint);
|
||||
|
||||
///отрисовка крепления нижнего двигателя
|
||||
Point p33 = new Point(_startPosX.Value + 90, _startPosY.Value + 66);
|
||||
Point p34 = new Point(_startPosX.Value + 95, _startPosY.Value + 70);
|
||||
Point p35 = new Point(_startPosX.Value + 110, _startPosY.Value + 70);
|
||||
Point p36 = new Point(_startPosX.Value + 115, _startPosY.Value + 65);
|
||||
|
||||
///отрисовка крепления верхнего двигателя
|
||||
Point p37 = new Point(_startPosX.Value + 90, _startPosY.Value + 45);
|
||||
Point p38 = new Point(_startPosX.Value + 95, _startPosY.Value + 40);
|
||||
Point p39 = new Point(_startPosX.Value + 110, _startPosY.Value + 40);
|
||||
Point p40 = new Point(_startPosX.Value + 115, _startPosY.Value + 45);
|
||||
|
||||
///отрисовка верхней ракеты
|
||||
g.DrawEllipse(pen, _startPosX.Value + 88, _startPosY.Value + 30, 34, 10);
|
||||
|
||||
///отрисовка нижней ракеты
|
||||
g.DrawEllipse(pen, _startPosX.Value + 88, _startPosY.Value + 70, 34, 10);
|
||||
|
||||
Point[] p_kreplenie2 = { p33, p34, p35, p36 };
|
||||
Point[] p_kreplenie1 = { p37, p38, p39, p40 };
|
||||
|
||||
g.DrawPolygon(pen, p_kreplenie2);
|
||||
g.DrawPolygon(pen, p_kreplenie1);
|
||||
}
|
||||
|
||||
_startPosX += 10;
|
||||
_startPosY += 5;
|
||||
base.DrawTransport(g);
|
||||
_startPosX -= 10;
|
||||
_startPosY -= 5;
|
||||
|
||||
// отрисовка двигателей
|
||||
if (stormtrooper.Dvigatel)
|
||||
{
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 75, _startPosY.Value + 25, 15, 15);
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 75, _startPosY.Value + 75, 15, 15);
|
||||
}
|
||||
}
|
||||
}
|
46
ProjectStormtrooper/Entites/EntityAirplane.cs
Normal file
46
ProjectStormtrooper/Entites/EntityAirplane.cs
Normal file
@ -0,0 +1,46 @@
|
||||
namespace ProjectStormtrooper.Entites;
|
||||
|
||||
/// <summary>
|
||||
/// Класс-сущность "Самолет"
|
||||
/// </summary>
|
||||
|
||||
public class EntityAirplane
|
||||
{
|
||||
/// <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 EntityAirplane(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
}
|
38
ProjectStormtrooper/Entites/EntityStormtrooper.cs
Normal file
38
ProjectStormtrooper/Entites/EntityStormtrooper.cs
Normal file
@ -0,0 +1,38 @@
|
||||
namespace ProjectStormtrooper.Entites;
|
||||
|
||||
/// <summary>
|
||||
/// Класс-сущность "Спортивный автомобиль"
|
||||
/// </summary>
|
||||
public class EntityStormtrooper : EntityAirplane
|
||||
{
|
||||
/// <summary>
|
||||
/// Дополнительтный цвет
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
|
||||
public void setAdditionalColor(Color color)
|
||||
{
|
||||
AdditionalColor = color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Признак наличия труб
|
||||
/// </summary>
|
||||
public bool Vint { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия топливного бака
|
||||
/// </summary>
|
||||
public bool Dvigatel { get; private set; }
|
||||
/// <summary>
|
||||
/// Инициализация полей класса EntityStormtrooper
|
||||
/// </summary>
|
||||
/// <param name="additionalcolor"></param>
|
||||
/// <param name="vint"></param>
|
||||
/// <param name="dvigatel"></param>
|
||||
public EntityStormtrooper(int speed, double weight, Color bodycolor, Color additionalcolor, bool vint, bool dvigatel) : base(speed, weight, bodycolor)
|
||||
{
|
||||
AdditionalColor = additionalcolor;
|
||||
Vint = vint;
|
||||
Dvigatel = dvigatel;
|
||||
}
|
||||
}
|
313
ProjectStormtrooper/FormAirplaneCollection.Designer.cs
generated
Normal file
313
ProjectStormtrooper/FormAirplaneCollection.Designer.cs
generated
Normal file
@ -0,0 +1,313 @@
|
||||
namespace ProjectStormtrooper
|
||||
{
|
||||
partial class FormAirplaneCollection
|
||||
{
|
||||
/// <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();
|
||||
buttonAddAirplane = new Button();
|
||||
buttonAddStormtrooper = new Button();
|
||||
buttonRefresh = new Button();
|
||||
maskedTextBox = new MaskedTextBox();
|
||||
buttonGoToCheck = new Button();
|
||||
buttonRemoveAirplane = 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();
|
||||
groupBoxTools.SuspendLayout();
|
||||
panelCompanyTools.SuspendLayout();
|
||||
panelStorage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||
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(894, 0);
|
||||
groupBoxTools.Margin = new Padding(3, 4, 3, 4);
|
||||
groupBoxTools.Name = "groupBoxTools";
|
||||
groupBoxTools.Padding = new Padding(3, 4, 3, 4);
|
||||
groupBoxTools.Size = new Size(205, 749);
|
||||
groupBoxTools.TabIndex = 0;
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
//
|
||||
// panelCompanyTools
|
||||
//
|
||||
panelCompanyTools.Controls.Add(buttonAddAirplane);
|
||||
panelCompanyTools.Controls.Add(buttonAddStormtrooper);
|
||||
panelCompanyTools.Controls.Add(buttonRefresh);
|
||||
panelCompanyTools.Controls.Add(maskedTextBox);
|
||||
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||
panelCompanyTools.Controls.Add(buttonRemoveAirplane);
|
||||
panelCompanyTools.Dock = DockStyle.Bottom;
|
||||
panelCompanyTools.Location = new Point(3, 421);
|
||||
panelCompanyTools.Name = "panelCompanyTools";
|
||||
panelCompanyTools.Size = new Size(199, 324);
|
||||
panelCompanyTools.TabIndex = 9;
|
||||
//
|
||||
// buttonAddAirplane
|
||||
//
|
||||
buttonAddAirplane.Dock = DockStyle.Bottom;
|
||||
buttonAddAirplane.Location = new Point(0, 4);
|
||||
buttonAddAirplane.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonAddAirplane.Name = "buttonAddAirplane";
|
||||
buttonAddAirplane.Size = new Size(199, 60);
|
||||
buttonAddAirplane.TabIndex = 1;
|
||||
buttonAddAirplane.Text = "Добавление самолета";
|
||||
buttonAddAirplane.UseVisualStyleBackColor = true;
|
||||
buttonAddAirplane.Click += buttonAddAirplane_Click;
|
||||
//
|
||||
// buttonAddStormtrooper
|
||||
//
|
||||
buttonAddStormtrooper.Dock = DockStyle.Bottom;
|
||||
buttonAddStormtrooper.Location = new Point(0, 64);
|
||||
buttonAddStormtrooper.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonAddStormtrooper.Name = "buttonAddStormtrooper";
|
||||
buttonAddStormtrooper.Size = new Size(199, 61);
|
||||
buttonAddStormtrooper.TabIndex = 2;
|
||||
buttonAddStormtrooper.Text = "Добавление штурмовика";
|
||||
buttonAddStormtrooper.UseVisualStyleBackColor = true;
|
||||
buttonAddStormtrooper.Click += buttonAddAirplane_Click;
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Dock = DockStyle.Bottom;
|
||||
buttonRefresh.Location = new Point(0, 125);
|
||||
buttonRefresh.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(199, 54);
|
||||
buttonRefresh.TabIndex = 6;
|
||||
buttonRefresh.Text = "Обновить";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += buttonRefresh_Click;
|
||||
//
|
||||
// maskedTextBox
|
||||
//
|
||||
maskedTextBox.Dock = DockStyle.Bottom;
|
||||
maskedTextBox.Location = new Point(0, 179);
|
||||
maskedTextBox.Margin = new Padding(3, 4, 3, 4);
|
||||
maskedTextBox.Mask = "00";
|
||||
maskedTextBox.Name = "maskedTextBox";
|
||||
maskedTextBox.Size = new Size(199, 27);
|
||||
maskedTextBox.TabIndex = 3;
|
||||
maskedTextBox.ValidatingType = typeof(int);
|
||||
//
|
||||
// buttonGoToCheck
|
||||
//
|
||||
buttonGoToCheck.Dock = DockStyle.Bottom;
|
||||
buttonGoToCheck.Location = new Point(0, 206);
|
||||
buttonGoToCheck.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||
buttonGoToCheck.Size = new Size(199, 56);
|
||||
buttonGoToCheck.TabIndex = 5;
|
||||
buttonGoToCheck.Text = "Передать на тесты";
|
||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||
buttonGoToCheck.Click += buttonGoToCheck_Click;
|
||||
//
|
||||
// buttonRemoveAirplane
|
||||
//
|
||||
buttonRemoveAirplane.Dock = DockStyle.Bottom;
|
||||
buttonRemoveAirplane.Location = new Point(0, 262);
|
||||
buttonRemoveAirplane.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonRemoveAirplane.Name = "buttonRemoveAirplane";
|
||||
buttonRemoveAirplane.Size = new Size(199, 62);
|
||||
buttonRemoveAirplane.TabIndex = 4;
|
||||
buttonRemoveAirplane.Text = "Удалить самолет";
|
||||
buttonRemoveAirplane.UseVisualStyleBackColor = true;
|
||||
buttonRemoveAirplane.Click += buttonRemoveAirplane_Click;
|
||||
//
|
||||
// buttonCreateCompany
|
||||
//
|
||||
buttonCreateCompany.Location = new Point(8, 364);
|
||||
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||
buttonCreateCompany.Size = new Size(192, 29);
|
||||
buttonCreateCompany.TabIndex = 8;
|
||||
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, 24);
|
||||
panelStorage.Name = "panelStorage";
|
||||
panelStorage.Size = new Size(199, 298);
|
||||
panelStorage.TabIndex = 7;
|
||||
//
|
||||
// buttonCollectionDel
|
||||
//
|
||||
buttonCollectionDel.Location = new Point(4, 262);
|
||||
buttonCollectionDel.Name = "buttonCollectionDel";
|
||||
buttonCollectionDel.Size = new Size(192, 29);
|
||||
buttonCollectionDel.TabIndex = 6;
|
||||
buttonCollectionDel.Text = "Удалить коллекцию";
|
||||
buttonCollectionDel.UseVisualStyleBackColor = true;
|
||||
buttonCollectionDel.Click += buttonCollectionDel_Click;
|
||||
//
|
||||
// listBoxCollection
|
||||
//
|
||||
listBoxCollection.FormattingEnabled = true;
|
||||
listBoxCollection.ItemHeight = 20;
|
||||
listBoxCollection.Location = new Point(7, 132);
|
||||
listBoxCollection.Name = "listBoxCollection";
|
||||
listBoxCollection.Size = new Size(190, 124);
|
||||
listBoxCollection.TabIndex = 5;
|
||||
//
|
||||
// buttonCollectionAdd
|
||||
//
|
||||
buttonCollectionAdd.Location = new Point(7, 97);
|
||||
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
||||
buttonCollectionAdd.Size = new Size(192, 29);
|
||||
buttonCollectionAdd.TabIndex = 4;
|
||||
buttonCollectionAdd.Text = "Добавить коллекцию";
|
||||
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
||||
buttonCollectionAdd.Click += buttonCollectionAdd_Click;
|
||||
//
|
||||
// radioButtonList
|
||||
//
|
||||
radioButtonList.AutoSize = true;
|
||||
radioButtonList.Location = new Point(110, 67);
|
||||
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(7, 67);
|
||||
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(5, 34);
|
||||
textBoxCollectionName.Name = "textBoxCollectionName";
|
||||
textBoxCollectionName.Size = new Size(192, 27);
|
||||
textBoxCollectionName.TabIndex = 1;
|
||||
//
|
||||
// labelCollectionName
|
||||
//
|
||||
labelCollectionName.AutoSize = true;
|
||||
labelCollectionName.Location = new Point(25, 11);
|
||||
labelCollectionName.Name = "labelCollectionName";
|
||||
labelCollectionName.Size = new Size(150, 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(10, 329);
|
||||
comboBoxSelectorCompany.Margin = new Padding(3, 4, 3, 4);
|
||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||
comboBoxSelectorCompany.Size = new Size(190, 28);
|
||||
comboBoxSelectorCompany.TabIndex = 0;
|
||||
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
pictureBox.Dock = DockStyle.Fill;
|
||||
pictureBox.Location = new Point(0, 0);
|
||||
pictureBox.Margin = new Padding(3, 4, 3, 4);
|
||||
pictureBox.Name = "pictureBox";
|
||||
pictureBox.Size = new Size(894, 749);
|
||||
pictureBox.TabIndex = 1;
|
||||
pictureBox.TabStop = false;
|
||||
//
|
||||
// FormAirplaneCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1099, 749);
|
||||
Controls.Add(pictureBox);
|
||||
Controls.Add(groupBoxTools);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormAirplaneCollection";
|
||||
Text = "Коллекция автомобилей";
|
||||
groupBoxTools.ResumeLayout(false);
|
||||
panelCompanyTools.ResumeLayout(false);
|
||||
panelCompanyTools.PerformLayout();
|
||||
panelStorage.ResumeLayout(false);
|
||||
panelStorage.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxTools;
|
||||
private ComboBox comboBoxSelectorCompany;
|
||||
private Button buttonAddStormtrooper;
|
||||
private Button buttonAddAirplane;
|
||||
private Button buttonRemoveAirplane;
|
||||
private MaskedTextBox maskedTextBox;
|
||||
private PictureBox pictureBox;
|
||||
private Button buttonGoToCheck;
|
||||
private Button buttonRefresh;
|
||||
private Panel panelStorage;
|
||||
private Button buttonCollectionAdd;
|
||||
private RadioButton radioButtonList;
|
||||
private RadioButton radioButtonMassive;
|
||||
private TextBox textBoxCollectionName;
|
||||
private Label labelCollectionName;
|
||||
private Button buttonCreateCompany;
|
||||
private Button buttonCollectionDel;
|
||||
private ListBox listBoxCollection;
|
||||
private Panel panelCompanyTools;
|
||||
}
|
||||
}
|
190
ProjectStormtrooper/FormAirplaneCollection.cs
Normal file
190
ProjectStormtrooper/FormAirplaneCollection.cs
Normal file
@ -0,0 +1,190 @@
|
||||
using ProjectStormtrooper.CollectionGenericObjects;
|
||||
using ProjectStormtrooper.Drawnings;
|
||||
|
||||
namespace ProjectStormtrooper;
|
||||
|
||||
/// <summary>
|
||||
/// Форма работы с компанией и ее коллекцией
|
||||
/// </summary>
|
||||
public partial class FormAirplaneCollection : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Компания
|
||||
/// </summary>
|
||||
private AbstractCompany? _company = null;
|
||||
|
||||
private readonly StorageCollection<DrawningAirplane> _storageCollection;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormAirplaneCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_storageCollection = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Выбор компании
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
panelCompanyTools.Enabled = false;
|
||||
}
|
||||
|
||||
private void buttonAddAirplane_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormAirplaneConfig form = new();
|
||||
form.Show();
|
||||
form.AddEvent(SetAirplane);
|
||||
}
|
||||
private void SetAirplane(DrawningAirplane? airplane)
|
||||
{
|
||||
if (_company == null || airplane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_company + airplane != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _company.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonRemoveAirplane_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBox.Text);
|
||||
if (_company - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _company.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
private void buttonGoToCheck_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DrawningAirplane? airplane = null;
|
||||
int counter = 100;
|
||||
while (airplane == null)
|
||||
{
|
||||
airplane = _company.GetRandomObject();
|
||||
counter--;
|
||||
if (counter <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (airplane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormStormtrooper form = new()
|
||||
{
|
||||
SetAirplane = airplane
|
||||
};
|
||||
form.ShowDialog();
|
||||
}
|
||||
private void buttonRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _company.Show();
|
||||
}
|
||||
|
||||
private void buttonCollectionAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
CollectionType collectionType = CollectionType.None;
|
||||
if (radioButtonMassive.Checked)
|
||||
{
|
||||
collectionType = CollectionType.Massive;
|
||||
}
|
||||
else if (radioButtonList.Checked)
|
||||
{
|
||||
collectionType = CollectionType.List;
|
||||
}
|
||||
_storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
|
||||
RerfreshListBoxItems();
|
||||
}
|
||||
private void RerfreshListBoxItems()
|
||||
{
|
||||
listBoxCollection.Items.Clear();
|
||||
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
|
||||
{
|
||||
string? colName = _storageCollection.Keys?[i];
|
||||
if (!string.IsNullOrEmpty(colName))
|
||||
{
|
||||
listBoxCollection.Items.Add(colName);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void buttonCollectionDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
// TODO прописать логику удаления элемента из коллекции
|
||||
// нужно убедиться, что есть выбранная коллекция
|
||||
// спросить у пользователя через MessageBox, что он подтверждает, что хочет удалить запись
|
||||
// удалить и обновить ListBox
|
||||
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
||||
{
|
||||
MessageBox.Show("Коллекция не выбрана");
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
|
||||
RerfreshListBoxItems();
|
||||
}
|
||||
private void buttonCreateCompany_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
||||
{
|
||||
MessageBox.Show("Коллекция не выбрана");
|
||||
return;
|
||||
}
|
||||
ICollectionGenericObjects<DrawningAirplane>? collection =
|
||||
_storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
|
||||
if (collection == null)
|
||||
{
|
||||
MessageBox.Show("Коллекция не проинициализирована");
|
||||
return;
|
||||
}
|
||||
switch (comboBoxSelectorCompany.Text)
|
||||
{
|
||||
case "Хранилище":
|
||||
_company = new AirplaneSharingService(pictureBox.Width, pictureBox.Height, collection);
|
||||
break;
|
||||
}
|
||||
panelCompanyTools.Enabled = true;
|
||||
RerfreshListBoxItems();
|
||||
}
|
||||
}
|
358
ProjectStormtrooper/FormAirplaneConfig.Designer.cs
generated
Normal file
358
ProjectStormtrooper/FormAirplaneConfig.Designer.cs
generated
Normal file
@ -0,0 +1,358 @@
|
||||
namespace ProjectStormtrooper
|
||||
{
|
||||
partial class FormAirplaneConfig
|
||||
{
|
||||
/// <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();
|
||||
panelBlack = new Panel();
|
||||
panelGrey = new Panel();
|
||||
panelWhite = new Panel();
|
||||
panelYellow = new Panel();
|
||||
panelBlue = new Panel();
|
||||
panelGreen = new Panel();
|
||||
panelRed = new Panel();
|
||||
checkBoxDvigatel = new CheckBox();
|
||||
checkBoxVint = 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();
|
||||
buttonCancel = new Button();
|
||||
panelObject = new Panel();
|
||||
labelAdditionalColor = new Label();
|
||||
labelBodyColor = new Label();
|
||||
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(checkBoxDvigatel);
|
||||
groupBoxConfig.Controls.Add(checkBoxVint);
|
||||
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(547, 450);
|
||||
groupBoxConfig.TabIndex = 0;
|
||||
groupBoxConfig.TabStop = false;
|
||||
groupBoxConfig.Text = "Параметры";
|
||||
//
|
||||
// groupBoxColors
|
||||
//
|
||||
groupBoxColors.Controls.Add(panelPurple);
|
||||
groupBoxColors.Controls.Add(panelBlack);
|
||||
groupBoxColors.Controls.Add(panelGrey);
|
||||
groupBoxColors.Controls.Add(panelWhite);
|
||||
groupBoxColors.Controls.Add(panelYellow);
|
||||
groupBoxColors.Controls.Add(panelBlue);
|
||||
groupBoxColors.Controls.Add(panelGreen);
|
||||
groupBoxColors.Controls.Add(panelRed);
|
||||
groupBoxColors.Location = new Point(275, 25);
|
||||
groupBoxColors.Name = "groupBoxColors";
|
||||
groupBoxColors.Size = new Size(250, 125);
|
||||
groupBoxColors.TabIndex = 8;
|
||||
groupBoxColors.TabStop = false;
|
||||
groupBoxColors.Text = "Цвета";
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
panelPurple.BackColor = Color.Purple;
|
||||
panelPurple.Location = new Point(204, 82);
|
||||
panelPurple.Name = "panelPurple";
|
||||
panelPurple.Size = new Size(40, 37);
|
||||
panelPurple.TabIndex = 3;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
panelBlack.BackColor = Color.Black;
|
||||
panelBlack.Location = new Point(136, 82);
|
||||
panelBlack.Name = "panelBlack";
|
||||
panelBlack.Size = new Size(40, 37);
|
||||
panelBlack.TabIndex = 4;
|
||||
//
|
||||
// panelGrey
|
||||
//
|
||||
panelGrey.BackColor = Color.Gray;
|
||||
panelGrey.Location = new Point(68, 82);
|
||||
panelGrey.Name = "panelGrey";
|
||||
panelGrey.Size = new Size(40, 37);
|
||||
panelGrey.TabIndex = 5;
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
panelWhite.BackColor = Color.White;
|
||||
panelWhite.Location = new Point(6, 82);
|
||||
panelWhite.Name = "panelWhite";
|
||||
panelWhite.Size = new Size(40, 37);
|
||||
panelWhite.TabIndex = 2;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
panelYellow.BackColor = Color.Yellow;
|
||||
panelYellow.Location = new Point(204, 26);
|
||||
panelYellow.Name = "panelYellow";
|
||||
panelYellow.Size = new Size(40, 37);
|
||||
panelYellow.TabIndex = 1;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
panelBlue.BackColor = Color.Blue;
|
||||
panelBlue.Location = new Point(136, 26);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new Size(40, 37);
|
||||
panelBlue.TabIndex = 1;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
panelGreen.BackColor = Color.Green;
|
||||
panelGreen.Location = new Point(68, 26);
|
||||
panelGreen.Name = "panelGreen";
|
||||
panelGreen.Size = new Size(40, 37);
|
||||
panelGreen.TabIndex = 1;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.BackColor = Color.Red;
|
||||
panelRed.Location = new Point(6, 26);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(40, 37);
|
||||
panelRed.TabIndex = 0;
|
||||
//
|
||||
// checkBoxDvigatel
|
||||
//
|
||||
checkBoxDvigatel.AutoSize = true;
|
||||
checkBoxDvigatel.Location = new Point(12, 172);
|
||||
checkBoxDvigatel.Name = "checkBoxDvigatel";
|
||||
checkBoxDvigatel.Size = new Size(227, 24);
|
||||
checkBoxDvigatel.TabIndex = 7;
|
||||
checkBoxDvigatel.Text = "Признак наличия двигателя";
|
||||
checkBoxDvigatel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxVint
|
||||
//
|
||||
checkBoxVint.AutoSize = true;
|
||||
checkBoxVint.Location = new Point(12, 131);
|
||||
checkBoxVint.Name = "checkBoxVint";
|
||||
checkBoxVint.Size = new Size(198, 24);
|
||||
checkBoxVint.TabIndex = 6;
|
||||
checkBoxVint.Text = "Признак наличия винта";
|
||||
checkBoxVint.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(84, 80);
|
||||
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(150, 27);
|
||||
numericUpDownWeight.TabIndex = 5;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
labelWeight.AutoSize = true;
|
||||
labelWeight.Location = new Point(23, 82);
|
||||
labelWeight.Name = "labelWeight";
|
||||
labelWeight.Size = new Size(36, 20);
|
||||
labelWeight.TabIndex = 4;
|
||||
labelWeight.Text = "Вес:";
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(84, 34);
|
||||
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(150, 27);
|
||||
numericUpDownSpeed.TabIndex = 3;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
labelSpeed.AutoSize = true;
|
||||
labelSpeed.Location = new Point(6, 34);
|
||||
labelSpeed.Name = "labelSpeed";
|
||||
labelSpeed.Size = new Size(76, 20);
|
||||
labelSpeed.TabIndex = 2;
|
||||
labelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelModifiedObject.Location = new Point(411, 153);
|
||||
labelModifiedObject.Name = "labelModifiedObject";
|
||||
labelModifiedObject.Size = new Size(118, 43);
|
||||
labelModifiedObject.TabIndex = 1;
|
||||
labelModifiedObject.Text = "Продвинутый";
|
||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelModifiedObject.MouseDown += labelObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Location = new Point(275, 153);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new Size(118, 43);
|
||||
labelSimpleObject.TabIndex = 0;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSimpleObject.MouseDown += labelObject_MouseDown;
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(10, 34);
|
||||
pictureBoxObject.Margin = new Padding(3, 4, 3, 4);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(208, 116);
|
||||
pictureBoxObject.TabIndex = 1;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(563, 167);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(94, 29);
|
||||
buttonAdd.TabIndex = 2;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(677, 167);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 3;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
panelObject.AllowDrop = true;
|
||||
panelObject.Controls.Add(labelAdditionalColor);
|
||||
panelObject.Controls.Add(labelBodyColor);
|
||||
panelObject.Controls.Add(pictureBoxObject);
|
||||
panelObject.Location = new Point(553, 0);
|
||||
panelObject.Name = "panelObject";
|
||||
panelObject.Size = new Size(235, 161);
|
||||
panelObject.TabIndex = 4;
|
||||
panelObject.DragDrop += panelObject_DragDrop;
|
||||
panelObject.DragEnter += panelObject_DragEnter;
|
||||
//
|
||||
// labelAdditionalColor
|
||||
//
|
||||
labelAdditionalColor.AllowDrop = true;
|
||||
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAdditionalColor.Location = new Point(101, 4);
|
||||
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||
labelAdditionalColor.Size = new Size(87, 27);
|
||||
labelAdditionalColor.TabIndex = 3;
|
||||
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(10, 4);
|
||||
labelBodyColor.Name = "labelBodyColor";
|
||||
labelBodyColor.Size = new Size(60, 27);
|
||||
labelBodyColor.TabIndex = 2;
|
||||
labelBodyColor.Text = "Цвет";
|
||||
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
|
||||
labelBodyColor.DragEnter += labelBodyColor_DragEnter;
|
||||
//
|
||||
// FormAirplaneConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(panelObject);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(groupBoxConfig);
|
||||
Name = "FormAirplaneConfig";
|
||||
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 labelWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label labelSpeed;
|
||||
private Label labelModifiedObject;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private GroupBox groupBoxColors;
|
||||
private CheckBox checkBoxDvigatel;
|
||||
private CheckBox checkBoxVint;
|
||||
private Panel panelYellow;
|
||||
private Panel panelBlue;
|
||||
private Panel panelGreen;
|
||||
private Panel panelRed;
|
||||
private Panel panelPurple;
|
||||
private Panel panelBlack;
|
||||
private Panel panelGrey;
|
||||
private Panel panelWhite;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCancel;
|
||||
private Panel panelObject;
|
||||
private Label labelAdditionalColor;
|
||||
private Label labelBodyColor;
|
||||
}
|
||||
}
|
181
ProjectStormtrooper/FormAirplaneConfig.cs
Normal file
181
ProjectStormtrooper/FormAirplaneConfig.cs
Normal file
@ -0,0 +1,181 @@
|
||||
using ProjectStormtrooper.Drawnings;
|
||||
using ProjectStormtrooper.Entites;
|
||||
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 ProjectStormtrooper;
|
||||
|
||||
/// <summary>
|
||||
/// Форма конфигурации объекта
|
||||
/// </summary>
|
||||
public partial class FormAirplaneConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Объект - прорисовка самолета
|
||||
/// </summary>
|
||||
private DrawningAirplane? _airplane = null;
|
||||
|
||||
private event Action<DrawningAirplane>? AirplaneDelegate;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormAirplaneConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelRed.MouseDown += Panel_MouseDown;
|
||||
panelGreen.MouseDown += Panel_MouseDown;
|
||||
panelBlue.MouseDown += Panel_MouseDown;
|
||||
panelYellow.MouseDown += Panel_MouseDown;
|
||||
panelWhite.MouseDown += Panel_MouseDown;
|
||||
panelGrey.MouseDown += Panel_MouseDown;
|
||||
panelBlack.MouseDown += Panel_MouseDown;
|
||||
panelPurple.MouseDown += Panel_MouseDown;
|
||||
// TODO buttonCancel.Click привязать анонимный метод через lambda с закрытием формы
|
||||
buttonCancel.Click += (sender, e) => Close();
|
||||
}
|
||||
|
||||
public void AddEvent(Action<DrawningAirplane> airplaneDelegate)
|
||||
{
|
||||
if (AirplaneDelegate == null)
|
||||
{
|
||||
AirplaneDelegate = airplaneDelegate;
|
||||
}
|
||||
else
|
||||
{
|
||||
AirplaneDelegate += airplaneDelegate;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
private void DrawObject()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_airplane?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
_airplane?.SetPosition(5, 5);
|
||||
_airplane?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Передаем информацию при нажатии на Label
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void labelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверка получемой информации (ее типа на соответствие требуемому)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void panelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Действия при приеме перетаскиваемой информации
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void panelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
_airplane = new DrawningAirplane((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_airplane = new DrawningStormtrooper((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value,
|
||||
Color.White, Color.Black, checkBoxVint.Checked, checkBoxDvigatel.Checked);
|
||||
break;
|
||||
}
|
||||
labelBodyColor.BackColor = Color.Empty;
|
||||
labelAdditionalColor.BackColor = Color.Empty;
|
||||
DrawObject();
|
||||
}
|
||||
|
||||
private void Panel_MouseDown(object? sender, MouseEventArgs e)
|
||||
{
|
||||
// TODO отправка цвета в Drag&Drop
|
||||
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
|
||||
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)
|
||||
{
|
||||
if (_airplane != null)
|
||||
{
|
||||
_airplane.EntityAirplane.setBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||
DrawObject();
|
||||
}
|
||||
}
|
||||
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_airplane is DrawningStormtrooper)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_airplane.EntityAirplane is EntityStormtrooper _stormtrooper)
|
||||
{
|
||||
_stormtrooper.setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||
}
|
||||
DrawObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Передача объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_airplane != null)
|
||||
{
|
||||
AirplaneDelegate?.Invoke(_airplane);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectStormtrooper/FormAirplaneConfig.resx
Normal file
120
ProjectStormtrooper/FormAirplaneConfig.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
147
ProjectStormtrooper/FormStormtrooper.Designer.cs
generated
Normal file
147
ProjectStormtrooper/FormStormtrooper.Designer.cs
generated
Normal file
@ -0,0 +1,147 @@
|
||||
namespace ProjectStormtrooper;
|
||||
|
||||
partial class FormStormtrooper
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
pictureBoxStormtrooper = new PictureBox();
|
||||
buttonLeft = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonRight = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
buttonStrategyStep = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxStormtrooper).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxStormtrooper
|
||||
//
|
||||
pictureBoxStormtrooper.Dock = DockStyle.Fill;
|
||||
pictureBoxStormtrooper.Location = new Point(0, 0);
|
||||
pictureBoxStormtrooper.Name = "pictureBoxStormtrooper";
|
||||
pictureBoxStormtrooper.Size = new Size(1268, 518);
|
||||
pictureBoxStormtrooper.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
pictureBoxStormtrooper.TabIndex = 0;
|
||||
pictureBoxStormtrooper.TabStop = false;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonLeft.Location = new Point(787, 550);
|
||||
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.arrowUp;
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUp.Location = new Point(828, 509);
|
||||
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.arrowDown;
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDown.Location = new Point(828, 550);
|
||||
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.arrowRight;
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonRight.Location = new Point(869, 550);
|
||||
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(790, 12);
|
||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
comboBoxStrategy.Size = new Size(121, 23);
|
||||
comboBoxStrategy.TabIndex = 7;
|
||||
//
|
||||
// buttonStrategyStep
|
||||
//
|
||||
buttonStrategyStep.Location = new Point(836, 41);
|
||||
buttonStrategyStep.Name = "buttonStrategyStep";
|
||||
buttonStrategyStep.Size = new Size(75, 23);
|
||||
buttonStrategyStep.TabIndex = 8;
|
||||
buttonStrategyStep.Text = "Шаг";
|
||||
buttonStrategyStep.UseVisualStyleBackColor = true;
|
||||
buttonStrategyStep.Click += ButtonStrategyStep_Click;
|
||||
//
|
||||
// FormStormtrooper
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(923, 597);
|
||||
Controls.Add(buttonStrategyStep);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(pictureBoxStormtrooper);
|
||||
Name = "FormStormtrooper";
|
||||
Text = "Штурмовик";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxStormtrooper).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxStormtrooper;
|
||||
private Button buttonLeft;
|
||||
private Button buttonUp;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonStrategyStep;
|
||||
}
|
||||
|
140
ProjectStormtrooper/FormStormtrooper.cs
Normal file
140
ProjectStormtrooper/FormStormtrooper.cs
Normal file
@ -0,0 +1,140 @@
|
||||
using ProjectStormtrooper.Drawnings;
|
||||
using ProjectStormtrooper.MovementStrategy;
|
||||
|
||||
namespace ProjectStormtrooper;
|
||||
|
||||
/// <summary>
|
||||
/// Форма работы с объектом "Штурмовик"
|
||||
/// </summary>
|
||||
public partial class FormStormtrooper : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Поле-объект для прорисовки объекта
|
||||
/// </summary>
|
||||
private DrawningAirplane? _drawningAirplane;
|
||||
|
||||
/// <summary>
|
||||
/// Стратегия перемещения
|
||||
/// </summary>
|
||||
private AbstractStrategy? _strategy;
|
||||
|
||||
/// <summary>
|
||||
/// Получение объекта
|
||||
/// </summary>
|
||||
public DrawningAirplane SetAirplane
|
||||
{
|
||||
set
|
||||
{
|
||||
_drawningAirplane = value;
|
||||
_drawningAirplane.SetPictureSize(pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height);
|
||||
comboBoxStrategy.Enabled = true;
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор формы
|
||||
/// </summary>
|
||||
public FormStormtrooper()
|
||||
{
|
||||
InitializeComponent();
|
||||
_strategy = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Метод прорисовки машины
|
||||
/// </summary>
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningAirplane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningAirplane.DrawTransport(gr);
|
||||
pictureBoxStormtrooper.Image = bmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перемещение объекта по форме (нажатие кнопок навигации)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningAirplane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
bool result = false;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
result =
|
||||
_drawningAirplane.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
result =
|
||||
_drawningAirplane.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
result =
|
||||
_drawningAirplane.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
result =
|
||||
_drawningAirplane.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Шаг"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
///
|
||||
|
||||
private void ButtonStrategyStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningAirplane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxStrategy.Enabled)
|
||||
{
|
||||
_strategy = comboBoxStrategy.SelectedIndex switch
|
||||
{
|
||||
0 => new MoveToCenter(),
|
||||
1 => new MoveToBorder(),
|
||||
_ => null,
|
||||
};
|
||||
if (_strategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_strategy.SetData(new MoveableAirplane(_drawningAirplane), pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height);
|
||||
}
|
||||
|
||||
if (_strategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
comboBoxStrategy.Enabled = false;
|
||||
_strategy.MakeStep();
|
||||
Draw();
|
||||
if (_strategy.GetStatus == StrategyStatus.Finish)
|
||||
{
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_strategy = null;
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectStormtrooper/FormStormtrooper.resx
Normal file
120
ProjectStormtrooper/FormStormtrooper.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
134
ProjectStormtrooper/MovementStrategy/AbstractStrategy.cs
Normal file
134
ProjectStormtrooper/MovementStrategy/AbstractStrategy.cs
Normal file
@ -0,0 +1,134 @@
|
||||
namespace ProjectStormtrooper.MovementStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Класс-стратегия перемещения объекта
|
||||
/// </summary>
|
||||
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 { get { 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;
|
||||
}
|
||||
}
|
24
ProjectStormtrooper/MovementStrategy/IMoveableObject.cs
Normal file
24
ProjectStormtrooper/MovementStrategy/IMoveableObject.cs
Normal file
@ -0,0 +1,24 @@
|
||||
namespace ProjectStormtrooper.MovementStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Интерфейс для работы с перемещаемым объектом
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
31
ProjectStormtrooper/MovementStrategy/MoveToBorder.cs
Normal file
31
ProjectStormtrooper/MovementStrategy/MoveToBorder.cs
Normal file
@ -0,0 +1,31 @@
|
||||
namespace ProjectStormtrooper.MovementStrategy;
|
||||
|
||||
public class MoveToBorder : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
ObjectParameters? objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return objParams.LeftBorder - GetStep() <= 0 ||
|
||||
objParams.RightBorder + GetStep() >= FieldWidth ||
|
||||
objParams.TopBorder - GetStep() <= 0
|
||||
|| objParams.ObjectMiddleVertical + GetStep() >= FieldHeight;
|
||||
}
|
||||
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
ObjectParameters? objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//реализация в правый нижний угол
|
||||
int x = objParams.RightBorder;
|
||||
if (x + GetStep() < FieldWidth) MoveRight();
|
||||
int y = objParams.DownBorder;
|
||||
if (y + GetStep() < FieldHeight) MoveDown();
|
||||
}
|
||||
}
|
53
ProjectStormtrooper/MovementStrategy/MoveToCenter.cs
Normal file
53
ProjectStormtrooper/MovementStrategy/MoveToCenter.cs
Normal file
@ -0,0 +1,53 @@
|
||||
namespace ProjectStormtrooper.MovementStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Стратегия перемещения объекта в центр экрана
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
51
ProjectStormtrooper/MovementStrategy/MoveableAirplane.cs
Normal file
51
ProjectStormtrooper/MovementStrategy/MoveableAirplane.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using ProjectStormtrooper.Drawnings;
|
||||
|
||||
namespace ProjectStormtrooper.MovementStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Класс-реализация IMoveableObject с использованием DrawningCar
|
||||
/// </summary>
|
||||
public class MoveableAirplane : IMoveableObject
|
||||
{
|
||||
private DrawningAirplane? _drawningairplane;
|
||||
public MoveableAirplane(DrawningAirplane? drawningairplane)
|
||||
{
|
||||
_drawningairplane = drawningairplane;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_drawningairplane == null || _drawningairplane.EntityAirplane == null || !_drawningairplane.GetPosX.HasValue || !_drawningairplane.GetPosY.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_drawningairplane.GetPosX.Value, _drawningairplane.GetPosY.Value, _drawningairplane.GetWidth, _drawningairplane.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_drawningairplane?.EntityAirplane?.Step ?? 0);
|
||||
public bool TryMoveObject(MovementDirection direction)
|
||||
{
|
||||
if (_drawningairplane == null || _drawningairplane.EntityAirplane == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return _drawningairplane.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,
|
||||
};
|
||||
}
|
||||
}
|
24
ProjectStormtrooper/MovementStrategy/MovementDirection.cs
Normal file
24
ProjectStormtrooper/MovementStrategy/MovementDirection.cs
Normal file
@ -0,0 +1,24 @@
|
||||
namespace ProjectStormtrooper.MovementStrategy;
|
||||
|
||||
public enum MovementDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
}
|
72
ProjectStormtrooper/MovementStrategy/ObjectParametrs.cs
Normal file
72
ProjectStormtrooper/MovementStrategy/ObjectParametrs.cs
Normal file
@ -0,0 +1,72 @@
|
||||
namespace ProjectStormtrooper.MovementStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Параметры-координаты объекта
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
28
ProjectStormtrooper/MovementStrategy/StretegyStatus.cs
Normal file
28
ProjectStormtrooper/MovementStrategy/StretegyStatus.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectStormtrooper.MovementStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Статус выполнения операции перемещения
|
||||
/// </summary>
|
||||
public enum StrategyStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Все готово к началу
|
||||
/// </summary>
|
||||
NotInit,
|
||||
|
||||
/// <summary>
|
||||
/// Выполняется
|
||||
/// </summary>
|
||||
InProgress,
|
||||
|
||||
/// <summary>
|
||||
/// Завершено
|
||||
/// </summary>
|
||||
Finish
|
||||
}
|
17
ProjectStormtrooper/Program.cs
Normal file
17
ProjectStormtrooper/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace ProjectStormtrooper
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormAirplaneCollection());
|
||||
}
|
||||
}
|
||||
}
|
26
ProjectStormtrooper/ProjectStormtrooper.csproj
Normal file
26
ProjectStormtrooper/ProjectStormtrooper.csproj
Normal file
@ -0,0 +1,26 @@
|
||||
<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>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
103
ProjectStormtrooper/Properties/Resources.Designer.cs
generated
Normal file
103
ProjectStormtrooper/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ProjectStormtrooper.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("ProjectStormtrooper.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowDown {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowLeft {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowRight {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowUp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
ProjectStormtrooper/Properties/Resources.resx
Normal file
133
ProjectStormtrooper/Properties/Resources.resx
Normal file
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowDown.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowLeft.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowRight.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowUp.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
ProjectStormtrooper/Resources/arrowDown.jpg
Normal file
BIN
ProjectStormtrooper/Resources/arrowDown.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
BIN
ProjectStormtrooper/Resources/arrowLeft.jpg
Normal file
BIN
ProjectStormtrooper/Resources/arrowLeft.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
BIN
ProjectStormtrooper/Resources/arrowRight.jpg
Normal file
BIN
ProjectStormtrooper/Resources/arrowRight.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
BIN
ProjectStormtrooper/Resources/arrowUp.jpg
Normal file
BIN
ProjectStormtrooper/Resources/arrowUp.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
46
Projectc/Projectc/Form1.Designer.cs
generated
46
Projectc/Projectc/Form1.Designer.cs
generated
@ -1,46 +0,0 @@
|
||||
namespace Projectc
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
SuspendLayout();
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Name = "Form1";
|
||||
Text = "Form1";
|
||||
Load += Form1_Load;
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
namespace Projectc
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
namespace Projectc
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +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>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user