Compare commits
3 Commits
a5dec11857
...
37a802cde6
Author | SHA1 | Date | |
---|---|---|---|
37a802cde6 | |||
26ecf356b8 | |||
30131211c3 |
@ -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>
|
||||||
/// Перегрузка оператора сложения для класса
|
/// Перегрузка оператора сложения для класса
|
||||||
|
@ -15,7 +15,7 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка максимального количества элементов
|
/// Установка максимального количества элементов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int SetMaxCount { set; }
|
int MaxCount { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в коллекцию
|
/// Добавление объекта в коллекцию
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -41,5 +41,13 @@ public interface ICollectionGenericObjects<T>
|
|||||||
/// <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();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private int _maxCount;
|
private int _maxCount;
|
||||||
public int Count => _collection.Count;
|
public int Count => _collection.Count;
|
||||||
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
|
public int MaxCount { set { if (value > 0) { _maxCount = value; } } get { return _collection.Count; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -64,4 +64,11 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
_collection.RemoveAt(position);
|
_collection.RemoveAt(position);
|
||||||
return true;
|
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>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
@ -98,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];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
namespace AntiAircraftGun.CollectionGenericObjects;
|
using AntiAircraftGun.Drawnings;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace AntiAircraftGun.CollectionGenericObjects;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс-хранилище коллекций
|
/// Класс-хранилище коллекций
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
public class StorageCollection<T>
|
public class StorageCollection<T>
|
||||||
where T : class
|
where T : DrawningGun
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Словарь (хранилище) с коллекциями
|
/// Словарь (хранилище) с коллекциями
|
||||||
@ -14,6 +17,11 @@ where T : class
|
|||||||
/// Возвращение списка названий коллекций
|
/// Возвращение списка названий коллекций
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> Keys => _storages.Keys.ToList();
|
public List<string> Keys => _storages.Keys.ToList();
|
||||||
|
|
||||||
|
|
||||||
|
private readonly string _collectionKey = "CollectionStorage";
|
||||||
|
private readonly string _separatorForKeyValue = "|";
|
||||||
|
private readonly string _separatorItems = ";";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -70,4 +78,106 @@ where T : class
|
|||||||
return _storages[name];
|
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;
|
||||||
|
|
||||||
|
string bufferTextFromFile = "";
|
||||||
|
using(FileStream fs = new(filename, FileMode.Open))
|
||||||
|
{
|
||||||
|
byte[] b=new byte[fs.Length];
|
||||||
|
UTF8Encoding temp = new(true);
|
||||||
|
while (fs.Read(b, 0, b.Length) > 0) bufferTextFromFile += temp.GetString(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
if(strs ==null || strs.Length == 0) return false;
|
||||||
|
if (!strs[0].Equals(_collectionKey))
|
||||||
|
// Если нет такой записи, то это не те данные
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_storages.Clear();
|
||||||
|
foreach (string data in strs)
|
||||||
|
{
|
||||||
|
string[] record=data.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?.CreateDrawningCar() 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? CreateDrawningCar(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,7 +2,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс-сущность "Зенитная установка"
|
/// Класс-сущность "Зенитная установка"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EntityAntiAircraftGun:EntityGun
|
public class EntityAntiAircraftGun : EntityGun
|
||||||
{
|
{
|
||||||
private EntityGun? EntityGun;
|
private EntityGun? EntityGun;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -18,10 +18,6 @@ public class EntityAntiAircraftGun:EntityGun
|
|||||||
this.OptionalElementsColor = OptionalElementsColor;
|
this.OptionalElementsColor = OptionalElementsColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Длинна ствола
|
|
||||||
/// </summary>
|
|
||||||
public double BarrelLength { get; private set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Люк
|
/// Люк
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -30,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]));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -41,4 +41,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]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,10 +46,17 @@
|
|||||||
radioButtonMassive = new RadioButton();
|
radioButtonMassive = new RadioButton();
|
||||||
labelNameCollection = new Label();
|
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();
|
panelCompanyTools.SuspendLayout();
|
||||||
panelStorage.SuspendLayout();
|
panelStorage.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||||
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBox1
|
// groupBox1
|
||||||
@ -57,9 +64,9 @@
|
|||||||
groupBox1.Controls.Add(panelCompanyTools);
|
groupBox1.Controls.Add(panelCompanyTools);
|
||||||
groupBox1.Controls.Add(panelStorage);
|
groupBox1.Controls.Add(panelStorage);
|
||||||
groupBox1.Dock = DockStyle.Right;
|
groupBox1.Dock = DockStyle.Right;
|
||||||
groupBox1.Location = new Point(981, 0);
|
groupBox1.Location = new Point(981, 28);
|
||||||
groupBox1.Name = "groupBox1";
|
groupBox1.Name = "groupBox1";
|
||||||
groupBox1.Size = new Size(235, 772);
|
groupBox1.Size = new Size(235, 744);
|
||||||
groupBox1.TabIndex = 0;
|
groupBox1.TabIndex = 0;
|
||||||
groupBox1.TabStop = false;
|
groupBox1.TabStop = false;
|
||||||
groupBox1.Text = "Инструменты";
|
groupBox1.Text = "Инструменты";
|
||||||
@ -74,14 +81,14 @@
|
|||||||
panelCompanyTools.Controls.Add(maskedTextBox);
|
panelCompanyTools.Controls.Add(maskedTextBox);
|
||||||
panelCompanyTools.Controls.Add(buttonRemoveGun);
|
panelCompanyTools.Controls.Add(buttonRemoveGun);
|
||||||
panelCompanyTools.Dock = DockStyle.Bottom;
|
panelCompanyTools.Dock = DockStyle.Bottom;
|
||||||
panelCompanyTools.Location = new Point(3, 395);
|
panelCompanyTools.Location = new Point(3, 384);
|
||||||
panelCompanyTools.Name = "panelCompanyTools";
|
panelCompanyTools.Name = "panelCompanyTools";
|
||||||
panelCompanyTools.Size = new Size(229, 374);
|
panelCompanyTools.Size = new Size(229, 357);
|
||||||
panelCompanyTools.TabIndex = 9;
|
panelCompanyTools.TabIndex = 9;
|
||||||
//
|
//
|
||||||
// buttonCreateCompany
|
// buttonCreateCompany
|
||||||
//
|
//
|
||||||
buttonCreateCompany.Location = new Point(9, 40);
|
buttonCreateCompany.Location = new Point(9, 87);
|
||||||
buttonCreateCompany.Name = "buttonCreateCompany";
|
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||||
buttonCreateCompany.Size = new Size(217, 29);
|
buttonCreateCompany.Size = new Size(217, 29);
|
||||||
buttonCreateCompany.TabIndex = 8;
|
buttonCreateCompany.TabIndex = 8;
|
||||||
@ -95,7 +102,7 @@
|
|||||||
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxSelectorCompany.FormattingEnabled = true;
|
comboBoxSelectorCompany.FormattingEnabled = true;
|
||||||
comboBoxSelectorCompany.Items.AddRange(new object[] { "База" });
|
comboBoxSelectorCompany.Items.AddRange(new object[] { "База" });
|
||||||
comboBoxSelectorCompany.Location = new Point(9, 6);
|
comboBoxSelectorCompany.Location = new Point(9, 53);
|
||||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||||
comboBoxSelectorCompany.Size = new Size(214, 28);
|
comboBoxSelectorCompany.Size = new Size(214, 28);
|
||||||
comboBoxSelectorCompany.TabIndex = 0;
|
comboBoxSelectorCompany.TabIndex = 0;
|
||||||
@ -104,7 +111,7 @@
|
|||||||
// buttonAddGun
|
// buttonAddGun
|
||||||
//
|
//
|
||||||
buttonAddGun.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
buttonAddGun.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonAddGun.Location = new Point(9, 87);
|
buttonAddGun.Location = new Point(9, 122);
|
||||||
buttonAddGun.Name = "buttonAddGun";
|
buttonAddGun.Name = "buttonAddGun";
|
||||||
buttonAddGun.Size = new Size(214, 52);
|
buttonAddGun.Size = new Size(214, 52);
|
||||||
buttonAddGun.TabIndex = 1;
|
buttonAddGun.TabIndex = 1;
|
||||||
@ -239,12 +246,53 @@
|
|||||||
// 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(981, 772);
|
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);
|
||||||
@ -252,6 +300,8 @@
|
|||||||
ClientSize = new Size(1216, 772);
|
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);
|
||||||
@ -260,7 +310,10 @@
|
|||||||
panelStorage.ResumeLayout(false);
|
panelStorage.ResumeLayout(false);
|
||||||
panelStorage.PerformLayout();
|
panelStorage.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||||
|
menuStrip.ResumeLayout(false);
|
||||||
|
menuStrip.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -283,5 +336,11 @@
|
|||||||
private Button buttonCreateCompany;
|
private Button buttonCreateCompany;
|
||||||
private Button buttonCollectionDel;
|
private Button buttonCollectionDel;
|
||||||
private Panel panelCompanyTools;
|
private Panel panelCompanyTools;
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem файлToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem saveToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem downloadToolStripMenuItem;
|
||||||
|
private SaveFileDialog saveFileDialog;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -48,7 +48,7 @@ public partial class FormGunCollections : Form
|
|||||||
/// <param name="gun"></param>
|
/// <param name="gun"></param>
|
||||||
private void SetGun(DrawningGun gun)
|
private void SetGun(DrawningGun gun)
|
||||||
{
|
{
|
||||||
if (_company == null||gun==null) { return; }
|
if (_company == null || gun == null) { return; }
|
||||||
if (_company + gun)
|
if (_company + gun)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
@ -223,4 +223,40 @@ listBoxCollection.SelectedItem == null)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <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>
|
@ -1,5 +1,6 @@
|
|||||||
using AntiAircraftGun.Drawnings;
|
using AntiAircraftGun.Drawnings;
|
||||||
using AntiAircraftGun.Entities;
|
using AntiAircraftGun.Entities;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace AntiAircraftGun;
|
namespace AntiAircraftGun;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -14,7 +15,7 @@ public partial class FormGunConfig : Form
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Событие для передачи объекта
|
/// Событие для передачи объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private event GunDelegate? _gunDelegate;
|
private event Action<DrawningGun>? _gunDelegate;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
@ -38,7 +39,7 @@ public partial class FormGunConfig : Form
|
|||||||
/// Привязка внешнего метода к союытию
|
/// Привязка внешнего метода к союытию
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gunDelegate"></param>
|
/// <param name="gunDelegate"></param>
|
||||||
public void AddEvent(GunDelegate gunDelegate)
|
public void AddEvent(Action<DrawningGun> gunDelegate)
|
||||||
{
|
{
|
||||||
_gunDelegate += gunDelegate;
|
_gunDelegate += gunDelegate;
|
||||||
}
|
}
|
||||||
@ -63,7 +64,21 @@ public partial class FormGunConfig : Form
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void LabelOblect_MouseDown(object sender, MouseEventArgs e)
|
private void LabelOblect_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
|
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>
|
||||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||||
@ -72,7 +87,7 @@ public partial class FormGunConfig : Form
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void PanelObjects_DragEnter(object sender, DragEventArgs e)
|
private void PanelObjects_DragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
|
e.Effect = DragDropEffects.Copy;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Действия при приеме перетаскиваемой информации
|
/// Действия при приеме перетаскиваемой информации
|
||||||
@ -81,20 +96,13 @@ public partial class FormGunConfig : Form
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void PanelObjects_DragDrop(object sender, DragEventArgs e)
|
private void PanelObjects_DragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
|
if ((DrawningGun)e.Data.GetData(typeof(DrawningGun)) != null)
|
||||||
{
|
{
|
||||||
case "labelSimpleOblect":
|
_gun = (DrawningGun)e.Data.GetData(typeof(DrawningGun));
|
||||||
_gun = new DrawningGun((int)numericUpDownSpeed.Value,
|
}
|
||||||
(double)numericUpDownWeight.Value, Color.White);
|
else
|
||||||
break;
|
{
|
||||||
case "labelModifiedObject":
|
_gun = (DrawningAntiAircraftGun)e.Data.GetData(typeof(DrawningAntiAircraftGun));
|
||||||
Random random = new Random();
|
|
||||||
_gun = new
|
|
||||||
DrawningAntiAircraftGun((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value,
|
|
||||||
Color.White,
|
|
||||||
Color.Black, random.Next(10, 100),
|
|
||||||
checkBoxHatch.Checked, checkBoxRadar.Checked);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
DrawObject();
|
DrawObject();
|
||||||
}
|
}
|
||||||
@ -150,5 +158,6 @@ public partial class FormGunConfig : Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO Реализовать логику смены цветов: основного и дополнительного(для продвинутого объекта)
|
// TODO Реализовать логику смены цветов: основного и дополнительного(для продвинутого объекта)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user