Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 923224c02e | |||
| 37a802cde6 | |||
| 26ecf356b8 | |||
| 30131211c3 | |||
| a5dec11857 | |||
| 9e6472cf47 | |||
| f1b78303ef | |||
| e37875f510 |
@@ -8,4 +8,9 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="EntityFramework" Version="6.2.0" />
|
||||||
|
<PackageReference Include="EntityFramework.ru" Version="6.2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -41,7 +41,7 @@ public abstract class AbstractCompany
|
|||||||
_pictureWidth = picWidth;
|
_pictureWidth = picWidth;
|
||||||
_pictureHeight = picHeight;
|
_pictureHeight = picHeight;
|
||||||
_collection = collection;
|
_collection = collection;
|
||||||
_collection.SetMaxCount = GetMaxCount;
|
_collection.MaxCount = GetMaxCount;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перегрузка оператора сложения для класса
|
/// Перегрузка оператора сложения для класса
|
||||||
@@ -49,19 +49,21 @@ public abstract class AbstractCompany
|
|||||||
/// <param name="company">Компания</param>
|
/// <param name="company">Компания</param>
|
||||||
/// <param name="gun">Добавляемый объект</param>
|
/// <param name="gun">Добавляемый объект</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static int operator +(AbstractCompany company, DrawningGun gun)
|
public static bool operator +(AbstractCompany company, DrawningGun gun)
|
||||||
{
|
{
|
||||||
return company._collection.Insert(gun);
|
return company._collection?.Insert(gun) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перегрузка оператора удаления для класса
|
/// Перегрузка оператора удаления для класса
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="company">Компания</param>
|
/// <param name="company">Компания</param>
|
||||||
/// <param name="position">Номер удаляемого объекта</param>
|
/// <param name="position">Номер удаляемого объекта</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static DrawningGun? operator -(AbstractCompany company, int position)
|
public static bool operator -(AbstractCompany company, int position)
|
||||||
{
|
{
|
||||||
return company._collection?.Remove(position);
|
return company._collection?.Remove(position) ?? false;
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение случайного объекта из коллекции
|
/// Получение случайного объекта из коллекции
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
namespace AntiAircraftGun.CollectionGenericObjects;
|
||||||
|
/// <summary>
|
||||||
|
/// Тип коллекции
|
||||||
|
/// </summary>
|
||||||
|
public enum CollectionType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Неопределено
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Массив
|
||||||
|
/// </summary>
|
||||||
|
Massive = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Список
|
||||||
|
/// </summary>
|
||||||
|
List = 2
|
||||||
|
}
|
||||||
@@ -51,10 +51,12 @@ public class GunSharingService : AbstractCompany
|
|||||||
for (int i = 0; i < maxCountX; i++)
|
for (int i = 0; i < maxCountX; i++)
|
||||||
{
|
{
|
||||||
currentIndex++;
|
currentIndex++;
|
||||||
if (_collection.Get(currentIndex) == null) continue;
|
if (_collection.Get(currentIndex) != null)
|
||||||
|
{
|
||||||
|
|
||||||
_collection.Get(currentIndex).SetPictureSize(_pictureWidth, _pictureHeight);
|
_collection.Get(currentIndex).SetPictureSize(_pictureWidth, _pictureHeight);
|
||||||
_collection.Get(currentIndex).SetPosition(boarderOffsetX + i * _placeSizeWidth + i * offsetX, boarderOffsetY + j * _placeSizeHeight);
|
_collection.Get(currentIndex).SetPosition(boarderOffsetX + i * _placeSizeWidth + i * offsetX, boarderOffsetY + j * _placeSizeHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,31 +15,39 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка максимального количества элементов
|
/// Установка максимального количества элементов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int SetMaxCount { set; }
|
int MaxCount { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в коллекцию
|
/// Добавление объекта в коллекцию
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">Добавляемый объект</param>
|
/// <param name="obj">Добавляемый объект</param>
|
||||||
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
||||||
int Insert(T obj);
|
bool Insert(T obj);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в коллекцию на конкретную позицию
|
/// Добавление объекта в коллекцию на конкретную позицию
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">Добавляемый объект</param>
|
/// <param name="obj">Добавляемый объект</param>
|
||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
||||||
int Insert(T obj, int position);
|
bool Insert(T obj, int position);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление объекта из коллекции с конкретной позиции
|
/// Удаление объекта из коллекции с конкретной позиции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
|
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
|
||||||
T? Remove(int position);
|
bool Remove(int position);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта по позиции
|
/// Получение объекта по позиции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns>Объект</returns>
|
/// <returns>Объект</returns>
|
||||||
T? Get(int position);
|
T? Get(int position);
|
||||||
|
/// <summary>
|
||||||
|
/// Получение типа коллекции
|
||||||
|
/// </summary>
|
||||||
|
CollectionType GetCollectionType { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Получение объектов коллекции по одному
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
IEnumerable<T?> GetItems();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AntiAircraftGun.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 { set { if (value > 0) { _maxCount = value; } } get { return _collection.Count; } }
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public ListGenericObjects()
|
||||||
|
{
|
||||||
|
_collection = new();
|
||||||
|
}
|
||||||
|
public T? Get(int position)
|
||||||
|
{
|
||||||
|
// TODO проверка позиции
|
||||||
|
if (!_collection.Any()) { return null; }
|
||||||
|
if (_collection.Count <= position || position < 0 || position >= _maxCount) { return null; }
|
||||||
|
return _collection[position];
|
||||||
|
}
|
||||||
|
public bool Insert(T obj)
|
||||||
|
{
|
||||||
|
// TODO проверка, что не превышено максимальное количество элементов
|
||||||
|
// TODO вставка в конец набора
|
||||||
|
if (_collection.Count>=_maxCount) return false;
|
||||||
|
_collection.Add(obj);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Insert(T obj, int position)
|
||||||
|
{
|
||||||
|
// TODO проверка, что не превышено максимальное количество элементов
|
||||||
|
// TODO проверка позиции
|
||||||
|
// TODO вставка по позиции
|
||||||
|
if (_collection.Count >= _maxCount || _collection[position] == null || position < 0) { return false; }
|
||||||
|
_collection.Insert(position, obj);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Remove(int position)
|
||||||
|
{
|
||||||
|
// TODO проверка позиции
|
||||||
|
// TODO удаление объекта из списка
|
||||||
|
if (_collection[position] == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_collection.RemoveAt(position);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public CollectionType GetCollectionType => CollectionType.List;
|
||||||
|
public IEnumerable<T?> GetItems()
|
||||||
|
{
|
||||||
|
for(int i=0; i<_collection.Count; i++) yield return _collection[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ internal class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private T?[] _collection;
|
private T?[] _collection;
|
||||||
public int Count => _collection.Length;
|
public int Count => _collection.Length;
|
||||||
public int SetMaxCount
|
public int MaxCount
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@@ -29,6 +29,10 @@ internal class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _collection.Length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
@@ -44,46 +48,44 @@ internal class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
return null;
|
return null;
|
||||||
return _collection[position];
|
return _collection[position];
|
||||||
}
|
}
|
||||||
public int Insert(T obj)
|
public bool Insert(T obj)
|
||||||
{
|
{
|
||||||
// TODO вставка в свободное место набора
|
// TODO вставка в свободное место набора
|
||||||
for (int i = 0; i < Count; i++)
|
for (int i = 0; i < Count; i++)
|
||||||
{
|
{
|
||||||
if (InsertingElementCollection(i, obj)) return i;
|
if (InsertingElementCollection(i, obj)) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
public int Insert(T obj, int position)
|
public bool Insert(T obj, int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
// TODO проверка позиции
|
||||||
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
|
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
|
||||||
// ищется свободное место после этой позиции и идет вставка туда
|
// ищется свободное место после этой позиции и идет вставка туда
|
||||||
// если нет после, ищем до
|
// если нет после, ищем до
|
||||||
// TODO вставка
|
// TODO вставка
|
||||||
if (InsertingElementCollection(position, obj)) return position;
|
if (InsertingElementCollection(position, obj)) return true;
|
||||||
|
|
||||||
for (int i = position + 1; i < Count; i++)
|
for (int i = position + 1; i < Count; i++)
|
||||||
{
|
{
|
||||||
if (InsertingElementCollection(i, obj)) return position;
|
if (InsertingElementCollection(i, obj)) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = position - 1; i >= 0; i--)
|
for (int i = position - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (InsertingElementCollection(i, obj)) return position;
|
if (InsertingElementCollection(i, obj)) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
public T? Remove(int position)
|
public bool Remove(int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
// TODO проверка позиции
|
||||||
// TODO удаление объекта из массива, присвоив элементу массива значение null
|
// TODO удаление объекта из массива, присвоив элементу массива значение null
|
||||||
if (_collection[position] == null) return null;
|
if (_collection[position] == null) return false;
|
||||||
|
|
||||||
T? temp = _collection[position];
|
|
||||||
_collection[position] = null;
|
_collection[position] = null;
|
||||||
return temp;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -100,4 +102,11 @@ internal class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
_collection[index] = obj;
|
_collection[index] = obj;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public CollectionType GetCollectionType => CollectionType.Massive;
|
||||||
|
public IEnumerable<T?> GetItems()
|
||||||
|
{
|
||||||
|
for (int i=0; i < _collection.Length; i++) yield return _collection[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,189 @@
|
|||||||
|
using AntiAircraftGun.Drawnings;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace AntiAircraftGun.CollectionGenericObjects;
|
||||||
|
/// <summary>
|
||||||
|
/// Класс-хранилище коллекций
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
public class StorageCollection<T>
|
||||||
|
where T : DrawningGun
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Словарь (хранилище) с коллекциями
|
||||||
|
/// </summary>
|
||||||
|
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращение списка названий коллекций
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Keys => _storages.Keys.ToList();
|
||||||
|
|
||||||
|
|
||||||
|
private readonly string _collectionKey = "CollectionStorage";
|
||||||
|
private readonly string _separatorForKeyValue = "|";
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
|
||||||
|
// TODO Прописать логику для добавления
|
||||||
|
if (name.Length<=0 || _storages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch(collectionType)
|
||||||
|
{
|
||||||
|
case CollectionType.List:
|
||||||
|
_storages.Add(name, new ListGenericObjects<T>());
|
||||||
|
break;
|
||||||
|
case CollectionType.Massive:
|
||||||
|
_storages.Add(name, new MassiveGenericObjects<T>());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
public void DelCollection(string name)
|
||||||
|
{
|
||||||
|
// TODO Прописать логику для удаления коллекции
|
||||||
|
if(!_storages.ContainsKey(name)) { return; }
|
||||||
|
_storages.Remove(name);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Доступ к коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название коллекции</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ICollectionGenericObjects<T>? this[string name]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// TODO Продумать логику получения объекта
|
||||||
|
if (!_storages.ContainsKey(name)) { return null; }
|
||||||
|
return _storages[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Запись информации в файл
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool SaveData(string filename)
|
||||||
|
{
|
||||||
|
if(File.Exists(filename))
|
||||||
|
{
|
||||||
|
File.Delete(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_storages.Count==0) return false;
|
||||||
|
StringBuilder sb = new();
|
||||||
|
sb.Append(_collectionKey);
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string,ICollectionGenericObjects<T>> value in _storages)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
using FileStream fs=new(filename, FileMode.Create);
|
||||||
|
byte[] info=new UTF8Encoding(true).GetBytes(sb.ToString());
|
||||||
|
fs.Write(info, 0, info.Length);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Загрузка информации по установкам в хранилище из файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool LoadData(string filename)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filename))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
using (StreamReader reader = File.OpenText(filename))
|
||||||
|
{
|
||||||
|
string str = reader.ReadLine();
|
||||||
|
if (str == null || str.Length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!str.StartsWith(_collectionKey))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_storages.Clear();
|
||||||
|
string strs = "";
|
||||||
|
while ((strs = reader.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?.CreateDrawningCun() is T gun)
|
||||||
|
{
|
||||||
|
if (!collection.Insert(gun))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_storages.Add(record[0], collection);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static ICollectionGenericObjects<T>? CreateCollection(CollectionType collectionType)
|
||||||
|
{
|
||||||
|
return collectionType switch
|
||||||
|
{
|
||||||
|
CollectionType.Massive => new MassiveGenericObjects<T>(),
|
||||||
|
CollectionType.List => new ListGenericObjects<T>(),
|
||||||
|
_ => null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,10 @@ namespace AntiAircraftGun.Drawnings;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class DrawningAntiAircraftGun:DrawningGun
|
public class DrawningAntiAircraftGun:DrawningGun
|
||||||
{
|
{
|
||||||
|
public DrawningAntiAircraftGun(EntityGun gun) : base(gun)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -15,9 +19,9 @@ public class DrawningAntiAircraftGun:DrawningGun
|
|||||||
/// <param name="optionalElementsColor"></param>
|
/// <param name="optionalElementsColor"></param>
|
||||||
/// <param name="barrelLenth"></param>
|
/// <param name="barrelLenth"></param>
|
||||||
/// <param name="hatchHeight"></param>
|
/// <param name="hatchHeight"></param>
|
||||||
public DrawningAntiAircraftGun(int speed, double weight, Color bodyColor, Color optionalElementsColor, double barrelLenth, bool hatchHeight, bool radar) : base(150,115) //140, 65
|
public DrawningAntiAircraftGun(int speed, double weight, Color bodyColor, Color optionalElementsColor,bool hatchHeight, bool radar) : base(150,115) //140, 65
|
||||||
{
|
{
|
||||||
EntityGun = new EntityAntiAircraftGun(speed,weight,bodyColor,optionalElementsColor,barrelLenth,hatchHeight,radar);
|
EntityGun = new EntityAntiAircraftGun(speed,weight,bodyColor,optionalElementsColor,hatchHeight,radar);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Прорисовка объекта
|
/// Прорисовка объекта
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public class DrawningGun
|
|||||||
/// Правая координата прорисовку зенитной установки
|
/// Правая координата прорисовку зенитной установки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected int? _startPosY;
|
protected int? _startPosY;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина прорисовки зенитной установки
|
/// Ширина прорисовки зенитной установки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -88,6 +89,12 @@ public class DrawningGun
|
|||||||
_drawingGunHeight = drawningGunHeight;
|
_drawingGunHeight = drawningGunHeight;
|
||||||
_drawningGunWidth = drawningGunWidth;
|
_drawningGunWidth = drawningGunWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DrawningGun(EntityGun gun)
|
||||||
|
{
|
||||||
|
EntityGun = gun;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка гранц поля
|
/// Установка гранц поля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using AntiAircraftGun.Entities;
|
||||||
|
|
||||||
|
namespace AntiAircraftGun.Drawnings;
|
||||||
|
/// <summary>
|
||||||
|
/// Расширение для класса EntityGun
|
||||||
|
/// </summary>
|
||||||
|
public static class ExtentionDrawningGun
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записи информации по объекту в файл
|
||||||
|
/// </summary>
|
||||||
|
private static readonly string _separatorForObject = ":";
|
||||||
|
/// <summary>
|
||||||
|
/// Создание объекта из строки
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">Строка с данными для создания объекта</param>
|
||||||
|
/// <returns>Объект</returns>
|
||||||
|
public static DrawningGun? CreateDrawningCun(this string info)
|
||||||
|
{
|
||||||
|
string[] strs = info.Split(_separatorForObject);
|
||||||
|
EntityGun? gun = EntityAntiAircraftGun.CreateEntityAntiaircraftGun(strs);
|
||||||
|
if (gun != null)
|
||||||
|
{
|
||||||
|
return new DrawningAntiAircraftGun(gun);
|
||||||
|
}
|
||||||
|
gun = EntityGun.CreateEntityCar(strs);
|
||||||
|
if (gun != null)
|
||||||
|
{
|
||||||
|
return new DrawningGun(gun);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Получение данных для сохранения в файл
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="drawningCar">Сохраняемый объект</param>
|
||||||
|
/// <returns>Строка с данными по объекту</returns>
|
||||||
|
public static string GetDataForSave(this DrawningGun drawningCun)
|
||||||
|
{
|
||||||
|
string[]? array = drawningCun?.EntityGun?.GetStringRepresentation();
|
||||||
|
if (array == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
return string.Join(_separatorForObject, array);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,14 +2,22 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс-сущность "Зенитная установка"
|
/// Класс-сущность "Зенитная установка"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EntityAntiAircraftGun:EntityGun
|
public class EntityAntiAircraftGun : EntityGun
|
||||||
{
|
{
|
||||||
private EntityGun? EntityGun;
|
private EntityGun? EntityGun;
|
||||||
|
/// <summary>
|
||||||
|
/// Дополнительный цвет
|
||||||
|
/// </summary>
|
||||||
public Color OptionalElementsColor { get; private set; }
|
public Color OptionalElementsColor { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Длинна ствола
|
/// Публичный сеттер для дополнительного цвета
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double BarrelLength { get; private set; }
|
/// <param name="OptionalElementsColor"></param>
|
||||||
|
public void SetOptionalElemensColor(Color OptionalElementsColor)
|
||||||
|
{
|
||||||
|
this.OptionalElementsColor = OptionalElementsColor;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Люк
|
/// Люк
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -18,13 +26,22 @@ public class EntityAntiAircraftGun:EntityGun
|
|||||||
/// Радар
|
/// Радар
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Radar { get; private set; }
|
public bool Radar { get; private set; }
|
||||||
public EntityAntiAircraftGun(int speed, double weight, Color bodyColor, Color optionalElementsColor, double barrelLenth, bool hatch, bool radar) : base(speed, weight, bodyColor)
|
public EntityAntiAircraftGun(int speed, double weight, Color bodyColor, Color optionalElementsColor, bool hatch, bool radar) : base(speed, weight, bodyColor)
|
||||||
{
|
{
|
||||||
EntityGun = new EntityGun(speed, weight, bodyColor);
|
EntityGun = new EntityGun(speed, weight, bodyColor);
|
||||||
OptionalElementsColor = optionalElementsColor;
|
OptionalElementsColor = optionalElementsColor;
|
||||||
BarrelLength = barrelLenth;
|
|
||||||
Radar = radar;
|
Radar = radar;
|
||||||
Hatch = hatch;
|
Hatch = hatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string[] GetStringRepresentation()
|
||||||
|
{
|
||||||
|
return new[] { nameof(EntityAntiAircraftGun), Speed.ToString(), Weight.ToString(), BodyColor.Name, OptionalElementsColor.ToString(), Hatch.ToString(), Radar.ToString() };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EntityAntiAircraftGun? CreateEntityAntiaircraftGun(string[] strs)
|
||||||
|
{
|
||||||
|
if (strs.Length != 7 || strs[0] != nameof(EntityAntiAircraftGun)) return null;
|
||||||
|
return new EntityAntiAircraftGun(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]), Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
using System;
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
||||||
|
|
||||||
namespace AntiAircraftGun.Entities;
|
namespace AntiAircraftGun.Entities;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -27,6 +22,15 @@ public class EntityGun
|
|||||||
/// Шаг
|
/// Шаг
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Step { get { return Speed * 100 / Weight; } private set { } }
|
public double Step { get { return Speed * 100 / Weight; } private set { } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Публичный сеттер для основного цвета
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bodyColor"></param>
|
||||||
|
public void SetBodyColor(Color bodyColor)
|
||||||
|
{
|
||||||
|
this.BodyColor = bodyColor;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор сущности
|
/// Конструктор сущности
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -39,4 +43,26 @@ public class EntityGun
|
|||||||
Weight = weight;
|
Weight = weight;
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение строк со значениями свойств объекта класса-сущности
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual string[] GetStringRepresentation()
|
||||||
|
{
|
||||||
|
return new[] { nameof(EntityGun), Speed.ToString(), Weight.ToString(), BodyColor.Name };
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Создание объекта из массива строк
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strs"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static EntityGun? CreateEntityCar(string[] strs)
|
||||||
|
{
|
||||||
|
if (strs.Length != 4 || strs[0] != nameof(EntityGun))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new EntityGun(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,41 +29,102 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
groupBox1 = new GroupBox();
|
groupBox1 = new GroupBox();
|
||||||
|
panelCompanyTools = new Panel();
|
||||||
|
buttonCreateCompany = new Button();
|
||||||
|
comboBoxSelectorCompany = new ComboBox();
|
||||||
|
buttonAddGun = new Button();
|
||||||
buttonRefresh = new Button();
|
buttonRefresh = new Button();
|
||||||
buttonGoToCheck = new Button();
|
buttonGoToCheck = new Button();
|
||||||
buttonRemoveGun = new Button();
|
|
||||||
maskedTextBox = new MaskedTextBox();
|
maskedTextBox = new MaskedTextBox();
|
||||||
buttonAddAntiAircraftGun = new Button();
|
buttonRemoveGun = new Button();
|
||||||
buttonAddGun = new Button();
|
panelStorage = new Panel();
|
||||||
comboBoxSelectorCompany = new ComboBox();
|
buttonCollectionDel = new Button();
|
||||||
|
listBoxCollection = new ListBox();
|
||||||
|
buttonCollectionAdd = new Button();
|
||||||
|
textBoxCollectionName = new TextBox();
|
||||||
|
radioButtonList = new RadioButton();
|
||||||
|
radioButtonMassive = new RadioButton();
|
||||||
|
labelNameCollection = new Label();
|
||||||
pictureBox = new PictureBox();
|
pictureBox = new PictureBox();
|
||||||
|
menuStrip = new MenuStrip();
|
||||||
|
файлToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
saveToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
downloadToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
saveFileDialog = new SaveFileDialog();
|
||||||
|
openFileDialog = new OpenFileDialog();
|
||||||
groupBox1.SuspendLayout();
|
groupBox1.SuspendLayout();
|
||||||
|
panelCompanyTools.SuspendLayout();
|
||||||
|
panelStorage.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||||
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBox1
|
// groupBox1
|
||||||
//
|
//
|
||||||
groupBox1.Controls.Add(buttonRefresh);
|
groupBox1.Controls.Add(panelCompanyTools);
|
||||||
groupBox1.Controls.Add(buttonGoToCheck);
|
groupBox1.Controls.Add(panelStorage);
|
||||||
groupBox1.Controls.Add(buttonRemoveGun);
|
|
||||||
groupBox1.Controls.Add(maskedTextBox);
|
|
||||||
groupBox1.Controls.Add(buttonAddAntiAircraftGun);
|
|
||||||
groupBox1.Controls.Add(buttonAddGun);
|
|
||||||
groupBox1.Controls.Add(comboBoxSelectorCompany);
|
|
||||||
groupBox1.Dock = DockStyle.Right;
|
groupBox1.Dock = DockStyle.Right;
|
||||||
groupBox1.Location = new Point(940, 0);
|
groupBox1.Location = new Point(981, 28);
|
||||||
groupBox1.Name = "groupBox1";
|
groupBox1.Name = "groupBox1";
|
||||||
groupBox1.Size = new Size(235, 669);
|
groupBox1.Size = new Size(235, 744);
|
||||||
groupBox1.TabIndex = 0;
|
groupBox1.TabIndex = 0;
|
||||||
groupBox1.TabStop = false;
|
groupBox1.TabStop = false;
|
||||||
groupBox1.Text = "Инструменты";
|
groupBox1.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
|
// panelCompanyTools
|
||||||
|
//
|
||||||
|
panelCompanyTools.Controls.Add(buttonCreateCompany);
|
||||||
|
panelCompanyTools.Controls.Add(comboBoxSelectorCompany);
|
||||||
|
panelCompanyTools.Controls.Add(buttonAddGun);
|
||||||
|
panelCompanyTools.Controls.Add(buttonRefresh);
|
||||||
|
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
||||||
|
panelCompanyTools.Controls.Add(maskedTextBox);
|
||||||
|
panelCompanyTools.Controls.Add(buttonRemoveGun);
|
||||||
|
panelCompanyTools.Dock = DockStyle.Bottom;
|
||||||
|
panelCompanyTools.Location = new Point(3, 384);
|
||||||
|
panelCompanyTools.Name = "panelCompanyTools";
|
||||||
|
panelCompanyTools.Size = new Size(229, 357);
|
||||||
|
panelCompanyTools.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// buttonCreateCompany
|
||||||
|
//
|
||||||
|
buttonCreateCompany.Location = new Point(9, 87);
|
||||||
|
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||||
|
buttonCreateCompany.Size = new Size(217, 29);
|
||||||
|
buttonCreateCompany.TabIndex = 8;
|
||||||
|
buttonCreateCompany.Text = "Создать компанию";
|
||||||
|
buttonCreateCompany.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreateCompany.Click += ButtonCreateCompany_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(9, 53);
|
||||||
|
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||||
|
comboBoxSelectorCompany.Size = new Size(214, 28);
|
||||||
|
comboBoxSelectorCompany.TabIndex = 0;
|
||||||
|
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
|
||||||
|
//
|
||||||
|
// buttonAddGun
|
||||||
|
//
|
||||||
|
buttonAddGun.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonAddGun.Location = new Point(9, 122);
|
||||||
|
buttonAddGun.Name = "buttonAddGun";
|
||||||
|
buttonAddGun.Size = new Size(214, 52);
|
||||||
|
buttonAddGun.TabIndex = 1;
|
||||||
|
buttonAddGun.Text = "Добавление установки";
|
||||||
|
buttonAddGun.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddGun.Click += ButtonAddGun_Click;
|
||||||
|
//
|
||||||
// buttonRefresh
|
// buttonRefresh
|
||||||
//
|
//
|
||||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonRefresh.Location = new Point(32, 578);
|
buttonRefresh.Location = new Point(9, 313);
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
buttonRefresh.Size = new Size(171, 70);
|
buttonRefresh.Size = new Size(214, 39);
|
||||||
buttonRefresh.TabIndex = 6;
|
buttonRefresh.TabIndex = 6;
|
||||||
buttonRefresh.Text = "Обновить";
|
buttonRefresh.Text = "Обновить";
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
@@ -72,90 +133,187 @@
|
|||||||
// buttonGoToCheck
|
// buttonGoToCheck
|
||||||
//
|
//
|
||||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonGoToCheck.Location = new Point(32, 465);
|
buttonGoToCheck.Location = new Point(9, 274);
|
||||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||||
buttonGoToCheck.Size = new Size(171, 70);
|
buttonGoToCheck.Size = new Size(214, 33);
|
||||||
buttonGoToCheck.TabIndex = 5;
|
buttonGoToCheck.TabIndex = 5;
|
||||||
buttonGoToCheck.Text = "Передать на тесты";
|
buttonGoToCheck.Text = "Передать на тесты";
|
||||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||||
buttonGoToCheck.Click += ButtonGoToCheck_Click;
|
buttonGoToCheck.Click += ButtonGoToCheck_Click;
|
||||||
//
|
//
|
||||||
|
// maskedTextBox
|
||||||
|
//
|
||||||
|
maskedTextBox.Location = new Point(9, 203);
|
||||||
|
maskedTextBox.Mask = "00";
|
||||||
|
maskedTextBox.Name = "maskedTextBox";
|
||||||
|
maskedTextBox.Size = new Size(217, 27);
|
||||||
|
maskedTextBox.TabIndex = 3;
|
||||||
|
maskedTextBox.ValidatingType = typeof(int);
|
||||||
|
//
|
||||||
// buttonRemoveGun
|
// buttonRemoveGun
|
||||||
//
|
//
|
||||||
buttonRemoveGun.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonRemoveGun.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonRemoveGun.Location = new Point(32, 364);
|
buttonRemoveGun.Location = new Point(9, 236);
|
||||||
buttonRemoveGun.Name = "buttonRemoveGun";
|
buttonRemoveGun.Name = "buttonRemoveGun";
|
||||||
buttonRemoveGun.Size = new Size(171, 70);
|
buttonRemoveGun.Size = new Size(214, 32);
|
||||||
buttonRemoveGun.TabIndex = 4;
|
buttonRemoveGun.TabIndex = 4;
|
||||||
buttonRemoveGun.Text = "Удалить установку";
|
buttonRemoveGun.Text = "Удалить установку";
|
||||||
buttonRemoveGun.UseVisualStyleBackColor = true;
|
buttonRemoveGun.UseVisualStyleBackColor = true;
|
||||||
buttonRemoveGun.Click += ButtonRemoveGun_Click;
|
buttonRemoveGun.Click += ButtonRemoveGun_Click;
|
||||||
//
|
//
|
||||||
// maskedTextBox
|
// panelStorage
|
||||||
//
|
//
|
||||||
maskedTextBox.Location = new Point(32, 292);
|
panelStorage.Controls.Add(buttonCollectionDel);
|
||||||
maskedTextBox.Mask = "00";
|
panelStorage.Controls.Add(listBoxCollection);
|
||||||
maskedTextBox.Name = "maskedTextBox";
|
panelStorage.Controls.Add(buttonCollectionAdd);
|
||||||
maskedTextBox.Size = new Size(171, 27);
|
panelStorage.Controls.Add(textBoxCollectionName);
|
||||||
maskedTextBox.TabIndex = 3;
|
panelStorage.Controls.Add(radioButtonList);
|
||||||
maskedTextBox.ValidatingType = typeof(int);
|
panelStorage.Controls.Add(radioButtonMassive);
|
||||||
|
panelStorage.Controls.Add(labelNameCollection);
|
||||||
|
panelStorage.Dock = DockStyle.Top;
|
||||||
|
panelStorage.Location = new Point(3, 23);
|
||||||
|
panelStorage.Name = "panelStorage";
|
||||||
|
panelStorage.Size = new Size(229, 366);
|
||||||
|
panelStorage.TabIndex = 7;
|
||||||
//
|
//
|
||||||
// buttonAddAntiAircraftGun
|
// buttonCollectionDel
|
||||||
//
|
//
|
||||||
buttonAddAntiAircraftGun.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonCollectionDel.Location = new Point(9, 326);
|
||||||
buttonAddAntiAircraftGun.Location = new Point(33, 191);
|
buttonCollectionDel.Name = "buttonCollectionDel";
|
||||||
buttonAddAntiAircraftGun.Name = "buttonAddAntiAircraftGun";
|
buttonCollectionDel.Size = new Size(217, 29);
|
||||||
buttonAddAntiAircraftGun.Size = new Size(171, 70);
|
buttonCollectionDel.TabIndex = 6;
|
||||||
buttonAddAntiAircraftGun.TabIndex = 2;
|
buttonCollectionDel.Text = "Удалить коллекцию";
|
||||||
buttonAddAntiAircraftGun.Text = "Добавление зенитной установки";
|
buttonCollectionDel.UseVisualStyleBackColor = true;
|
||||||
buttonAddAntiAircraftGun.UseVisualStyleBackColor = true;
|
buttonCollectionDel.Click += ButtonCollectionDel_Click;
|
||||||
buttonAddAntiAircraftGun.Click += ButtonAddAntiAircraftGun_Click;
|
|
||||||
//
|
//
|
||||||
// buttonAddGun
|
// listBoxCollection
|
||||||
//
|
//
|
||||||
buttonAddGun.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
listBoxCollection.FormattingEnabled = true;
|
||||||
buttonAddGun.Location = new Point(32, 106);
|
listBoxCollection.ItemHeight = 20;
|
||||||
buttonAddGun.Name = "buttonAddGun";
|
listBoxCollection.Location = new Point(9, 164);
|
||||||
buttonAddGun.Size = new Size(171, 70);
|
listBoxCollection.Name = "listBoxCollection";
|
||||||
buttonAddGun.TabIndex = 1;
|
listBoxCollection.Size = new Size(217, 144);
|
||||||
buttonAddGun.Text = "Добавление установки";
|
listBoxCollection.TabIndex = 5;
|
||||||
buttonAddGun.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddGun.Click += ButtonAddGun_Click;
|
|
||||||
//
|
//
|
||||||
// comboBoxSelectorCompany
|
// buttonCollectionAdd
|
||||||
//
|
//
|
||||||
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonCollectionAdd.Location = new Point(9, 120);
|
||||||
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
||||||
comboBoxSelectorCompany.FormattingEnabled = true;
|
buttonCollectionAdd.Size = new Size(217, 29);
|
||||||
comboBoxSelectorCompany.Items.AddRange(new object[] { "База" });
|
buttonCollectionAdd.TabIndex = 4;
|
||||||
comboBoxSelectorCompany.Location = new Point(33, 43);
|
buttonCollectionAdd.Text = "Добаваить коллекцию";
|
||||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
||||||
comboBoxSelectorCompany.Size = new Size(171, 28);
|
buttonCollectionAdd.Click += ButtonCollectionAdd_Click;
|
||||||
comboBoxSelectorCompany.TabIndex = 0;
|
//
|
||||||
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged;
|
// textBoxCollectionName
|
||||||
|
//
|
||||||
|
textBoxCollectionName.Location = new Point(9, 41);
|
||||||
|
textBoxCollectionName.Name = "textBoxCollectionName";
|
||||||
|
textBoxCollectionName.Size = new Size(217, 27);
|
||||||
|
textBoxCollectionName.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// radioButtonList
|
||||||
|
//
|
||||||
|
radioButtonList.AutoSize = true;
|
||||||
|
radioButtonList.Location = new Point(146, 74);
|
||||||
|
radioButtonList.Name = "radioButtonList";
|
||||||
|
radioButtonList.Size = new Size(80, 24);
|
||||||
|
radioButtonList.TabIndex = 2;
|
||||||
|
radioButtonList.TabStop = true;
|
||||||
|
radioButtonList.Text = "Список";
|
||||||
|
radioButtonList.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// radioButtonMassive
|
||||||
|
//
|
||||||
|
radioButtonMassive.AutoSize = true;
|
||||||
|
radioButtonMassive.Location = new Point(9, 74);
|
||||||
|
radioButtonMassive.Name = "radioButtonMassive";
|
||||||
|
radioButtonMassive.Size = new Size(82, 24);
|
||||||
|
radioButtonMassive.TabIndex = 1;
|
||||||
|
radioButtonMassive.TabStop = true;
|
||||||
|
radioButtonMassive.Text = "Массив";
|
||||||
|
radioButtonMassive.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// labelNameCollection
|
||||||
|
//
|
||||||
|
labelNameCollection.AutoSize = true;
|
||||||
|
labelNameCollection.Location = new Point(41, 11);
|
||||||
|
labelNameCollection.Name = "labelNameCollection";
|
||||||
|
labelNameCollection.Size = new Size(155, 20);
|
||||||
|
labelNameCollection.TabIndex = 0;
|
||||||
|
labelNameCollection.Text = "Название коллекции";
|
||||||
//
|
//
|
||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
pictureBox.Dock = DockStyle.Fill;
|
pictureBox.Dock = DockStyle.Fill;
|
||||||
pictureBox.Location = new Point(0, 0);
|
pictureBox.Location = new Point(0, 28);
|
||||||
pictureBox.Name = "pictureBox";
|
pictureBox.Name = "pictureBox";
|
||||||
pictureBox.Size = new Size(940, 669);
|
pictureBox.Size = new Size(981, 744);
|
||||||
pictureBox.TabIndex = 1;
|
pictureBox.TabIndex = 1;
|
||||||
pictureBox.TabStop = false;
|
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(1216, 28);
|
||||||
|
menuStrip.TabIndex = 2;
|
||||||
|
menuStrip.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// файлToolStripMenuItem
|
||||||
|
//
|
||||||
|
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, downloadToolStripMenuItem });
|
||||||
|
файл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;
|
||||||
|
//
|
||||||
|
// downloadToolStripMenuItem
|
||||||
|
//
|
||||||
|
downloadToolStripMenuItem.Name = "downloadToolStripMenuItem";
|
||||||
|
downloadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
|
||||||
|
downloadToolStripMenuItem.Size = new Size(227, 26);
|
||||||
|
downloadToolStripMenuItem.Text = "Загрузка";
|
||||||
|
downloadToolStripMenuItem.Click += DownloadToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// saveFileDialog
|
||||||
|
//
|
||||||
|
saveFileDialog.Filter = "txt files|*.txt";
|
||||||
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
openFileDialog.Filter = "txt files|*.txt";
|
||||||
|
//
|
||||||
// FormGunCollections
|
// FormGunCollections
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(1175, 669);
|
ClientSize = new Size(1216, 772);
|
||||||
Controls.Add(pictureBox);
|
Controls.Add(pictureBox);
|
||||||
Controls.Add(groupBox1);
|
Controls.Add(groupBox1);
|
||||||
|
Controls.Add(menuStrip);
|
||||||
|
MainMenuStrip = menuStrip;
|
||||||
Name = "FormGunCollections";
|
Name = "FormGunCollections";
|
||||||
Text = "Коллекция установок";
|
Text = "Коллекция установок";
|
||||||
groupBox1.ResumeLayout(false);
|
groupBox1.ResumeLayout(false);
|
||||||
groupBox1.PerformLayout();
|
panelCompanyTools.ResumeLayout(false);
|
||||||
|
panelCompanyTools.PerformLayout();
|
||||||
|
panelStorage.ResumeLayout(false);
|
||||||
|
panelStorage.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||||
|
menuStrip.ResumeLayout(false);
|
||||||
|
menuStrip.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -164,10 +322,25 @@
|
|||||||
private Button buttonAddGun;
|
private Button buttonAddGun;
|
||||||
private ComboBox comboBoxSelectorCompany;
|
private ComboBox comboBoxSelectorCompany;
|
||||||
private MaskedTextBox maskedTextBox;
|
private MaskedTextBox maskedTextBox;
|
||||||
private Button buttonAddAntiAircraftGun;
|
|
||||||
private PictureBox pictureBox;
|
private PictureBox pictureBox;
|
||||||
private Button buttonRemoveGun;
|
private Button buttonRemoveGun;
|
||||||
private Button buttonRefresh;
|
private Button buttonRefresh;
|
||||||
private Button buttonGoToCheck;
|
private Button buttonGoToCheck;
|
||||||
|
private Panel panelStorage;
|
||||||
|
private ListBox listBoxCollection;
|
||||||
|
private Button buttonCollectionAdd;
|
||||||
|
private TextBox textBoxCollectionName;
|
||||||
|
private RadioButton radioButtonList;
|
||||||
|
private RadioButton radioButtonMassive;
|
||||||
|
private Label labelNameCollection;
|
||||||
|
private Button buttonCreateCompany;
|
||||||
|
private Button buttonCollectionDel;
|
||||||
|
private Panel panelCompanyTools;
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem файлToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem saveToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem downloadToolStripMenuItem;
|
||||||
|
private SaveFileDialog saveFileDialog;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,10 @@ namespace AntiAircraftGun;
|
|||||||
|
|
||||||
public partial class FormGunCollections : Form
|
public partial class FormGunCollections : Form
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private readonly StorageCollection<DrawningGun> _storageCollection;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Компания
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private AbstractCompany? _company = null;
|
private AbstractCompany? _company = null;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -15,53 +17,39 @@ public partial class FormGunCollections : Form
|
|||||||
public FormGunCollections()
|
public FormGunCollections()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_storageCollection = new();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
switch (comboBoxSelectorCompany.Text)
|
panelCompanyTools.Enabled = true;
|
||||||
{
|
|
||||||
case "База":
|
|
||||||
_company = new GunSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningGun>());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создание объекта класса перемещения
|
/// Добавление установки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type">Тип создаваемого объекта</param>
|
/// <param name="sender"></param>
|
||||||
private void CreateObj(string type)
|
/// <param name="e"></param>
|
||||||
|
private void ButtonAddGun_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_company == null)
|
FormGunConfig form = new();
|
||||||
{
|
// TODO передать метод
|
||||||
return;
|
form.AddEvent(SetGun);
|
||||||
}
|
form.Show();
|
||||||
|
}
|
||||||
|
|
||||||
DrawningGun _drawningGun;
|
|
||||||
Random random = new();
|
/// <summary>
|
||||||
switch (type)
|
/// Добавление автомобиля в коллекцию
|
||||||
{
|
/// </summary>
|
||||||
case nameof(DrawningGun):
|
/// <param name="gun"></param>
|
||||||
_drawningGun = new DrawningGun(random.Next(100, 300),
|
private void SetGun(DrawningGun gun)
|
||||||
random.Next(1000, 3000), SetColor(random));
|
{
|
||||||
break;
|
if (_company == null || gun == null) { return; }
|
||||||
case nameof(DrawningAntiAircraftGun):
|
if (_company + gun)
|
||||||
_drawningGun = new DrawningAntiAircraftGun(random.Next(100, 300),
|
|
||||||
random.Next(1000, 3000),
|
|
||||||
SetColor(random),
|
|
||||||
SetColor(random),
|
|
||||||
random.Next(10, 100),
|
|
||||||
Convert.ToBoolean(random.Next(0, 2)),
|
|
||||||
Convert.ToBoolean(random.Next(0, 2)));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_company + _drawningGun!=-1)
|
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
@@ -70,30 +58,13 @@ public partial class FormGunCollections : Form
|
|||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение цвета
|
/// Удаление установки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="random">Случайные числа</param>
|
/// <param name="sender"></param>
|
||||||
/// <returns></returns>
|
/// <param name="e"></param>
|
||||||
private static Color SetColor(Random random)
|
|
||||||
{
|
|
||||||
Color color = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
|
|
||||||
ColorDialog dialog = new();
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK) { color = dialog.Color; }
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAddGun_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CreateObj(nameof(DrawningGun));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAddAntiAircraftGun_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CreateObj(nameof(DrawningAntiAircraftGun));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonRemoveGun_Click(object sender, EventArgs e)
|
private void ButtonRemoveGun_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_company == null)
|
if (_company == null)
|
||||||
@@ -104,9 +75,9 @@ public partial class FormGunCollections : Form
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MessageBox.Show("Удалить объект", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; }
|
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; }
|
||||||
int pos = Convert.ToInt32(maskedTextBox.Text);
|
int pos = Convert.ToInt32(maskedTextBox.Text);
|
||||||
if (_company - pos is DrawningGun)
|
if (_company - pos)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
@@ -117,7 +88,11 @@ public partial class FormGunCollections : Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Передача объекта на тесты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
private void ButtonGoToCheck_Click(object sender, EventArgs e)
|
private void ButtonGoToCheck_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_company == null)
|
if (_company == null)
|
||||||
@@ -148,7 +123,11 @@ public partial class FormGunCollections : Form
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Обновление экрана
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
private void ButtonRefresh_Click(object sender, EventArgs e)
|
private void ButtonRefresh_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_company == null)
|
if (_company == null)
|
||||||
@@ -157,4 +136,127 @@ public partial class FormGunCollections : Form
|
|||||||
}
|
}
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление колллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonCollectionDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxCollection.SelectedItem == null || listBoxCollection.SelectedIndex < 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Коллекция для удаления не выбрана");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
|
||||||
|
RerfreshListBoxItems();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Создание компании
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonCreateCompany_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxCollection.SelectedIndex < 0 ||
|
||||||
|
listBoxCollection.SelectedItem == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Коллекция не выбрана");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ICollectionGenericObjects<DrawningGun>? collection =
|
||||||
|
_storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (collection == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Коллекция не проинициализирована");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (comboBoxSelectorCompany.Text)
|
||||||
|
{
|
||||||
|
case "База":
|
||||||
|
_company = new GunSharingService(pictureBox.Width,
|
||||||
|
pictureBox.Height, collection);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
panelCompanyTools.Enabled = true;
|
||||||
|
RerfreshListBoxItems();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Обновление списка в listBoxCollection
|
||||||
|
/// </summary>
|
||||||
|
private void RerfreshListBoxItems()
|
||||||
|
{
|
||||||
|
listBoxCollection.Items.Clear();
|
||||||
|
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
|
||||||
|
{
|
||||||
|
string? colName = _storageCollection.Keys?[i];
|
||||||
|
if (!string.IsNullOrEmpty(colName))
|
||||||
|
{
|
||||||
|
listBoxCollection.Items.Add(colName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Обработка нажатия "Cохранения"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Обработка нажатия "Загрузка"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void DownloadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//TODO продумать логику
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_storageCollection.LoadData(openFileDialog.FileName))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Загрузка прошла успешно", "Результат",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
RerfreshListBoxItems();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не загрузилось", "Результат",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,4 +117,16 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</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>
|
||||||
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>25</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
||||||
371
AntiAircraftGun/AntiAircraftGun/FormGunConfig.Designer.cs
generated
Normal file
371
AntiAircraftGun/AntiAircraftGun/FormGunConfig.Designer.cs
generated
Normal file
@@ -0,0 +1,371 @@
|
|||||||
|
namespace AntiAircraftGun
|
||||||
|
{
|
||||||
|
partial class FormGunConfig
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
labelSimpleOblect = new Label();
|
||||||
|
groupBoxColors = new GroupBox();
|
||||||
|
panelIndigo = new Panel();
|
||||||
|
panelGrey = new Panel();
|
||||||
|
panelBlack = new Panel();
|
||||||
|
panelWhite = new Panel();
|
||||||
|
panelGreen = new Panel();
|
||||||
|
panelBlue = new Panel();
|
||||||
|
panelYellow = new Panel();
|
||||||
|
panelRed = new Panel();
|
||||||
|
checkBoxRadar = new CheckBox();
|
||||||
|
checkBoxHatch = new CheckBox();
|
||||||
|
numericUpDownWeight = new NumericUpDown();
|
||||||
|
numericUpDownSpeed = new NumericUpDown();
|
||||||
|
labelWeight = new Label();
|
||||||
|
labelSpeed = new Label();
|
||||||
|
labelModifiedObject = new Label();
|
||||||
|
labelSimpleObject = new Label();
|
||||||
|
pictureBoxObjects = new PictureBox();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
panelObjects = new Panel();
|
||||||
|
labelOptionalColor = new Label();
|
||||||
|
labelBodyColor = new Label();
|
||||||
|
groupBoxConfig.SuspendLayout();
|
||||||
|
groupBoxColors.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObjects).BeginInit();
|
||||||
|
panelObjects.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBoxConfig
|
||||||
|
//
|
||||||
|
groupBoxConfig.Controls.Add(labelSimpleOblect);
|
||||||
|
groupBoxConfig.Controls.Add(groupBoxColors);
|
||||||
|
groupBoxConfig.Controls.Add(checkBoxRadar);
|
||||||
|
groupBoxConfig.Controls.Add(checkBoxHatch);
|
||||||
|
groupBoxConfig.Controls.Add(numericUpDownWeight);
|
||||||
|
groupBoxConfig.Controls.Add(numericUpDownSpeed);
|
||||||
|
groupBoxConfig.Controls.Add(labelWeight);
|
||||||
|
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(682, 345);
|
||||||
|
groupBoxConfig.TabIndex = 0;
|
||||||
|
groupBoxConfig.TabStop = false;
|
||||||
|
groupBoxConfig.Text = "Параметры";
|
||||||
|
//
|
||||||
|
// labelSimpleOblect
|
||||||
|
//
|
||||||
|
labelSimpleOblect.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
labelSimpleOblect.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelSimpleOblect.Location = new Point(277, 241);
|
||||||
|
labelSimpleOblect.Name = "labelSimpleOblect";
|
||||||
|
labelSimpleOblect.Size = new Size(131, 55);
|
||||||
|
labelSimpleOblect.TabIndex = 10;
|
||||||
|
labelSimpleOblect.Text = "Простой";
|
||||||
|
labelSimpleOblect.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelSimpleOblect.MouseDown += LabelOblect_MouseDown;
|
||||||
|
//
|
||||||
|
// groupBoxColors
|
||||||
|
//
|
||||||
|
groupBoxColors.Controls.Add(panelIndigo);
|
||||||
|
groupBoxColors.Controls.Add(panelGrey);
|
||||||
|
groupBoxColors.Controls.Add(panelBlack);
|
||||||
|
groupBoxColors.Controls.Add(panelWhite);
|
||||||
|
groupBoxColors.Controls.Add(panelGreen);
|
||||||
|
groupBoxColors.Controls.Add(panelBlue);
|
||||||
|
groupBoxColors.Controls.Add(panelYellow);
|
||||||
|
groupBoxColors.Controls.Add(panelRed);
|
||||||
|
groupBoxColors.Location = new Point(277, 41);
|
||||||
|
groupBoxColors.Name = "groupBoxColors";
|
||||||
|
groupBoxColors.Size = new Size(314, 171);
|
||||||
|
groupBoxColors.TabIndex = 8;
|
||||||
|
groupBoxColors.TabStop = false;
|
||||||
|
groupBoxColors.Text = "Цвета";
|
||||||
|
//
|
||||||
|
// panelIndigo
|
||||||
|
//
|
||||||
|
panelIndigo.BackColor = Color.Indigo;
|
||||||
|
panelIndigo.Location = new Point(233, 91);
|
||||||
|
panelIndigo.Name = "panelIndigo";
|
||||||
|
panelIndigo.Size = new Size(39, 41);
|
||||||
|
panelIndigo.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// panelGrey
|
||||||
|
//
|
||||||
|
panelGrey.BackColor = Color.Gray;
|
||||||
|
panelGrey.Location = new Point(163, 91);
|
||||||
|
panelGrey.Name = "panelGrey";
|
||||||
|
panelGrey.Size = new Size(39, 41);
|
||||||
|
panelGrey.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// panelBlack
|
||||||
|
//
|
||||||
|
panelBlack.BackColor = Color.Black;
|
||||||
|
panelBlack.Location = new Point(92, 91);
|
||||||
|
panelBlack.Name = "panelBlack";
|
||||||
|
panelBlack.Size = new Size(39, 41);
|
||||||
|
panelBlack.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// panelWhite
|
||||||
|
//
|
||||||
|
panelWhite.BackColor = Color.White;
|
||||||
|
panelWhite.Location = new Point(19, 91);
|
||||||
|
panelWhite.Name = "panelWhite";
|
||||||
|
panelWhite.Size = new Size(39, 41);
|
||||||
|
panelWhite.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelGreen
|
||||||
|
//
|
||||||
|
panelGreen.BackColor = Color.Green;
|
||||||
|
panelGreen.Location = new Point(233, 37);
|
||||||
|
panelGreen.Name = "panelGreen";
|
||||||
|
panelGreen.Size = new Size(39, 41);
|
||||||
|
panelGreen.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelBlue
|
||||||
|
//
|
||||||
|
panelBlue.BackColor = Color.Blue;
|
||||||
|
panelBlue.Location = new Point(163, 37);
|
||||||
|
panelBlue.Name = "panelBlue";
|
||||||
|
panelBlue.Size = new Size(39, 41);
|
||||||
|
panelBlue.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// panelYellow
|
||||||
|
//
|
||||||
|
panelYellow.BackColor = Color.Yellow;
|
||||||
|
panelYellow.Location = new Point(92, 37);
|
||||||
|
panelYellow.Name = "panelYellow";
|
||||||
|
panelYellow.Size = new Size(39, 41);
|
||||||
|
panelYellow.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelRed
|
||||||
|
//
|
||||||
|
panelRed.BackColor = Color.Red;
|
||||||
|
panelRed.Location = new Point(19, 37);
|
||||||
|
panelRed.Name = "panelRed";
|
||||||
|
panelRed.Size = new Size(39, 41);
|
||||||
|
panelRed.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// checkBoxRadar
|
||||||
|
//
|
||||||
|
checkBoxRadar.AutoSize = true;
|
||||||
|
checkBoxRadar.Location = new Point(22, 203);
|
||||||
|
checkBoxRadar.Name = "checkBoxRadar";
|
||||||
|
checkBoxRadar.Size = new Size(72, 24);
|
||||||
|
checkBoxRadar.TabIndex = 7;
|
||||||
|
checkBoxRadar.Text = "Радар";
|
||||||
|
checkBoxRadar.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxHatch
|
||||||
|
//
|
||||||
|
checkBoxHatch.AutoSize = true;
|
||||||
|
checkBoxHatch.Location = new Point(22, 149);
|
||||||
|
checkBoxHatch.Name = "checkBoxHatch";
|
||||||
|
checkBoxHatch.Size = new Size(60, 24);
|
||||||
|
checkBoxHatch.TabIndex = 6;
|
||||||
|
checkBoxHatch.Text = "Люк";
|
||||||
|
checkBoxHatch.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// numericUpDownWeight
|
||||||
|
//
|
||||||
|
numericUpDownWeight.Location = new Point(104, 92);
|
||||||
|
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(99, 27);
|
||||||
|
numericUpDownWeight.TabIndex = 5;
|
||||||
|
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// numericUpDownSpeed
|
||||||
|
//
|
||||||
|
numericUpDownSpeed.Location = new Point(104, 41);
|
||||||
|
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(99, 27);
|
||||||
|
numericUpDownSpeed.TabIndex = 4;
|
||||||
|
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// labelWeight
|
||||||
|
//
|
||||||
|
labelWeight.AutoSize = true;
|
||||||
|
labelWeight.Location = new Point(22, 94);
|
||||||
|
labelWeight.Name = "labelWeight";
|
||||||
|
labelWeight.Size = new Size(36, 20);
|
||||||
|
labelWeight.TabIndex = 3;
|
||||||
|
labelWeight.Text = "Вес:";
|
||||||
|
//
|
||||||
|
// labelSpeed
|
||||||
|
//
|
||||||
|
labelSpeed.AutoSize = true;
|
||||||
|
labelSpeed.Location = new Point(22, 43);
|
||||||
|
labelSpeed.Name = "labelSpeed";
|
||||||
|
labelSpeed.Size = new Size(76, 20);
|
||||||
|
labelSpeed.TabIndex = 2;
|
||||||
|
labelSpeed.Text = "Скорость:";
|
||||||
|
//
|
||||||
|
// labelModifiedObject
|
||||||
|
//
|
||||||
|
labelModifiedObject.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelModifiedObject.Location = new Point(460, 241);
|
||||||
|
labelModifiedObject.Name = "labelModifiedObject";
|
||||||
|
labelModifiedObject.Size = new Size(131, 55);
|
||||||
|
labelModifiedObject.TabIndex = 1;
|
||||||
|
labelModifiedObject.Text = "Продвинутый";
|
||||||
|
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelModifiedObject.MouseDown += LabelOblect_MouseDown;
|
||||||
|
//
|
||||||
|
// labelSimpleObject
|
||||||
|
//
|
||||||
|
labelSimpleObject.Location = new Point(0, 0);
|
||||||
|
labelSimpleObject.Name = "labelSimpleObject";
|
||||||
|
labelSimpleObject.Size = new Size(100, 23);
|
||||||
|
labelSimpleObject.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// pictureBoxObjects
|
||||||
|
//
|
||||||
|
pictureBoxObjects.Location = new Point(41, 95);
|
||||||
|
pictureBoxObjects.Name = "pictureBoxObjects";
|
||||||
|
pictureBoxObjects.Size = new Size(218, 169);
|
||||||
|
pictureBoxObjects.TabIndex = 0;
|
||||||
|
pictureBoxObjects.TabStop = false;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(731, 304);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(94, 29);
|
||||||
|
buttonAdd.TabIndex = 2;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(931, 304);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(94, 29);
|
||||||
|
buttonCancel.TabIndex = 3;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// panelObjects
|
||||||
|
//
|
||||||
|
panelObjects.AllowDrop = true;
|
||||||
|
panelObjects.Controls.Add(labelOptionalColor);
|
||||||
|
panelObjects.Controls.Add(labelBodyColor);
|
||||||
|
panelObjects.Controls.Add(pictureBoxObjects);
|
||||||
|
panelObjects.Location = new Point(731, 12);
|
||||||
|
panelObjects.Name = "panelObjects";
|
||||||
|
panelObjects.Size = new Size(294, 284);
|
||||||
|
panelObjects.TabIndex = 4;
|
||||||
|
panelObjects.DragDrop += PanelObjects_DragDrop;
|
||||||
|
panelObjects.DragEnter += PanelObjects_DragEnter;
|
||||||
|
//
|
||||||
|
// labelOptionalColor
|
||||||
|
//
|
||||||
|
labelOptionalColor.AllowDrop = true;
|
||||||
|
labelOptionalColor.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
labelOptionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelOptionalColor.Location = new Point(164, 14);
|
||||||
|
labelOptionalColor.Name = "labelOptionalColor";
|
||||||
|
labelOptionalColor.Size = new Size(118, 42);
|
||||||
|
labelOptionalColor.TabIndex = 12;
|
||||||
|
labelOptionalColor.Text = "Доп. Цвет";
|
||||||
|
labelOptionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelOptionalColor.DragDrop += labelOptionalColor_DragDrop;
|
||||||
|
labelOptionalColor.DragEnter += labelOptionalColor_DragEnter;
|
||||||
|
//
|
||||||
|
// labelBodyColor
|
||||||
|
//
|
||||||
|
labelBodyColor.AllowDrop = true;
|
||||||
|
labelBodyColor.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelBodyColor.Location = new Point(13, 14);
|
||||||
|
labelBodyColor.Name = "labelBodyColor";
|
||||||
|
labelBodyColor.Size = new Size(113, 42);
|
||||||
|
labelBodyColor.TabIndex = 11;
|
||||||
|
labelBodyColor.Text = "Цвет";
|
||||||
|
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
|
||||||
|
labelBodyColor.DragEnter += labelBodyColor_DragEnter;
|
||||||
|
//
|
||||||
|
// FormGunConfig
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(1056, 345);
|
||||||
|
Controls.Add(panelObjects);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(groupBoxConfig);
|
||||||
|
Name = "FormGunConfig";
|
||||||
|
Text = "Создание объекта";
|
||||||
|
groupBoxConfig.ResumeLayout(false);
|
||||||
|
groupBoxConfig.PerformLayout();
|
||||||
|
groupBoxColors.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObjects).EndInit();
|
||||||
|
panelObjects.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBoxConfig;
|
||||||
|
private Label labelSimpleObject;
|
||||||
|
private Label labelModifiedObject;
|
||||||
|
private NumericUpDown numericUpDownWeight;
|
||||||
|
private NumericUpDown numericUpDownSpeed;
|
||||||
|
private Label labelWeight;
|
||||||
|
private Label labelSpeed;
|
||||||
|
private CheckBox checkBoxRadar;
|
||||||
|
private CheckBox checkBoxHatch;
|
||||||
|
private GroupBox groupBoxColors;
|
||||||
|
private Panel panelRed;
|
||||||
|
private Panel panelIndigo;
|
||||||
|
private Panel panelGrey;
|
||||||
|
private Panel panelBlack;
|
||||||
|
private Panel panelWhite;
|
||||||
|
private Panel panelGreen;
|
||||||
|
private Panel panelBlue;
|
||||||
|
private Panel panelYellow;
|
||||||
|
private PictureBox pictureBoxObjects;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Panel panelObjects;
|
||||||
|
private Label labelSimpleOblect;
|
||||||
|
private Label labelBodyColor;
|
||||||
|
private Label labelOptionalColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
163
AntiAircraftGun/AntiAircraftGun/FormGunConfig.cs
Normal file
163
AntiAircraftGun/AntiAircraftGun/FormGunConfig.cs
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
using AntiAircraftGun.Drawnings;
|
||||||
|
using AntiAircraftGun.Entities;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AntiAircraftGun;
|
||||||
|
/// <summary>
|
||||||
|
/// Форма конфигурации объекта
|
||||||
|
/// </summary>
|
||||||
|
public partial class FormGunConfig : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Объект прорисовки класса
|
||||||
|
/// </summary>
|
||||||
|
private DrawningGun? _gun;
|
||||||
|
/// <summary>
|
||||||
|
/// Событие для передачи объекта
|
||||||
|
/// </summary>
|
||||||
|
private event Action<DrawningGun>? _gunDelegate;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public FormGunConfig()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
panelRed.MouseDown += Panel_MouseDown;
|
||||||
|
panelGreen.MouseDown += Panel_MouseDown;
|
||||||
|
panelBlue.MouseDown += Panel_MouseDown;
|
||||||
|
panelWhite.MouseDown += Panel_MouseDown;
|
||||||
|
panelBlack.MouseDown += Panel_MouseDown;
|
||||||
|
panelGrey.MouseDown += Panel_MouseDown;
|
||||||
|
panelIndigo.MouseDown += Panel_MouseDown;
|
||||||
|
panelYellow.MouseDown += Panel_MouseDown;
|
||||||
|
|
||||||
|
// TODO buttonCancel.Click with lambda
|
||||||
|
buttonCancel.Click += (sender, e) => Close();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Привязка внешнего метода к союытию
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="gunDelegate"></param>
|
||||||
|
public void AddEvent(Action<DrawningGun> gunDelegate)
|
||||||
|
{
|
||||||
|
_gunDelegate += gunDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <summary>
|
||||||
|
/// Прорисовка объекта
|
||||||
|
/// </summary>
|
||||||
|
private void DrawObject()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxObjects.Width, pictureBoxObjects.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_gun?.SetPictureSize(pictureBoxObjects.Width,
|
||||||
|
pictureBoxObjects.Height);
|
||||||
|
_gun?.SetPosition(15, 15);
|
||||||
|
_gun?.DrawTransport(gr);
|
||||||
|
pictureBoxObjects.Image = bmp;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Передаем информацию при нажатии на Label
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void LabelOblect_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
Label label=sender as Label;
|
||||||
|
if(label.Name== "labelSimpleOblect")
|
||||||
|
{
|
||||||
|
label.DoDragDrop(new DrawningGun((int)numericUpDownSpeed.Value,
|
||||||
|
(double)numericUpDownWeight.Value, Color.White), DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Random random = new Random();
|
||||||
|
label.DoDragDrop(new
|
||||||
|
DrawningAntiAircraftGun((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value,
|
||||||
|
Color.White,
|
||||||
|
Color.Black,
|
||||||
|
checkBoxHatch.Checked, checkBoxRadar.Checked), DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void PanelObjects_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Действия при приеме перетаскиваемой информации
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void PanelObjects_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if ((DrawningGun)e.Data.GetData(typeof(DrawningGun)) != null)
|
||||||
|
{
|
||||||
|
_gun = (DrawningGun)e.Data.GetData(typeof(DrawningGun));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_gun = (DrawningAntiAircraftGun)e.Data.GetData(typeof(DrawningAntiAircraftGun));
|
||||||
|
}
|
||||||
|
DrawObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Panel_MouseDown(object? sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
// TODO реализовать выбор цвета
|
||||||
|
(sender as Control)?.DoDragDrop((sender as Control)?.BackColor ?? Color.Black, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Передача объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_gun != null)
|
||||||
|
{
|
||||||
|
_gunDelegate?.Invoke(_gun);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_gun != null)
|
||||||
|
{
|
||||||
|
_gun.EntityGun.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
DrawObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelBodyColor_DragEnter(object? sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
e.Effect = e.Data?.GetDataPresent(typeof(Color)) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelOptionalColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_gun.EntityGun is EntityAntiAircraftGun antiAircraftGun)
|
||||||
|
{
|
||||||
|
antiAircraftGun.SetOptionalElemensColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
DrawObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void labelOptionalColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_gun is DrawningAntiAircraftGun)
|
||||||
|
{
|
||||||
|
e.Effect = e.Data?.GetDataPresent(typeof(Color)) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO Реализовать логику смены цветов: основного и дополнительного(для продвинутого объекта)
|
||||||
|
}
|
||||||
120
AntiAircraftGun/AntiAircraftGun/FormGunConfig.resx
Normal file
120
AntiAircraftGun/AntiAircraftGun/FormGunConfig.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>
|
||||||
7
AntiAircraftGun/AntiAircraftGun/GunDelegate.cs
Normal file
7
AntiAircraftGun/AntiAircraftGun/GunDelegate.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
using AntiAircraftGun.Drawnings;
|
||||||
|
namespace AntiAircraftGun;
|
||||||
|
/// <summary>
|
||||||
|
/// Делегат для объекта класса прорисовки
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="drawningGun"></param>
|
||||||
|
public delegate void GunDelegate(DrawningGun drawningGun);
|
||||||
Reference in New Issue
Block a user