5 Commits

Author SHA1 Message Date
a18c598b8d убраны комменты 2024-04-04 10:48:41 +04:00
a8591777d9 финал 2024-04-03 16:28:15 +04:00
8c4a09a8b5 Внесены изменения в именах 2024-04-01 00:59:32 +04:00
9654506023 Компания 2024-03-26 00:09:01 +04:00
d39c9e27bc Коллекция объектов 2024-03-15 20:28:52 +04:00
22 changed files with 135 additions and 1540 deletions

View File

@@ -48,7 +48,7 @@ public abstract class AbstractCompany
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = collection;
_collection.MaxCount = GetMaxCount;
_collection.SetMaxCount = GetMaxCount;
}
/// <summary>

View File

@@ -3,7 +3,7 @@
namespace ProjectAirFighter.CollectionGenericObjects;
/// <summary>
/// Реализация абстрактной компании - ангар
/// Реализация абстрактной компании - каршеринг
/// </summary>
public class Angar : AbstractCompany
{

View File

@@ -1,22 +0,0 @@
namespace ProjectAirFighter.CollectionGenericObjects;
/// <summary>
/// Тип коллекции
/// </summary>
public enum CollectionType
{
/// <summary>
/// Неопределено
/// </summary>
None = 0,
/// <summary>
/// Массив
/// </summary>
Massive = 1,
/// <summary>
/// Список
/// </summary>
List = 2
}

View File

@@ -1,6 +1,4 @@
using ProjectAirFighter.Drawnings;
namespace ProjectAirFighter.CollectionGenericObjects;
namespace ProjectAirFighter.CollectionGenericObjects;
/// <summary>
/// Интерфейс описания действий для набора хранимых объектов
@@ -17,7 +15,7 @@ public interface ICollectionGenericObjects<T>
/// <summary>
/// Установка максимального количества элементов
/// </summary>
int MaxCount { get; set; }
int SetMaxCount { set; }
/// <summary>
/// Добавление объекта в коллекцию
@@ -47,15 +45,4 @@ public interface ICollectionGenericObjects<T>
/// <param name="position">Позиция</param>
/// <returns>Объект</returns>
T? Get(int position);
/// <summary>
/// Получение типа коллекции
/// </summary>
CollectionType GetCollectionType { get; }
/// <summary>
/// Получение объектов коллекции по одному
/// </summary>
/// <returns>Поэлементый вывод элементов коллекции</returns>
IEnumerable<T?> GetItems();
}

View File

@@ -1,83 +0,0 @@
namespace ProjectAirFighter.CollectionGenericObjects;
/// <summary>
/// Параметризованный набор объектов
/// </summary>
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
public class ListGenericObjects<T> : ICollectionGenericObjects<T>
where T : class
{
/// <summary>
/// Список объектов, которые храним
/// </summary>
private readonly List<T?> _collection;
/// <summary>
/// Максимально допустимое число объектов в списке
/// </summary>
private int _maxCount;
public int Count => _collection.Count;
public int MaxCount
{
get
{
return Count;
}
set
{
if (value > 0)
{
_maxCount = value;
}
}
}
public CollectionType GetCollectionType => CollectionType.List;
/// <summary>
/// Конструктор
/// </summary>
public ListGenericObjects()
{
_collection = new();
}
public T? Get(int position)
{
if (position >= Count || position < 0) return null;
return _collection[position];
}
public int Insert(T obj)
{
if (Count + 1 > _maxCount) return -1;
_collection.Add(obj);
return Count;
}
public int Insert(T obj, int position)
{
if (Count + 1 > _maxCount) return -1;
if (position < 0 || position > Count) return -1;
_collection.Insert(position, obj);
return 1;
}
public T? Remove(int position)
{
if (position < 0 || position > Count) return null;
T? pos = _collection[position];
_collection.RemoveAt(position);
return pos;
}
public IEnumerable<T?> GetItems()
{
for (int i = 0; i < _collection.Count; ++i)
{
yield return _collection[i];
}
}
}

View File

@@ -14,12 +14,8 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
public int Count => _collection.Length;
public int MaxCount
public int SetMaxCount
{
get
{
return _collection.Length;
}
set
{
if (value > 0)
@@ -36,8 +32,6 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
}
}
public CollectionType GetCollectionType => CollectionType.Massive;
/// <summary>
/// Конструктор
/// </summary>
@@ -104,19 +98,11 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
public T? Remove(int position)
{
if (position >= _collection.Length || position < 0)
{
return null;
{
return null;
}
T obj = _collection[position];
_collection[position] = null;
return obj;
}
public IEnumerable<T?> GetItems()
{
for (int i = 0; i < _collection.Length; ++i)
{
yield return _collection[i];
}
}
}

View File

@@ -1,231 +0,0 @@
using ProjectAirFighter.Drawnings;
using System.Text;
namespace ProjectAirFighter.CollectionGenericObjects;
/// <summary>
/// Класс-хранилище коллекций
/// </summary>
/// <typeparam name="T"></typeparam>
public class StorageCollection<T>
where T : DrawningMilitaryAircraft
{
/// <summary>
/// Словарь (хранилище) с коллекциями
/// </summary>
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
/// <summary>
/// Возвращение списка названий коллекций
/// </summary>
public List<string> Keys => _storages.Keys.ToList();
/// Ключевое слово, с которого должен начинаться файл
/// </summary>
private readonly string _collectionKey = "CollectionsStorage";
/// <summary>
/// Разделитель для записи ключа и значения элемента словаря
/// </summary>
private readonly string _separatorForKeyValue = "|";
/// <summary>
/// Разделитель для записей коллекции данных в файл
/// </summary>
private readonly string _separatorItems = ";";
/// <summary>
/// Конструктор
/// </summary>
public StorageCollection()
{
_storages = new Dictionary<string, ICollectionGenericObjects<T>>(); //вот тут какое-то свойство
}
/// <summary>
/// Добавление коллекции в хранилище
/// </summary>
/// <param name="name">Название коллекции</param>
/// <param name="collectionType">тип коллекции</param>
public void AddCollection(string name, CollectionType collectionType)
{
if (name == null || _storages.ContainsKey(name)) { return; }
switch (collectionType)
{
case CollectionType.None:
return;
case CollectionType.Massive:
_storages[name] = new MassiveGenericObjects<T>();
return;
case CollectionType.List:
_storages[name] = new ListGenericObjects<T>();
return;
}
}
/// <summary>
/// Удаление коллекции
/// </summary>
/// <param name="name">Название коллекции</param>
public void DelCollection(string name)
{
if (_storages.ContainsKey(name))
_storages.Remove(name);
}
/// <summary>
/// Доступ к коллекции
/// </summary>
/// <param name="name">Название коллекции</param>
/// <returns></returns>
public ICollectionGenericObjects<T>? this[string name]
{
get
{
if (name == null || !_storages.ContainsKey(name)) { return null; }
return _storages[name];
}
}
/// <summary>
/// Сохранение информации по военным самолётам в хранилище в файл
/// </summary>
/// <param name="filename">Путь и имя файла</param>
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
public bool SaveData(string filename)
{
if (_storages.Count == 0)
{
return false;
}
if (File.Exists(filename))
{
File.Delete(filename);
}
using (StreamWriter writer = new StreamWriter(filename))
{
writer.Write(_collectionKey);
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
{
StringBuilder sb = new();
sb.Append(Environment.NewLine);
if (value.Value.Count == 0)
{
continue;
}
sb.Append(value.Key);
sb.Append(_separatorForKeyValue);
sb.Append(value.Value.GetCollectionType);
sb.Append(_separatorForKeyValue);
sb.Append(value.Value.MaxCount);
sb.Append(_separatorForKeyValue);
foreach (T? item in value.Value.GetItems())
{
string data = item?.GetDataForSave() ?? string.Empty;
if (string.IsNullOrEmpty(data))
{
continue;
}
sb.Append(data);
sb.Append(_separatorItems);
}
writer.Write(sb);
}
}
return true;
}
/// <summary>
/// Загрузка информации по военным самолётам в хранилище из файла
/// </summary>
/// <param name="filename">Путь и имя файла</param>
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
public bool LoadData(string filename)
{
if (!File.Exists(filename))
{
return false;
}
using (StreamReader fs = File.OpenText(filename))
{
string str = fs.ReadLine();
if (str == null || str.Length == 0)
{
return false;
}
if (!str.StartsWith(_collectionKey))
{
return false;
}
_storages.Clear();
string strs = "";
while ((strs = fs.ReadLine()) != null)
{
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
if (record.Length != 4)
{
continue;
}
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType);
if (collection == null)
{
return false;
}
collection.MaxCount = Convert.ToInt32(record[2]);
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set)
{
if (elem?.CreateDrawningMilitaryAircraft() is T militaryAircraft)
{
if (collection.Insert(militaryAircraft) == -1)
{
return false;
}
}
}
_storages.Add(record[0], collection);
}
return true;
}
}
/// <summary>
/// Создание коллекции по типу
/// </summary>
/// <param name="collectionType"></param>
/// <returns></returns>
///
private static ICollectionGenericObjects<T>? CreateCollection(CollectionType collectionType)
{
return collectionType switch
{
CollectionType.Massive => new MassiveGenericObjects<T>(),
CollectionType.List => new ListGenericObjects<T>(),
_ => null,
};
}
}

View File

@@ -17,40 +17,24 @@ public class DrawningAirFighter : DrawningMilitaryAircraft
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="wings">Признак наличия доп крыльев</param>
/// <param name="rockets">Признак наличия ракет</param>
public DrawningAirFighter(int speed, double weight, Color bodyColor, Color additionalColor, bool wings, bool rockets) : base(70, 70)
public DrawningAirFighter (int speed, double weight, Color bodyColor, Color additionalColor, bool wings, bool rockets) : base (70, 70)
{
EntityMilitaryAircraft = new EntityAirFighter(speed, weight, bodyColor, additionalColor, wings, rockets);
}
/// <summary>
/// Конструктор
/// </summary>
public DrawningAirFighter(EntityAirFighter militaryAircraft) : base(110, 60)
{
EntityMilitaryAircraft = new EntityAirFighter(militaryAircraft.Speed, militaryAircraft.Weight, militaryAircraft.BodyColor, militaryAircraft.AdditionalColor, militaryAircraft.Wings, militaryAircraft.Rockets);
}
//public DrawningAirFighter(EntityMilitaryAircraft entityMilitaryAircraft) : base(110, 60)
//{
// if (entityMilitaryAircraft != null)
// {
// EntityMilitaryAircraft = entityMilitaryAircraft;
// }
//}
public override void DrawTransport(Graphics g)
{
if (EntityMilitaryAircraft == null || EntityMilitaryAircraft is not EntityAirFighter airFighter || !_startPosX.HasValue || !_startPosY.HasValue)
if (EntityMilitaryAircraft == null || EntityMilitaryAircraft is not EntityAirFighter militaryAircraftFighter || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(airFighter.AdditionalColor);
Brush additionalBrush = new SolidBrush(militaryAircraftFighter.AdditionalColor);
base.DrawTransport(g);
if (airFighter.Wings)
if (militaryAircraftFighter.Wings)
{
Point wings1 = new Point(_startPosX.Value + 45, _startPosY.Value + 30);
Point wings2 = new Point(_startPosX.Value + 45, _startPosY.Value + 15);
@@ -69,7 +53,7 @@ public class DrawningAirFighter : DrawningMilitaryAircraft
g.DrawPolygon(pen, DownWing);
}
if (airFighter.Rockets)
if (militaryAircraftFighter.Rockets)
{
Point rocket1 = new Point(_startPosX.Value + 40, _startPosY.Value + 5);
Point rocket2 = new Point(_startPosX.Value + 15, _startPosY.Value + 5);

View File

@@ -23,22 +23,22 @@ public class DrawningMilitaryAircraft
private int? _pictureHeight;
/// <summary>
/// Левая координата прорисовки самолёта
/// Левая координата прорисовки самолёта
/// </summary>
protected int? _startPosX;
/// <summary>
/// Верхняя кооридната прорисовки военного самолёта
/// Верхняя кооридната прорисовки самолёта
/// </summary>
protected int? _startPosY;
/// <summary>
/// Ширина прорисовки военного самолёта
/// Ширина прорисовки самолёта
/// </summary>
private readonly int _drawningMilitaryAircraftWidth = 70;
/// <summary>
/// Высота прорисовки военного самолёта
/// Высота прорисовки самолёта
/// </summary>
private readonly int _drawningMilitaryAircraftHeight = 70;
@@ -79,26 +79,17 @@ public class DrawningMilitaryAircraft
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
public DrawningMilitaryAircraft(int speed, double weight, Color bodyColor) : this()
public DrawningMilitaryAircraft (int speed, double weight, Color bodyColor) : this()
{
EntityMilitaryAircraft = new EntityMilitaryAircraft(speed, weight, bodyColor);
}
/// <summary>
/// Конструктор
/// </summary>
/// <param name="militaryAircraft">Класс-сущность</param>
public DrawningMilitaryAircraft(EntityMilitaryAircraft militaryAircraft) : this()
{
EntityMilitaryAircraft = militaryAircraft;
}
/// <summary>
/// Конструктор для наследников
/// </summary>
/// <param name="drawningCarWidth">Ширина прорисовки военного самолёта</param>
/// <param name="drawningCarHeight">Высота прорисовки военного самолёта</param>
protected DrawningMilitaryAircraft(int drawningMilitaryAircraftWidth, int drawningMilitaryAircraftHeight) : this()
/// <param name="drawningMilitaryAircraftWidth">Ширина прорисовки самолёта</param>
/// <param name="drawningMilitaryAircraftHeight">Высота прорисовки самолёта</param>
protected DrawningMilitaryAircraft(int drawningMilitaryAircraftWidth, int drawningMilitaryAircraftHeight) : this()
{
_drawningMilitaryAircraftWidth = drawningMilitaryAircraftWidth;
_drawningMilitaryAircraftHeight = drawningMilitaryAircraftHeight;

View File

@@ -1,54 +0,0 @@
using ProjectAirFighter.Entities;
namespace ProjectAirFighter.Drawnings;
/// <summary>
/// Расширение для класса EntityCar
/// </summary>
public static class ExtentionDrawningMilitaryAircraft
{
/// <summary>
/// Разделитель для записи информации по объекту в файл
/// </summary>
private static readonly string _separatorForObject = ":";
/// <summary>
/// Создание объекта из строки
/// </summary>
/// <param name="info">Строка с данными для создания объекта</param>
/// <returns>Объект</returns>
public static DrawningMilitaryAircraft? CreateDrawningMilitaryAircraft(this string info)
{
string[] strs = info.Split(_separatorForObject);
EntityMilitaryAircraft? militaryAircraft = EntityAirFighter.CreateEntityAirFighter(strs);
if (militaryAircraft != null)
{
return new DrawningAirFighter((EntityAirFighter)militaryAircraft);
}
militaryAircraft = EntityMilitaryAircraft.CreateEntityMilitaryAircraft(strs);
if (militaryAircraft != null)
{
return new DrawningMilitaryAircraft(militaryAircraft);
}
return null;
}
/// <summary>
/// Получение данных для сохранения в файл
/// </summary>
/// <param name="drawningCar">Сохраняемый объект</param>
/// <returns>Строка с данными по объекту</returns>
public static string GetDataForSave(this DrawningMilitaryAircraft drawningMilitaryAircraft)
{
string[]? array = drawningMilitaryAircraft?.EntityMilitaryAircraft?.GetStringRepresentation();
if (array == null)
{
return string.Empty;
}
return string.Join(_separatorForObject, array);
}
}

View File

@@ -7,11 +7,6 @@ public class EntityAirFighter : EntityMilitaryAircraft
{
public Color AdditionalColor { get; private set; }
public void SetAdditionalColor(Color additionalColor)
{
AdditionalColor = additionalColor;
}
public bool Wings { get; private set; }
public bool Rockets { get; private set; }
@@ -22,24 +17,4 @@ public class EntityAirFighter : EntityMilitaryAircraft
Rockets = rockets;
Wings = wings;
}
public override string[] GetStringRepresentation()
{
return new[] { nameof(EntityAirFighter), Speed.ToString(), Weight.ToString(), BodyColor.Name, Wings.ToString(), Rockets.ToString(), AdditionalColor.Name };
}
/// <summary>
/// Создание объекта из массива строк
/// </summary>
/// <param name="strs"></param>
/// <returns></returns>
public static EntityAirFighter? CreateEntityAirFighter(string[] strs)
{
if (strs.Length != 8 || strs[0] != nameof(EntityAirFighter))
{
return null;
}
return new EntityAirFighter(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]), Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]));
}
}

View File

@@ -11,48 +11,19 @@ public class EntityMilitaryAircraft
public Color BodyColor { get; private set; }
public void SetBodyColor(Color bodyColor)
{
BodyColor = bodyColor;
}
public double Step => Speed * 100 / Weight;
/// <summary>
/// Конструктор сущности
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес автомобиля</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
public EntityMilitaryAircraft(int speed, double weight, Color bodyColor)
public EntityMilitaryAircraft (int speed, double weight, Color bodyColor)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
}
/// <summary>
/// Получение строк со значениями свойств объекта класса-сущности
/// </summary>
/// <returns></returns>
public virtual string[] GetStringRepresentation()
{
return new[] { nameof(EntityMilitaryAircraft), Speed.ToString(), Weight.ToString(), BodyColor.Name };
}
/// <summary>
/// Создание объекта из массива строк
/// </summary>
/// <param name="strs"></param>
/// <returns></returns>
public static EntityMilitaryAircraft? CreateEntityMilitaryAircraft(string[] strs)
{
if (strs.Length != 4 || strs[0] != nameof(EntityMilitaryAircraft))
{
return null;
}
return new EntityMilitaryAircraft(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
}
}

View File

@@ -28,7 +28,7 @@
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
name/value pmilitaryAircrafts.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support

View File

@@ -29,70 +29,41 @@
private void InitializeComponent()
{
groupBoxTools = new GroupBox();
panelCompanyTools = new Panel();
buttonRefresh = new Button();
buttonGoToCheck = new Button();
buttonRemoveMilitaryAircraft = new Button();
buttonAddMilitaryAircraft = new Button();
buttonRemoveAir = new Button();
maskedTextBoxPosition = new MaskedTextBox();
buttonCreateCompany = new Button();
panelStorage = new Panel();
buttonCollectionDel = new Button();
listBoxCollection = new ListBox();
buttonCollectionAdd = new Button();
textBoxCollectionName = new TextBox();
radioButtonMassive = new RadioButton();
radioButtonList = new RadioButton();
labelCollectionName = new Label();
buttonAddAirFighter = new Button();
buttonAddAir = new Button();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
menuStrip = new MenuStrip();
файлToolStripMenuItem = new ToolStripMenuItem();
saveToolStripMenuItem = new ToolStripMenuItem();
loadToolStripMenuItem = new ToolStripMenuItem();
saveFileDialog = new SaveFileDialog();
openFileDialog = new OpenFileDialog();
groupBoxTools.SuspendLayout();
panelCompanyTools.SuspendLayout();
panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
menuStrip.SuspendLayout();
SuspendLayout();
//
// groupBoxTools
//
groupBoxTools.Controls.Add(panelCompanyTools);
groupBoxTools.Controls.Add(buttonCreateCompany);
groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(buttonRefresh);
groupBoxTools.Controls.Add(buttonGoToCheck);
groupBoxTools.Controls.Add(buttonRemoveAir);
groupBoxTools.Controls.Add(maskedTextBoxPosition);
groupBoxTools.Controls.Add(buttonAddAirFighter);
groupBoxTools.Controls.Add(buttonAddAir);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(744, 28);
groupBoxTools.Location = new Point(594, 0);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(206, 639);
groupBoxTools.Size = new Size(206, 450);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Controls.Add(buttonRemoveMilitaryAircraft);
panelCompanyTools.Controls.Add(buttonAddMilitaryAircraft);
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
panelCompanyTools.Dock = DockStyle.Bottom;
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(3, 357);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(200, 279);
panelCompanyTools.TabIndex = 10;
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(0, 227);
buttonRefresh.Location = new Point(6, 395);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(192, 49);
buttonRefresh.Size = new Size(197, 29);
buttonRefresh.TabIndex = 7;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
@@ -101,137 +72,55 @@
// buttonGoToCheck
//
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToCheck.Location = new Point(3, 178);
buttonGoToCheck.Location = new Point(6, 328);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(192, 49);
buttonGoToCheck.Size = new Size(197, 29);
buttonGoToCheck.TabIndex = 6;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
buttonGoToCheck.Click += buttonGoToCheck_Click;
//
// buttonRemoveMilitaryAircraft
// buttonRemoveAir
//
buttonRemoveMilitaryAircraft.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveMilitaryAircraft.Location = new Point(4, 129);
buttonRemoveMilitaryAircraft.Name = "buttonRemoveMilitaryAircraft";
buttonRemoveMilitaryAircraft.Size = new Size(191, 49);
buttonRemoveMilitaryAircraft.TabIndex = 5;
buttonRemoveMilitaryAircraft.Text = "Удаление военного самолёта";
buttonRemoveMilitaryAircraft.UseVisualStyleBackColor = true;
buttonRemoveMilitaryAircraft.Click += buttonRemoveMilitaryAircraft_Click;
//
// buttonAddMilitaryAircraft
//
buttonAddMilitaryAircraft.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddMilitaryAircraft.Location = new Point(4, 3);
buttonAddMilitaryAircraft.Name = "buttonAddMilitaryAircraft";
buttonAddMilitaryAircraft.Size = new Size(191, 49);
buttonAddMilitaryAircraft.TabIndex = 1;
buttonAddMilitaryAircraft.Text = "Добавление военного самолёта";
buttonAddMilitaryAircraft.UseVisualStyleBackColor = true;
buttonAddMilitaryAircraft.Click += buttonAddMilitaryAircraft_Click;
buttonRemoveAir.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveAir.Location = new Point(5, 211);
buttonRemoveAir.Name = "buttonRemoveAir";
buttonRemoveAir.Size = new Size(197, 29);
buttonRemoveAir.TabIndex = 5;
buttonRemoveAir.Text = "Удаление самолёта";
buttonRemoveAir.UseVisualStyleBackColor = true;
buttonRemoveAir.Click += buttonRemoveAir_Click;
//
// maskedTextBoxPosition
//
maskedTextBoxPosition.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
maskedTextBoxPosition.Location = new Point(3, 96);
maskedTextBoxPosition.Location = new Point(6, 161);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
maskedTextBoxPosition.Size = new Size(192, 27);
maskedTextBoxPosition.Size = new Size(194, 27);
maskedTextBoxPosition.TabIndex = 4;
maskedTextBoxPosition.ValidatingType = typeof(int);
//
// buttonCreateCompany
// buttonAddAirFighter
//
buttonCreateCompany.Location = new Point(7, 322);
buttonCreateCompany.Name = "buttonCreateCompany";
buttonCreateCompany.Size = new Size(191, 29);
buttonCreateCompany.TabIndex = 9;
buttonCreateCompany.Text = "Создание компании";
buttonCreateCompany.UseVisualStyleBackColor = true;
buttonCreateCompany.Click += buttonCreateCompany_Click;
buttonAddAirFighter.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddAirFighter.Location = new Point(6, 103);
buttonAddAirFighter.Name = "buttonAddAirFighter";
buttonAddAirFighter.Size = new Size(197, 31);
buttonAddAirFighter.TabIndex = 2;
buttonAddAirFighter.Text = "Добавление истребителя";
buttonAddAirFighter.UseVisualStyleBackColor = true;
buttonAddAirFighter.Click += buttonAddAirFighter_Click;
//
// panelStorage
// buttonAddAir
//
panelStorage.Controls.Add(buttonCollectionDel);
panelStorage.Controls.Add(listBoxCollection);
panelStorage.Controls.Add(buttonCollectionAdd);
panelStorage.Controls.Add(textBoxCollectionName);
panelStorage.Controls.Add(radioButtonMassive);
panelStorage.Controls.Add(radioButtonList);
panelStorage.Controls.Add(labelCollectionName);
panelStorage.Dock = DockStyle.Top;
panelStorage.Location = new Point(3, 23);
panelStorage.Name = "panelStorage";
panelStorage.Size = new Size(200, 256);
panelStorage.TabIndex = 8;
//
// buttonCollectionDel
//
buttonCollectionDel.Location = new Point(6, 224);
buttonCollectionDel.Name = "buttonCollectionDel";
buttonCollectionDel.Size = new Size(189, 29);
buttonCollectionDel.TabIndex = 6;
buttonCollectionDel.Text = "Удаление коллекции";
buttonCollectionDel.UseVisualStyleBackColor = true;
buttonCollectionDel.Click += buttonCollectionDel_Click;
//
// listBoxCollection
//
listBoxCollection.FormattingEnabled = true;
listBoxCollection.ItemHeight = 20;
listBoxCollection.Location = new Point(6, 131);
listBoxCollection.Name = "listBoxCollection";
listBoxCollection.Size = new Size(189, 84);
listBoxCollection.TabIndex = 5;
//
// buttonCollectionAdd
//
buttonCollectionAdd.Location = new Point(6, 96);
buttonCollectionAdd.Name = "buttonCollectionAdd";
buttonCollectionAdd.Size = new Size(189, 29);
buttonCollectionAdd.TabIndex = 4;
buttonCollectionAdd.Text = "Добавить коллекцию";
buttonCollectionAdd.UseVisualStyleBackColor = true;
buttonCollectionAdd.Click += buttonCollectionAdd_Click;
//
// textBoxCollectionName
//
textBoxCollectionName.Location = new Point(6, 33);
textBoxCollectionName.Name = "textBoxCollectionName";
textBoxCollectionName.Size = new Size(189, 27);
textBoxCollectionName.TabIndex = 3;
//
// radioButtonMassive
//
radioButtonMassive.AutoSize = true;
radioButtonMassive.Location = new Point(6, 66);
radioButtonMassive.Name = "radioButtonMassive";
radioButtonMassive.Size = new Size(82, 24);
radioButtonMassive.TabIndex = 2;
radioButtonMassive.TabStop = true;
radioButtonMassive.Text = "Массив";
radioButtonMassive.UseVisualStyleBackColor = true;
//
// radioButtonList
//
radioButtonList.AutoSize = true;
radioButtonList.Location = new Point(115, 66);
radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(80, 24);
radioButtonList.TabIndex = 1;
radioButtonList.TabStop = true;
radioButtonList.Text = "Список";
radioButtonList.UseVisualStyleBackColor = true;
//
// labelCollectionName
//
labelCollectionName.AutoSize = true;
labelCollectionName.Location = new Point(17, 10);
labelCollectionName.Name = "labelCollectionName";
labelCollectionName.Size = new Size(158, 20);
labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции:";
buttonAddAir.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddAir.Location = new Point(6, 68);
buttonAddAir.Name = "buttonAddAir";
buttonAddAir.Size = new Size(197, 29);
buttonAddAir.TabIndex = 1;
buttonAddAir.Text = "Добавление самолёта";
buttonAddAir.UseVisualStyleBackColor = true;
buttonAddAir.Click += buttonAddAir_Click;
//
// comboBoxSelectorCompany
//
@@ -239,110 +128,46 @@
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(7, 285);
comboBoxSelectorCompany.Location = new Point(6, 26);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(193, 28);
comboBoxSelectorCompany.Size = new Size(194, 28);
comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged;
//
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 28);
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(744, 639);
pictureBox.Size = new Size(594, 450);
pictureBox.TabIndex = 3;
pictureBox.TabStop = false;
//
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(950, 28);
menuStrip.TabIndex = 4;
menuStrip.Text = "menuStrip";
//
// файлToolStripMenuItem
//
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
файлToolStripMenuItem.Name = айлToolStripMenuItem";
файлToolStripMenuItem.Size = new Size(59, 24);
файлToolStripMenuItem.Text = "Файл";
//
// saveToolStripMenuItem
//
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
saveToolStripMenuItem.Size = new Size(227, 26);
saveToolStripMenuItem.Text = "Сохранение";
saveToolStripMenuItem.Click += saveToolStripMenuItem_Click;
//
// loadToolStripMenuItem
//
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
loadToolStripMenuItem.Size = new Size(227, 26);
loadToolStripMenuItem.Text = "Загрузка";
loadToolStripMenuItem.Click += loadToolStripMenuItem_Click;
//
// saveFileDialog
//
saveFileDialog.Filter = "txt file | *.txt";
//
// openFileDialog
//
openFileDialog.Filter = "txt file | *.txt";
//
// FormMilitaryAircraftCollection
// FormAirCollection
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(950, 667);
ClientSize = new Size(800, 450);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormMilitaryAircraftCollection";
Text = "Коллекция военных самолётов";
Name = "FormAirCollection";
Text = "Коллекция самолётов";
groupBoxTools.ResumeLayout(false);
panelCompanyTools.ResumeLayout(false);
panelCompanyTools.PerformLayout();
panelStorage.ResumeLayout(false);
panelStorage.PerformLayout();
groupBoxTools.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private GroupBox groupBoxTools;
private ComboBox comboBoxSelectorCompany;
private Button buttonAddMilitaryAircraft;
private MaskedTextBox maskedTextBoxPosition;
private Button buttonAddAir;
private Button buttonAddAirFighter;
private PictureBox pictureBox;
private MaskedTextBox maskedTextBoxPosition;
private Button buttonRemoveAir;
private Button buttonRefresh;
private Button buttonGoToCheck;
private Button buttonRemoveMilitaryAircraft;
private Panel panelStorage;
private TextBox textBoxCollectionName;
private RadioButton radioButtonMassive;
private RadioButton radioButtonList;
private Label labelCollectionName;
private Button buttonCollectionDel;
private ListBox listBoxCollection;
private Button buttonCollectionAdd;
private Button buttonCreateCompany;
private Panel panelCompanyTools;
private MenuStrip menuStrip;
private ToolStripMenuItem файлToolStripMenuItem;
private ToolStripMenuItem saveToolStripMenuItem;
private ToolStripMenuItem loadToolStripMenuItem;
private SaveFileDialog saveFileDialog;
private OpenFileDialog openFileDialog;
}
}

View File

@@ -5,11 +5,6 @@ namespace ProjectAirFighter;
public partial class FormMilitaryAircraftCollection : Form
{
/// <summary>
/// Хранилише коллекций
/// </summary>
private readonly StorageCollection<DrawningMilitaryAircraft> _storageCollection;
/// <summary>
/// Компания
/// </summary>
@@ -21,7 +16,6 @@ public partial class FormMilitaryAircraftCollection : Form
public FormMilitaryAircraftCollection()
{
InitializeComponent();
_storageCollection = new();
}
/// <summary>
@@ -31,34 +25,52 @@ public partial class FormMilitaryAircraftCollection : Form
/// <param name="e"></param>
private void comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
{
panelCompanyTools.Enabled = false;
switch (comboBoxSelectorCompany.Text)
{
case "Хранилище":
_company = new Angar(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningMilitaryAircraft>());
break;
}
}
/// <summary>
/// Добавление военного самолёта
/// Добавление самолёта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonAddMilitaryAircraft_Click(object sender, EventArgs e)
{
FormMilitaryAircraftConfig form = new();
form.Show();
form.AddEvent(SetMilitaryAircraft);
}
private void buttonAddAir_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningMilitaryAircraft));
// <summary>
/// Добавление военного самолёта в коллекцию
/// <summary>
/// Добавление истребителя
/// </summary>
/// <param name="militaryAircraft"></param>
private void SetMilitaryAircraft(DrawningMilitaryAircraft? militaryAircraft)
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonAddAirFighter_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAirFighter));
private void CreateObject(string type)
{
if (_company == null || militaryAircraft == null)
if (_company == null)
{
return;
}
if (_company + militaryAircraft != -1)
Random random = new();
DrawningMilitaryAircraft drawningMilitaryAircraft;
switch (type)
{
case nameof(DrawningMilitaryAircraft):
drawningMilitaryAircraft = new DrawningMilitaryAircraft(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
break;
case nameof(DrawningAirFighter):
drawningMilitaryAircraft = new DrawningAirFighter(random.Next(100, 300), random.Next(1000, 3000),
GetColor(random), GetColor(random),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break;
default:
return;
}
if (_company + drawningMilitaryAircraft != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@@ -69,13 +81,30 @@ public partial class FormMilitaryAircraftCollection : Form
}
}
/// <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;
}
/// <summary>
/// Удаление объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonRemoveMilitaryAircraft_Click(object sender, EventArgs e)
private void buttonRemoveAir_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
{
@@ -149,112 +178,4 @@ public partial class FormMilitaryAircraftCollection : Form
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 buttonCollectionDel_Click(object sender, EventArgs e)
{
if (listBoxCollection.SelectedItem == null)
{
MessageBox.Show("Коллекция не выбрана");
return;
}
if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
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 buttonCreateCompany_Click(object sender, EventArgs e)
{
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
{
MessageBox.Show("Коллекция не выбрана");
return;
}
ICollectionGenericObjects<DrawningMilitaryAircraft>? collection = _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
if (collection == null)
{
MessageBox.Show("Коллекция не проинициализирована");
return;
}
switch (comboBoxSelectorCompany.Text)
{
case "Хранилище":
_company = new Angar(pictureBox.Width, pictureBox.Height, collection);
break;
}
panelCompanyTools.Enabled = true;
RerfreshListBoxItems();
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
if (_storageCollection.SaveData(saveFileDialog.FileName))
{
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
if (_storageCollection.LoadData(openFileDialog.FileName))
{
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
RerfreshListBoxItems();
}
else
{
MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@@ -117,13 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>145, 17</value>
</metadata>
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>310, 17</value>
</metadata>
</root>

View File

@@ -1,357 +0,0 @@
namespace ProjectAirFighter
{
partial class FormMilitaryAircraftConfig
{
/// <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();
panelBlueViolet = new Panel();
panelBlack = new Panel();
panelGray = new Panel();
panelWhite = new Panel();
panelYellow = new Panel();
panelBlue = new Panel();
panelGreen = new Panel();
panelRed = new Panel();
checkBoxRockets = new CheckBox();
checkBoxWings = 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(checkBoxRockets);
groupBoxConfig.Controls.Add(checkBoxWings);
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(604, 207);
groupBoxConfig.TabIndex = 0;
groupBoxConfig.TabStop = false;
groupBoxConfig.Text = "Параметры";
//
// groupBoxColors
//
groupBoxColors.Controls.Add(panelBlueViolet);
groupBoxColors.Controls.Add(panelBlack);
groupBoxColors.Controls.Add(panelGray);
groupBoxColors.Controls.Add(panelWhite);
groupBoxColors.Controls.Add(panelYellow);
groupBoxColors.Controls.Add(panelBlue);
groupBoxColors.Controls.Add(panelGreen);
groupBoxColors.Controls.Add(panelRed);
groupBoxColors.Location = new Point(347, 12);
groupBoxColors.Name = "groupBoxColors";
groupBoxColors.Size = new Size(250, 125);
groupBoxColors.TabIndex = 1;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "Цвета";
//
// panelBlueViolet
//
panelBlueViolet.BackColor = Color.BlueViolet;
panelBlueViolet.Location = new Point(196, 83);
panelBlueViolet.Name = "panelBlueViolet";
panelBlueViolet.Size = new Size(36, 36);
panelBlueViolet.TabIndex = 9;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(136, 83);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(36, 36);
panelBlack.TabIndex = 11;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(77, 83);
panelGray.Name = "panelGray";
panelGray.Size = new Size(36, 36);
panelGray.TabIndex = 10;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(15, 83);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(36, 36);
panelWhite.TabIndex = 9;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(196, 26);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(36, 36);
panelYellow.TabIndex = 9;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(136, 26);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(36, 36);
panelBlue.TabIndex = 9;
//
// panelGreen
//
panelGreen.BackColor = Color.Green;
panelGreen.Location = new Point(77, 26);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(36, 36);
panelGreen.TabIndex = 9;
//
// panelRed
//
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(15, 26);
panelRed.Name = "panelRed";
panelRed.Size = new Size(36, 36);
panelRed.TabIndex = 8;
//
// checkBoxRockets
//
checkBoxRockets.AutoSize = true;
checkBoxRockets.Location = new Point(6, 154);
checkBoxRockets.Name = "checkBoxRockets";
checkBoxRockets.Size = new Size(339, 24);
checkBoxRockets.TabIndex = 7;
checkBoxRockets.Text = "Признак наличия дополнительных крыльев";
checkBoxRockets.UseVisualStyleBackColor = true;
//
// checkBoxWings
//
checkBoxWings.AutoSize = true;
checkBoxWings.Location = new Point(6, 124);
checkBoxWings.Name = "checkBoxWings";
checkBoxWings.Size = new Size(318, 24);
checkBoxWings.TabIndex = 6;
checkBoxWings.Text = "Признак наличия дополнительных ракет";
checkBoxWings.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(102, 75);
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(126, 27);
numericUpDownWeight.TabIndex = 5;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(12, 75);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(36, 20);
labelWeight.TabIndex = 4;
labelWeight.Text = "Вес:";
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(102, 32);
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(126, 27);
numericUpDownSpeed.TabIndex = 3;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(12, 34);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(76, 20);
labelSpeed.TabIndex = 2;
labelSpeed.Text = "Скорость:";
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(466, 154);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(113, 36);
labelModifiedObject.TabIndex = 1;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
labelModifiedObject.MouseDown += LabelObject_MouseDown;
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(347, 154);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(113, 36);
labelSimpleObject.TabIndex = 0;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(3, 49);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(185, 99);
pictureBoxObject.TabIndex = 0;
pictureBoxObject.TabStop = false;
//
// buttonAdd
//
buttonAdd.Location = new Point(610, 166);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(85, 29);
buttonAdd.TabIndex = 1;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(716, 166);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(85, 29);
buttonCancel.TabIndex = 2;
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(610, 0);
panelObject.Name = "panelObject";
panelObject.Size = new Size(191, 160);
panelObject.TabIndex = 3;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
//
// labelAdditionalColor
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(100, 9);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(88, 36);
labelAdditionalColor.TabIndex = 2;
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += LabelColors_DragDrop;
labelAdditionalColor.DragEnter += LabelColors_DragEnter;
//
// labelBodyColor
//
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(3, 9);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(88, 36);
labelBodyColor.TabIndex = 1;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
labelBodyColor.DragDrop += LabelColors_DragDrop;
labelBodyColor.DragEnter += LabelColors_DragEnter;
//
// FormMilitaryAircraftConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 207);
Controls.Add(panelObject);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(groupBoxConfig);
Name = "FormMilitaryAircraftConfig";
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 labelModifiedObject;
private Label labelSimpleObject;
private Label labelWeight;
private NumericUpDown numericUpDownSpeed;
private Label labelSpeed;
private NumericUpDown numericUpDownWeight;
private CheckBox checkBoxRockets;
private CheckBox checkBoxWings;
private GroupBox groupBoxColors;
private Panel panelRed;
private Panel panelBlueViolet;
private Panel panelBlack;
private Panel panelGray;
private Panel panelWhite;
private Panel panelYellow;
private Panel panelBlue;
private Panel panelGreen;
private PictureBox pictureBoxObject;
private Button buttonAdd;
private Button buttonCancel;
private Panel panelObject;
private Label labelAdditionalColor;
private Label labelBodyColor;
}
}

View File

@@ -1,169 +0,0 @@
using ProjectAirFighter.Drawnings;
using ProjectAirFighter.Entities;
namespace ProjectAirFighter;
/// <summary>
/// Форма конфигурации объекта
/// </summary>
public partial class FormMilitaryAircraftConfig : Form
{
/// <summary>
/// Объект - прорисовка автомобиля
/// </summary>
private DrawningMilitaryAircraft? _militaryAircraft;
/// <summary>
/// Событие для передачи объекта
/// </summary>
private event Action<DrawningMilitaryAircraft>? MilitaryAircraftDelegate;
/// <summary>
/// Конструктор
/// </summary>
public FormMilitaryAircraftConfig()
{
InitializeComponent();
panelRed.MouseDown += Panel_MouseDown;
panelGreen.MouseDown += Panel_MouseDown;
panelBlue.MouseDown += Panel_MouseDown;
panelYellow.MouseDown += Panel_MouseDown;
panelWhite.MouseDown += Panel_MouseDown;
panelGray.MouseDown += Panel_MouseDown;
panelBlack.MouseDown += Panel_MouseDown;
panelBlueViolet.MouseDown += Panel_MouseDown;
buttonCancel.Click += (sender, e) => Close();
}
/// <summary>
/// Привязка внешнего метода к событию
/// </summary>
/// <param name="militaryAircraftDelegate"></param>
public void AddEvent(Action<DrawningMilitaryAircraft> militaryAircraftDelegate)
{
if (MilitaryAircraftDelegate != null)
{
MilitaryAircraftDelegate = militaryAircraftDelegate;
}
else
{
MilitaryAircraftDelegate += militaryAircraftDelegate;
}
}
/// <summary>
/// Прорисовка объекта
/// </summary>
private void DrawObject()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_militaryAircraft.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
_militaryAircraft?.SetPosition(15, 15);
_militaryAircraft?.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)
{
e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
}
/// <summary>
/// Действия при приеме перетаскиваемой информации
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
{
case "labelSimpleObject":
_militaryAircraft = new DrawningMilitaryAircraft((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.Black);
break;
case "labelModifiedObject":
_militaryAircraft = new DrawningAirFighter((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White,
Color.Black, checkBoxRockets.Checked, checkBoxWings.Checked);
break;
}
DrawObject();
}
/// <summary>
/// Передаем информацию при нажатии на Panel
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>2
private void Panel_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Проверка получаемой информации (ее типа на соответствие требуемому)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelColors_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data?.GetDataPresent(typeof(Color)) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
}
/// <summary>
/// Действия при приеме перетаскиваемой информации
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelColors_DragDrop(object sender, DragEventArgs e)
{
if (_militaryAircraft == null)
{
return;
}
Label label = (Label)sender;
Color newColor = (Color)e.Data.GetData(typeof(Color).ToString());
switch (label.Name)
{
case "labelBodyColor":
_militaryAircraft.EntityMilitaryAircraft.SetBodyColor(newColor);
DrawObject();
break;
case "labelAdditionalColor":
if (_militaryAircraft is DrawningAirFighter)
{
(_militaryAircraft.EntityMilitaryAircraft as EntityAirFighter).SetAdditionalColor(newColor);
DrawObject();
}
break;
}
}
/// <summary>
/// Передача объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonAdd_Click(object sender, EventArgs e)
{
if (_militaryAircraft != null)
{
MilitaryAircraftDelegate?.Invoke(_militaryAircraft);
Close();
}
}
}

View File

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

View File

@@ -10,9 +10,9 @@ public class MoveToBorder : AbstractStrategy
return false;
}
return objParams.RightBorder <= FieldWidth &&
return objParams.RightBorder <= FieldWidth &&
objParams.RightBorder + GetStep() >= FieldWidth &&
objParams.DownBorder <= FieldHeight &&
objParams.DownBorder <= FieldHeight &&
objParams.DownBorder + GetStep() >= FieldHeight;
}

View File

@@ -15,7 +15,7 @@ public class MoveToCenter : AbstractStrategy
return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth / 2 &&
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2 &&
objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2 &&
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
}

View File

@@ -28,7 +28,7 @@
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
name/value pmilitaryAircrafts.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support