Лабораторная работа№3
This commit is contained in:
parent
bf7cfe1f84
commit
26e0d00ce5
@ -0,0 +1,116 @@
|
|||||||
|
using ProjectAirFighter.CollectionGenericObject;
|
||||||
|
using ProjectAirFighter.Drawning;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAirFighter.CollectionGenericObjects;
|
||||||
|
|
||||||
|
public abstract class AbstractCompany
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Размер места(ширина)
|
||||||
|
/// </summary>
|
||||||
|
public readonly int _placeSizeWidth = 140;
|
||||||
|
/// <summary>
|
||||||
|
/// Размер места(высота)
|
||||||
|
/// </summary>
|
||||||
|
public readonly int _placeSizeHeight = 160;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ширина окна
|
||||||
|
/// </summary>
|
||||||
|
protected readonly int _pictureWidth;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Высота окна
|
||||||
|
/// </summary>
|
||||||
|
protected readonly int _pictureHeight;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Коллекция военных самолетов
|
||||||
|
/// </summary>
|
||||||
|
protected ICollectionGeneticObjects<DrawningWarPlane> _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, ICollectionGeneticObjects<DrawningWarPlane> collection)
|
||||||
|
{
|
||||||
|
_pictureWidth = picWidth;
|
||||||
|
_pictureHeight = picHeight;
|
||||||
|
_collection = collection;
|
||||||
|
_collection.SetMaxCount = GetMaxCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Перегрузка оператора сложения для класса
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="company"></param>
|
||||||
|
/// <param name="warPlane"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int operator +(AbstractCompany company, DrawningWarPlane warPlane)
|
||||||
|
{
|
||||||
|
return company._collection.Insert(warPlane);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Перегрузка оператора удаление для класса
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="company"></param>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DrawningWarPlane operator -(AbstractCompany company, int position)
|
||||||
|
{
|
||||||
|
return company._collection.Remove(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение случайного объекта из коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public DrawningWarPlane? 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)
|
||||||
|
{
|
||||||
|
DrawningWarPlane? 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,53 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAirFighter.CollectionGenericObject;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Интерфейс описания действий для набора хранимых объектов
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
public interface ICollectionGeneticObjects<T>
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Колличество объектов в коллекции
|
||||||
|
/// </summary>
|
||||||
|
int Count { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///Установка максимального количества элементов
|
||||||
|
/// </summary>
|
||||||
|
int SetMaxCount { set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление объекта в коллекцию
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">Добавляемы объект</param>
|
||||||
|
/// <returns>true - вставка прошла успешно, false - вставка не удалась</returns>
|
||||||
|
int Insert(T obj);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление объекта в коллекцию на конкретную позицию
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">Добавляемы объект</param>
|
||||||
|
/// <param name="position">Позиция</param>
|
||||||
|
/// <returns>true - вставка прошла успешно, false - вставка не удалась</returns>
|
||||||
|
int Insert(T obj, int position);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление объекта из коллекции с конкретной позиции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position">Позиция</param>
|
||||||
|
/// <returns>true - удаление прошло успешно, false - удаление не удалось</returns>
|
||||||
|
T? Remove(int position);
|
||||||
|
/// <summary>
|
||||||
|
/// Получение объекта по позции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
T? Get(int position);
|
||||||
|
}
|
@ -0,0 +1,105 @@
|
|||||||
|
using ProjectAirFighter.CollectionGenericObject;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAirFighter.CollectionGenericObjects;
|
||||||
|
/// <summary>
|
||||||
|
/// Параметризованный набор объектов
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
|
||||||
|
public class MassiveGenericObjects<T> : ICollectionGeneticObjects<T>
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Массив объектов, которые хроним
|
||||||
|
/// </summary>
|
||||||
|
private T[] _collection;
|
||||||
|
|
||||||
|
public int Count => _collection.Length;
|
||||||
|
|
||||||
|
public int SetMaxCount { set { if (value > 0) { _collection = new T?[value]; } } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public MassiveGenericObjects()
|
||||||
|
{
|
||||||
|
_collection = Array.Empty<T?>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public T? Get(int position)
|
||||||
|
{
|
||||||
|
if (position >= 0 && position < Count)
|
||||||
|
{
|
||||||
|
return _collection[position];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(T obj)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Count; i++)
|
||||||
|
{
|
||||||
|
if (_collection[i] == null)
|
||||||
|
{
|
||||||
|
_collection[i] = obj;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(T obj, int position)
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= Count)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (_collection[position] == null)
|
||||||
|
{
|
||||||
|
_collection[position] = obj;
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
int temp = position + 1;
|
||||||
|
while (temp < Count)
|
||||||
|
{
|
||||||
|
if (_collection[temp] == null)
|
||||||
|
{
|
||||||
|
_collection[temp] = obj;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
temp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
temp = position - 1;
|
||||||
|
while (temp > 0)
|
||||||
|
{
|
||||||
|
if (_collection[temp] == null)
|
||||||
|
{
|
||||||
|
_collection[temp] = obj;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
temp--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T? Remove(int position)
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= Count)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (_collection[position] == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
T? temp = _collection[position];
|
||||||
|
_collection[position] = null;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
using ProjectAirFighter.CollectionGenericObject;
|
||||||
|
using ProjectAirFighter.Drawning;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectAirFighter.CollectionGenericObjects;
|
||||||
|
|
||||||
|
public class WarPlaneBase : AbstractCompany
|
||||||
|
{
|
||||||
|
public WarPlaneBase(int picWidth, int picHeight, ICollectionGeneticObjects<DrawningWarPlane> collection) : base(picWidth, picHeight, collection)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void DrawBackgound(Graphics g)
|
||||||
|
{
|
||||||
|
Pen pen = new(Color.Black, 3);
|
||||||
|
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; j++)
|
||||||
|
{
|
||||||
|
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth - 20, j * _placeSizeHeight);
|
||||||
|
}
|
||||||
|
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SetObjectsPosition()
|
||||||
|
{
|
||||||
|
int width = _pictureWidth / _placeSizeWidth;
|
||||||
|
int height = _pictureHeight / _placeSizeHeight;
|
||||||
|
|
||||||
|
int curWidth = 0;
|
||||||
|
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 + 10, curHeight * _placeSizeHeight + 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curHeight < height - 1)
|
||||||
|
curHeight++;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
curHeight = 0;
|
||||||
|
curWidth++;
|
||||||
|
}
|
||||||
|
if (curHeight > height)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ public class DrawningWarPlane
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота прорисовки самолета
|
/// Высота прорисовки самолета
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _drawningWarPlaneHeight = 140;
|
private readonly int _drawningWarPlaneHeight = 140;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Координаты X объекта
|
/// Координаты X объекта
|
||||||
@ -63,7 +63,8 @@ public class DrawningWarPlane
|
|||||||
/// Ширина объекта
|
/// Ширина объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int GetWigdth => _drawningWarPlaneWidth;
|
public int GetWigdth => _drawningWarPlaneWidth;
|
||||||
private DrawningWarPlane() {
|
private DrawningWarPlane()
|
||||||
|
{
|
||||||
_pictureHeight = null;
|
_pictureHeight = null;
|
||||||
_pictureWidth = null;
|
_pictureWidth = null;
|
||||||
_startPosX = null;
|
_startPosX = null;
|
||||||
@ -76,7 +77,7 @@ public class DrawningWarPlane
|
|||||||
/// <param name="weight">Вес</param>
|
/// <param name="weight">Вес</param>
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
public DrawningWarPlane(int speed, double weight, Color bodyColor) : this()
|
public DrawningWarPlane(int speed, double weight, Color bodyColor) : this()
|
||||||
public void Init(EntityAirFighter entityAirFighter)
|
{
|
||||||
EntityWarPlane = new EntityWarPlane(speed, weight, bodyColor);
|
EntityWarPlane = new EntityWarPlane(speed, weight, bodyColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -85,14 +86,12 @@ public class DrawningWarPlane
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="drawningWarPlaneHeight">Высота прорисовки самолета</param>
|
/// <param name="drawningWarPlaneHeight">Высота прорисовки самолета</param>
|
||||||
/// <param name="drawningWarPlaneWidth">Ширина прорисовки самолета</param>
|
/// <param name="drawningWarPlaneWidth">Ширина прорисовки самолета</param>
|
||||||
public DrawningWarPlane(int drawningWarPlaneWidth,int drawningWarPlaneHeight) : this()
|
public DrawningWarPlane(int drawningWarPlaneWidth, int drawningWarPlaneHeight) : this()
|
||||||
{
|
{
|
||||||
_drawningWarPlaneWidth = drawningWarPlaneWidth;
|
_drawningWarPlaneWidth = drawningWarPlaneWidth;
|
||||||
_drawningWarPlaneHeight = drawningWarPlaneHeight;
|
_drawningWarPlaneHeight = drawningWarPlaneHeight;
|
||||||
|
|
||||||
_startPosY = null;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -100,9 +99,7 @@ public class DrawningWarPlane
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="width">Ширина поля</param>
|
/// <param name="width">Ширина поля</param>
|
||||||
/// <param name="height">Высота поля</param>
|
/// <param name="height">Высота поля</param>
|
||||||
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
|
/// <returns></returns>
|
||||||
|
|
||||||
|
|
||||||
public bool SetPictureSize(int width, int height)
|
public bool SetPictureSize(int width, int height)
|
||||||
{
|
{
|
||||||
if (width > _drawningWarPlaneWidth && height > _drawningWarPlaneHeight)
|
if (width > _drawningWarPlaneWidth && height > _drawningWarPlaneHeight)
|
||||||
@ -135,10 +132,6 @@ public class DrawningWarPlane
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка позиции
|
/// Установка позиции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -174,23 +167,25 @@ public class DrawningWarPlane
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Изменение направления перемещения
|
/// Изменение направления перемещения
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="direction">Направление</param>
|
/// <param name="direction">Направление</param>
|
||||||
/// <returns>true - перемещене выполнено, false - перемещение невозможно</returns>
|
/// <returns>true - перемещение выполнено, false - перемещение невозможно </returns>
|
||||||
public bool MoveTransport(DirectionType direction)
|
public virtual bool MoveTransport(DirectionType direction)
|
||||||
{
|
{
|
||||||
if (EntityWarPlane == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
if (EntityWarPlane == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
|
//влево
|
||||||
|
case DirectionType.Left:
|
||||||
if (_startPosX.Value - EntityWarPlane.Step > 0)
|
if (_startPosX.Value - EntityWarPlane.Step > 0)
|
||||||
if (_startPosX.Value - EntityAirFighter.Step > 0)
|
|
||||||
if (_startPosX.Value - EntityAirFighter.Step > 0)
|
|
||||||
{
|
{
|
||||||
_startPosX -= (int)EntityWarPlane.Step;
|
_startPosX -= (int)EntityWarPlane.Step;
|
||||||
}
|
}
|
||||||
@ -202,22 +197,13 @@ public class DrawningWarPlane
|
|||||||
_startPosY -= (int)EntityWarPlane.Step;
|
_startPosY -= (int)EntityWarPlane.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
// вправо
|
//вниз
|
||||||
case DirectionType.Right:
|
case DirectionType.Down:
|
||||||
//TODO прописать логику сдвига в право
|
|
||||||
|
|
||||||
if (_startPosX.Value + _drawningAirFlighterWidth + EntityAirFighter.Step < _pictureWidth)
|
|
||||||
{
|
|
||||||
|
|
||||||
_startPosX += (int)EntityAirFighter.Step;
|
|
||||||
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
if (_startPosY.Value + EntityWarPlane.Step + _drawningWarPlaneWidth < _pictureHeight)
|
if (_startPosY.Value + EntityWarPlane.Step + _drawningWarPlaneWidth < _pictureHeight)
|
||||||
if (_startPosY.Value + EntityAirFighter.Step + _drawningAirFlighterHeight < _pictureHeight)
|
|
||||||
if (_startPosY.Value + EntityAirFighter.Step + _drawningAirFlighterHeight < _pictureHeight)
|
|
||||||
{
|
{
|
||||||
_startPosY += (int)EntityWarPlane.Step;
|
_startPosY += (int)EntityWarPlane.Step;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
//вправо
|
//вправо
|
||||||
case DirectionType.Right:
|
case DirectionType.Right:
|
||||||
if (_startPosX.Value + EntityWarPlane.Step + _drawningWarPlaneWidth < _pictureWidth)
|
if (_startPosX.Value + EntityWarPlane.Step + _drawningWarPlaneWidth < _pictureWidth)
|
||||||
@ -225,55 +211,18 @@ public class DrawningWarPlane
|
|||||||
_startPosX += (int)EntityWarPlane.Step;
|
_startPosX += (int)EntityWarPlane.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
return true;
|
|
||||||
return true;
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static GraphicsPath RoundedRect(Graphics g, Rectangle bounds, int radius)
|
|
||||||
{
|
|
||||||
int diameter = radius * 2;
|
|
||||||
Size size = new Size(diameter, diameter);
|
|
||||||
Rectangle arc = new Rectangle(bounds.Location, size);
|
|
||||||
GraphicsPath path = new GraphicsPath();
|
|
||||||
|
|
||||||
if (radius == 0)
|
|
||||||
{
|
|
||||||
path.AddRectangle(bounds);
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
// top left arc
|
|
||||||
path.AddArc(arc, 180, 90);
|
|
||||||
|
|
||||||
// top right arc
|
|
||||||
arc.X = bounds.Right - diameter;
|
|
||||||
path.AddArc(arc, 270, 90);
|
|
||||||
|
|
||||||
// bottom right arc
|
|
||||||
arc.Y = bounds.Bottom - diameter;
|
|
||||||
path.AddArc(arc, 0, 90);
|
|
||||||
|
|
||||||
// bottom left arc
|
|
||||||
arc.X = bounds.Left;
|
|
||||||
path.AddArc(arc, 90, 90);
|
|
||||||
|
|
||||||
g.FillPath(Brushes.Black, path);
|
|
||||||
|
|
||||||
path.CloseFigure();
|
|
||||||
return path;
|
|
||||||
public virtual void DrawTransport(Graphics g)
|
public virtual void DrawTransport(Graphics g)
|
||||||
public void DrawTransport(Graphics g)
|
|
||||||
public void DrawTransport(Graphics g)
|
|
||||||
{
|
{
|
||||||
if (EntityWarPlane == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
if (EntityWarPlane == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Pen pen = new(Color.Black, 3);
|
Pen pen = new(Color.Black, 3);
|
||||||
Pen pen_rocket = new(Color.Black);
|
Pen pen_rocket = new(Color.Black);
|
||||||
|
|
||||||
@ -305,7 +254,7 @@ public class DrawningWarPlane
|
|||||||
//залив носа
|
//залив носа
|
||||||
Brush brBlack = new SolidBrush(Color.Black);
|
Brush brBlack = new SolidBrush(Color.Black);
|
||||||
g.FillPolygon(brBlack, body);
|
g.FillPolygon(brBlack, body);
|
||||||
g.FillPolygon(brBlack, body);
|
|
||||||
//залив корпуса
|
//залив корпуса
|
||||||
Brush br = new SolidBrush(EntityWarPlane.BodyColor);
|
Brush br = new SolidBrush(EntityWarPlane.BodyColor);
|
||||||
g.FillRectangle(br, _startPosX.Value, _startPosY.Value + 60, 100, 20);
|
g.FillRectangle(br, _startPosX.Value, _startPosY.Value + 60, 100, 20);
|
||||||
@ -314,18 +263,7 @@ public class DrawningWarPlane
|
|||||||
g.FillPolygon(br, wingUpper);
|
g.FillPolygon(br, wingUpper);
|
||||||
g.FillPolygon(br, rearWingUpper);
|
g.FillPolygon(br, rearWingUpper);
|
||||||
g.FillPolygon(br, rearWingLower);
|
g.FillPolygon(br, rearWingLower);
|
||||||
g.FillPolygon(br, rearWingLower);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g.FillPolygon(brAdd, AddWingUpper);
|
|
||||||
g.FillPolygon(brAdd, AddWingLower);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g.FillPolygon(brAdd, AddWingUpper);
|
|
||||||
g.FillPolygon(brAdd, AddWingLower);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,12 +29,10 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
pictureBoxAirFighter = new PictureBox();
|
pictureBoxAirFighter = new PictureBox();
|
||||||
buttonCreate = new Button();
|
|
||||||
buttonLeft = new Button();
|
buttonLeft = new Button();
|
||||||
buttonUp = new Button();
|
buttonUp = new Button();
|
||||||
buttonDown = new Button();
|
buttonDown = new Button();
|
||||||
buttonRight = new Button();
|
buttonRight = new Button();
|
||||||
buttonCreateWarPlane = new Button();
|
|
||||||
comboBoxStrategy = new ComboBox();
|
comboBoxStrategy = new ComboBox();
|
||||||
buttonStrategyStep = new Button();
|
buttonStrategyStep = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxAirFighter).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxAirFighter).BeginInit();
|
||||||
@ -49,17 +47,6 @@
|
|||||||
pictureBoxAirFighter.TabIndex = 0;
|
pictureBoxAirFighter.TabIndex = 0;
|
||||||
pictureBoxAirFighter.TabStop = false;
|
pictureBoxAirFighter.TabStop = false;
|
||||||
//
|
//
|
||||||
// buttonCreate
|
|
||||||
//
|
|
||||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonCreate.Location = new Point(0, 522);
|
|
||||||
buttonCreate.Name = "buttonCreate";
|
|
||||||
buttonCreate.Size = new Size(232, 23);
|
|
||||||
buttonCreate.TabIndex = 1;
|
|
||||||
buttonCreate.Text = "Создать истребитель";
|
|
||||||
buttonCreate.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreate.Click += ButtonCreate_Click;
|
|
||||||
//
|
|
||||||
// buttonLeft
|
// buttonLeft
|
||||||
//
|
//
|
||||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
@ -112,17 +99,6 @@
|
|||||||
buttonRight.ClientSizeChanged += FormAirFighter_SizeChanged;
|
buttonRight.ClientSizeChanged += FormAirFighter_SizeChanged;
|
||||||
buttonRight.Click += ButtonMove_Click;
|
buttonRight.Click += ButtonMove_Click;
|
||||||
//
|
//
|
||||||
// buttonCreateWarPlane
|
|
||||||
//
|
|
||||||
buttonCreateWarPlane.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonCreateWarPlane.Location = new Point(238, 522);
|
|
||||||
buttonCreateWarPlane.Name = "buttonCreateWarPlane";
|
|
||||||
buttonCreateWarPlane.Size = new Size(232, 23);
|
|
||||||
buttonCreateWarPlane.TabIndex = 6;
|
|
||||||
buttonCreateWarPlane.Text = "Создать военный самолет";
|
|
||||||
buttonCreateWarPlane.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateWarPlane.Click += buttonCreateWarPlane_Click;
|
|
||||||
//
|
|
||||||
// comboBoxStrategy
|
// comboBoxStrategy
|
||||||
//
|
//
|
||||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
@ -150,12 +126,10 @@
|
|||||||
ClientSize = new Size(924, 557);
|
ClientSize = new Size(924, 557);
|
||||||
Controls.Add(buttonStrategyStep);
|
Controls.Add(buttonStrategyStep);
|
||||||
Controls.Add(comboBoxStrategy);
|
Controls.Add(comboBoxStrategy);
|
||||||
Controls.Add(buttonCreateWarPlane);
|
|
||||||
Controls.Add(buttonRight);
|
Controls.Add(buttonRight);
|
||||||
Controls.Add(buttonDown);
|
Controls.Add(buttonDown);
|
||||||
Controls.Add(buttonUp);
|
Controls.Add(buttonUp);
|
||||||
Controls.Add(buttonLeft);
|
Controls.Add(buttonLeft);
|
||||||
Controls.Add(buttonCreate);
|
|
||||||
Controls.Add(pictureBoxAirFighter);
|
Controls.Add(pictureBoxAirFighter);
|
||||||
Name = "FormAirFighter";
|
Name = "FormAirFighter";
|
||||||
Text = "Истребитель";
|
Text = "Истребитель";
|
||||||
@ -167,12 +141,10 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private PictureBox pictureBoxAirFighter;
|
private PictureBox pictureBoxAirFighter;
|
||||||
private Button buttonCreate;
|
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private Button buttonCreateWarPlane;
|
|
||||||
private ComboBox comboBoxStrategy;
|
private ComboBox comboBoxStrategy;
|
||||||
private Button buttonStrategyStep;
|
private Button buttonStrategyStep;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,17 @@ namespace ProjectAirFighter
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор формы
|
/// Конструктор формы
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
|
public DrawningWarPlane SetWarPlane{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_drawningWarPlane = value;
|
||||||
|
_drawningWarPlane.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
||||||
|
comboBoxStrategy.Enabled = true;
|
||||||
|
_strategy = null;
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
public FormAirFighter()
|
public FormAirFighter()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -43,45 +54,7 @@ namespace ProjectAirFighter
|
|||||||
_drawningWarPlane.DrawTransport(gr);
|
_drawningWarPlane.DrawTransport(gr);
|
||||||
pictureBoxAirFighter.Image = bmp;
|
pictureBoxAirFighter.Image = bmp;
|
||||||
}
|
}
|
||||||
private void CreateObject(string type)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case nameof(DrawningWarPlane):
|
|
||||||
_drawningWarPlane = new DrawningWarPlane(random.Next(100, 300),
|
|
||||||
random.Next(1000, 3000),
|
|
||||||
Color.FromArgb(random.Next(0, 256),
|
|
||||||
random.Next(0, 256), random.Next(0, 256)));
|
|
||||||
break;
|
|
||||||
case nameof(DrawningAirFighter):
|
|
||||||
_drawningWarPlane = new DrawningAirFighter(random.Next(100,
|
|
||||||
300), random.Next(1000, 3000),
|
|
||||||
Color.FromArgb(random.Next(0, 256),
|
|
||||||
random.Next(0, 256), random.Next(0, 256)),
|
|
||||||
Color.FromArgb(random.Next(0, 256),
|
|
||||||
random.Next(0, 256), random.Next(0, 256)),
|
|
||||||
Convert.ToBoolean(random.Next(0, 2)),
|
|
||||||
Convert.ToBoolean(random.Next(0, 2)));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_drawningWarPlane.SetPictureSize(pictureBoxAirFighter.Width,
|
|
||||||
pictureBoxAirFighter.Height);
|
|
||||||
_drawningWarPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
|
||||||
_strategy = null;
|
|
||||||
comboBoxStrategy.Enabled = true;
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CreateObject(nameof(DrawningAirFighter));
|
|
||||||
}
|
|
||||||
private void buttonCreateWarPlane_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CreateObject(nameof(DrawningWarPlane));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
168
ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.Designer.cs
generated
Normal file
168
ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.Designer.cs
generated
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
namespace ProjectAirFighter
|
||||||
|
{
|
||||||
|
partial class FormWarPlaneCollection
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
button1 = new Button();
|
||||||
|
buttonGoToCheck = new Button();
|
||||||
|
buttonRemove = new Button();
|
||||||
|
maskedTextBoxPosition = new MaskedTextBox();
|
||||||
|
buttonAddAirFighter = new Button();
|
||||||
|
buttonAddWarPlane = new Button();
|
||||||
|
comboBoxSelectorCompany = new ComboBox();
|
||||||
|
pictureBox = new PictureBox();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(button1);
|
||||||
|
groupBox1.Controls.Add(buttonGoToCheck);
|
||||||
|
groupBox1.Controls.Add(buttonRemove);
|
||||||
|
groupBox1.Controls.Add(maskedTextBoxPosition);
|
||||||
|
groupBox1.Controls.Add(buttonAddAirFighter);
|
||||||
|
groupBox1.Controls.Add(buttonAddWarPlane);
|
||||||
|
groupBox1.Controls.Add(comboBoxSelectorCompany);
|
||||||
|
groupBox1.Dock = DockStyle.Right;
|
||||||
|
groupBox1.Location = new Point(626, 0);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Size = new Size(174, 450);
|
||||||
|
groupBox1.TabIndex = 0;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "Инструменты";
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
button1.Location = new Point(6, 400);
|
||||||
|
button1.Name = "button1";
|
||||||
|
button1.Size = new Size(162, 44);
|
||||||
|
button1.TabIndex = 6;
|
||||||
|
button1.Text = "Обновить";
|
||||||
|
button1.UseVisualStyleBackColor = true;
|
||||||
|
button1.Click += ButtonRefresh_Click;
|
||||||
|
//
|
||||||
|
// buttonGoToCheck
|
||||||
|
//
|
||||||
|
buttonGoToCheck.Location = new Point(6, 326);
|
||||||
|
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||||
|
buttonGoToCheck.Size = new Size(162, 44);
|
||||||
|
buttonGoToCheck.TabIndex = 5;
|
||||||
|
buttonGoToCheck.Text = "Передать на тест";
|
||||||
|
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||||
|
buttonGoToCheck.Click += ButtonGoToCheck_Click;
|
||||||
|
//
|
||||||
|
// buttonRemove
|
||||||
|
//
|
||||||
|
buttonRemove.Location = new Point(6, 249);
|
||||||
|
buttonRemove.Name = "buttonRemove";
|
||||||
|
buttonRemove.Size = new Size(162, 44);
|
||||||
|
buttonRemove.TabIndex = 4;
|
||||||
|
buttonRemove.Text = "Удалить самолет";
|
||||||
|
buttonRemove.UseVisualStyleBackColor = true;
|
||||||
|
buttonRemove.Click += ButtonRemove_Click;
|
||||||
|
//
|
||||||
|
// maskedTextBoxPosition
|
||||||
|
//
|
||||||
|
maskedTextBoxPosition.Location = new Point(6, 220);
|
||||||
|
maskedTextBoxPosition.Mask = "00";
|
||||||
|
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
|
maskedTextBoxPosition.Size = new Size(162, 23);
|
||||||
|
maskedTextBoxPosition.TabIndex = 3;
|
||||||
|
maskedTextBoxPosition.ValidatingType = typeof(int);
|
||||||
|
//
|
||||||
|
// buttonAddAirFighter
|
||||||
|
//
|
||||||
|
buttonAddAirFighter.Location = new Point(6, 130);
|
||||||
|
buttonAddAirFighter.Name = "buttonAddAirFighter";
|
||||||
|
buttonAddAirFighter.Size = new Size(162, 44);
|
||||||
|
buttonAddAirFighter.TabIndex = 2;
|
||||||
|
buttonAddAirFighter.Text = "Добавление истребителя";
|
||||||
|
buttonAddAirFighter.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddAirFighter.Click += ButtonAddAirFighter_Click;
|
||||||
|
//
|
||||||
|
// buttonAddWarPlane
|
||||||
|
//
|
||||||
|
buttonAddWarPlane.Location = new Point(6, 72);
|
||||||
|
buttonAddWarPlane.Name = "buttonAddWarPlane";
|
||||||
|
buttonAddWarPlane.Size = new Size(162, 52);
|
||||||
|
buttonAddWarPlane.TabIndex = 1;
|
||||||
|
buttonAddWarPlane.Text = "Добавление военного самолета";
|
||||||
|
buttonAddWarPlane.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddWarPlane.Click += ButtonAddWarPlane_Click;
|
||||||
|
//
|
||||||
|
// 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(6, 22);
|
||||||
|
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||||
|
comboBoxSelectorCompany.Size = new Size(162, 23);
|
||||||
|
comboBoxSelectorCompany.TabIndex = 0;
|
||||||
|
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
|
||||||
|
//
|
||||||
|
// pictureBox
|
||||||
|
//
|
||||||
|
pictureBox.Dock = DockStyle.Fill;
|
||||||
|
pictureBox.Location = new Point(0, 0);
|
||||||
|
pictureBox.Name = "pictureBox";
|
||||||
|
pictureBox.Size = new Size(626, 450);
|
||||||
|
pictureBox.TabIndex = 1;
|
||||||
|
pictureBox.TabStop = false;
|
||||||
|
//
|
||||||
|
// FormWarPlaneCollection
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(pictureBox);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
|
Name = "FormWarPlaneCollection";
|
||||||
|
Text = "Коллекция военных самолетов";
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
groupBox1.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private ComboBox comboBoxSelectorCompany;
|
||||||
|
private MaskedTextBox maskedTextBoxPosition;
|
||||||
|
private Button buttonAddAirFighter;
|
||||||
|
private Button buttonAddWarPlane;
|
||||||
|
private PictureBox pictureBox;
|
||||||
|
private Button buttonRemove;
|
||||||
|
private Button buttonGoToCheck;
|
||||||
|
private Button button1;
|
||||||
|
}
|
||||||
|
}
|
154
ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.cs
Normal file
154
ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.cs
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
using ProjectAirFighter.CollectionGenericObjects;
|
||||||
|
using ProjectAirFighter.Drawning;
|
||||||
|
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 ProjectAirFighter;
|
||||||
|
|
||||||
|
public partial class FormWarPlaneCollection : Form
|
||||||
|
{
|
||||||
|
private AbstractCompany? _company;
|
||||||
|
public FormWarPlaneCollection()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
switch (comboBoxSelectorCompany.Text)
|
||||||
|
{
|
||||||
|
case "Хранилище":
|
||||||
|
_company = new WarPlaneBase(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningWarPlane>());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateObject(string type)
|
||||||
|
{
|
||||||
|
if (_company == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Random random = new();
|
||||||
|
DrawningWarPlane drawningWarPlane;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case nameof(DrawningWarPlane):
|
||||||
|
drawningWarPlane = new DrawningWarPlane(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
|
||||||
|
break;
|
||||||
|
case nameof(DrawningAirFighter):
|
||||||
|
drawningWarPlane = new DrawningAirFighter(random.Next(100, 300), random.Next(1000, 3000),
|
||||||
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||||
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||||
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_company + drawningWarPlane != -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBox.Image = _company.Show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAddWarPlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningWarPlane));
|
||||||
|
|
||||||
|
private void ButtonAddAirFighter_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAirFighter));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение цвета
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="random">Генератор случайных чисел</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static Color GetColor(Random random)
|
||||||
|
{
|
||||||
|
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0,
|
||||||
|
256), random.Next(0, 256));
|
||||||
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonRemove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawningWarPlane? warPlane = null;
|
||||||
|
|
||||||
|
int counter = 100;
|
||||||
|
while(warPlane == null)
|
||||||
|
{
|
||||||
|
warPlane = _company.GetRandomObject();
|
||||||
|
counter--;
|
||||||
|
if (counter <= 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (warPlane == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FormAirFighter form = new()
|
||||||
|
{
|
||||||
|
SetWarPlane = warPlane
|
||||||
|
};
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonRefresh_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_company == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pictureBox.Image = _company.Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
120
ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.resx
Normal file
120
ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.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>
|
@ -11,7 +11,7 @@ namespace ProjectAirFighter
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormAirFighter());
|
Application.Run(new FormWarPlaneCollection());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user