diff --git a/AirBomber/CollectionGenericObjects/AbstractCompany.cs b/AirBomber/CollectionGenericObjects/AbstractCompany.cs
index 0c9b413..ab94fa9 100644
--- a/AirBomber/CollectionGenericObjects/AbstractCompany.cs
+++ b/AirBomber/CollectionGenericObjects/AbstractCompany.cs
@@ -53,7 +53,7 @@ public abstract class AbstractCompany
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = collection;
- _collection.SetMaxCount = GetMaxCount;
+ _collection.MaxCount = GetMaxCount;
}
///
diff --git a/AirBomber/CollectionGenericObjects/ICollectionGenericObjects.cs b/AirBomber/CollectionGenericObjects/ICollectionGenericObjects.cs
index 5bd7242..9fbf04c 100644
--- a/AirBomber/CollectionGenericObjects/ICollectionGenericObjects.cs
+++ b/AirBomber/CollectionGenericObjects/ICollectionGenericObjects.cs
@@ -1,4 +1,5 @@
-using System;
+using AirBomber.CollectionGenericObjects;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -15,7 +16,7 @@ public interface ICollectionGenericObjects
///
/// Установка максимального количества элементов
///
- int SetMaxCount { set; }
+ int MaxCount { get; set; }
///
/// Добавление объекта в коллекцию
@@ -45,4 +46,15 @@ public interface ICollectionGenericObjects
/// Позиция
/// Объект
T? Get(int position);
+
+ ///
+ /// Получение типа коллекции
+ ///
+ CollectionType GetCollectionType { get; }
+
+ ///
+ /// Поэлементный вывод элементов коллекции
+ ///
+ ///
+ IEnumerable GetItems();
}
diff --git a/AirBomber/CollectionGenericObjects/ListGenericObjects.cs b/AirBomber/CollectionGenericObjects/ListGenericObjects.cs
index 994f56e..0095cd6 100644
--- a/AirBomber/CollectionGenericObjects/ListGenericObjects.cs
+++ b/AirBomber/CollectionGenericObjects/ListGenericObjects.cs
@@ -16,7 +16,19 @@ public class ListGenericObjects : ICollectionGenericObjects
private int _maxCount;
public int Count => _collection.Count;
- public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
+ public int MaxCount
+ {
+ get => _maxCount;
+ set
+ {
+ if (value > 0)
+ {
+ _maxCount = value;
+ }
+ }
+ }
+
+ public CollectionType GetCollectionType => CollectionType.List;
///
/// Конструктор
@@ -64,4 +76,12 @@ public class ListGenericObjects : ICollectionGenericObjects
_collection.RemoveAt(position);
return obj;
}
+
+ public IEnumerable GetItems()
+ {
+ for (int i = 0; i < _collection.Count; ++i)
+ {
+ yield return _collection[i];
+ }
+ }
}
\ No newline at end of file
diff --git a/AirBomber/CollectionGenericObjects/MassiveGenericObjects.cs b/AirBomber/CollectionGenericObjects/MassiveGenericObjects.cs
index 51ce63d..83c40dc 100644
--- a/AirBomber/CollectionGenericObjects/MassiveGenericObjects.cs
+++ b/AirBomber/CollectionGenericObjects/MassiveGenericObjects.cs
@@ -15,8 +15,12 @@ where T : class
public int Count => _collection.Length;
- public int SetMaxCount
+ public int MaxCount
{
+ get
+ {
+ return _collection.Length;
+ }
set
{
if (value > 0)
@@ -33,6 +37,8 @@ where T : class
}
}
+ public CollectionType GetCollectionType => CollectionType.Massive;
+
///
/// Конструктор
///
@@ -106,4 +112,12 @@ where T : class
_collection[position] = null;
return obj;
}
+
+ public IEnumerable GetItems()
+ {
+ for (int i = 0; i < _collection.Length; ++i)
+ {
+ yield return _collection[i];
+ }
+ }
}
\ No newline at end of file
diff --git a/AirBomber/CollectionGenericObjects/StorageCollection.cs b/AirBomber/CollectionGenericObjects/StorageCollection.cs
index affbd6d..0939a98 100644
--- a/AirBomber/CollectionGenericObjects/StorageCollection.cs
+++ b/AirBomber/CollectionGenericObjects/StorageCollection.cs
@@ -1,4 +1,5 @@
-using System;
+using AirBomber.Drawnings;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -10,7 +11,7 @@ namespace AirBomber.CollectionGenericObjects;
///
///
public class StorageCollection
- where T : class
+ where T : DrawningAirPlane
{
///
/// Словарь (хранилище) с коллекциями
@@ -22,6 +23,21 @@ public class StorageCollection
///
public List Keys => _storages.Keys.ToList();
+ ///
+ /// Ключевое слово, с которого должен начинаться файл
+ ///
+ private readonly string _collectionKey = "CollectionsStorage";
+
+ ///
+ /// Разделитель для записи ключа и значения элемента словаря
+ ///
+ private readonly string _separatorForKeyValue = "|";
+
+ ///
+ /// Разделитель для записей коллекции данных в файл
+ ///
+ private readonly string _separatorItems = ";";
+
///
/// Конструктор
///
@@ -83,4 +99,118 @@ public class StorageCollection
return null;
}
}
+
+ ///
+ /// Сохранение информации по автомобилям в хранилище в файл
+ ///
+ /// Путь и имя файла
+ /// true - сохранение прошло успешно, false - ошибка при сохранении данных
+ public bool SaveData(string filename)
+ {
+ if (_storages.Count == 0)
+ {
+ return false;
+ }
+
+ if (File.Exists(filename))
+ {
+ File.Delete(filename);
+ }
+
+ StringBuilder sb = new();
+
+ using (StreamWriter sw = new StreamWriter(filename))
+ {
+ sw.WriteLine(_collectionKey.ToString());
+ foreach (KeyValuePair> kvpair in _storages)
+ {
+ // не сохраняем пустые коллекции
+ if (kvpair.Value.Count == 0)
+ continue;
+ sb.Append(kvpair.Key);
+ sb.Append(_separatorForKeyValue);
+ sb.Append(kvpair.Value.GetCollectionType);
+ sb.Append(_separatorForKeyValue);
+ sb.Append(kvpair.Value.MaxCount);
+ sb.Append(_separatorForKeyValue);
+ foreach (T? item in kvpair.Value.GetItems())
+ {
+ string data = item?.GetDataForSave() ?? string.Empty;
+ if (string.IsNullOrEmpty(data))
+ continue;
+ sb.Append(data);
+ sb.Append(_separatorItems);
+ }
+ sw.WriteLine(sb.ToString());
+ sb.Clear();
+ }
+ }
+ return true;
+ }
+
+ ///
+ /// Загрузка информации по автомобилям в хранилище из файла
+ ///
+ /// Путь и имя файла
+ /// true - загрузка прошла успешно, false - ошибка при загрузке данных
+ public bool LoadData(string filename)
+ {
+ if (!File.Exists(filename))
+ {
+ return false;
+ }
+
+ using (StreamReader sr = new StreamReader(filename))
+ {
+ string? str;
+ str = sr.ReadLine();
+ if (str != _collectionKey.ToString())
+ return false;
+ _storages.Clear();
+ while ((str = sr.ReadLine()) != null)
+ {
+ string[] record = str.Split(_separatorForKeyValue);
+ if (record.Length != 4)
+ {
+ continue;
+ }
+ CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
+ ICollectionGenericObjects? collection = StorageCollection.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?.CreateDrawningAirPlane() is T boat)
+ {
+ if (collection.Insert(boat) == -1)
+ return false;
+ }
+ }
+ _storages.Add(record[0], collection);
+ }
+ }
+
+ return true;
+ }
+
+ ///
+ /// Создание коллекции по типу
+ ///
+ ///
+ ///
+ private static ICollectionGenericObjects? CreateCollection(CollectionType collectionType)
+ {
+ return collectionType switch
+ {
+ CollectionType.Massive => new MassiveGenericObjects(),
+ CollectionType.List => new ListGenericObjects(),
+ _ => null,
+ };
+ }
}
\ No newline at end of file
diff --git a/AirBomber/Drawnings/DrawningAirBomber.cs b/AirBomber/Drawnings/DrawningAirBomber.cs
index 5ed5eb7..f303fd4 100644
--- a/AirBomber/Drawnings/DrawningAirBomber.cs
+++ b/AirBomber/Drawnings/DrawningAirBomber.cs
@@ -28,6 +28,14 @@ public class DrawningAirBomber : DrawningAirPlane
EntityAirPlane = new EntityAirBomber(speed, weight, bodyColor, additionalColor, bombs, fuelTanks);
}
+ ///
+ /// Конструктор через сущность
+ ///
+ ///
+ public DrawningAirBomber(EntityAirPlane entityAirPlane) : base()
+ {
+ EntityAirPlane = entityAirPlane;
+ }
public override void DrawTransport(Graphics g)
{
if (EntityAirPlane == null || EntityAirPlane is not EntityAirBomber airbomber || !_startPosX.HasValue || !_startPosY.HasValue)
diff --git a/AirBomber/Drawnings/DrawningAirPlane.cs b/AirBomber/Drawnings/DrawningAirPlane.cs
index 460ebed..9a27fc1 100644
--- a/AirBomber/Drawnings/DrawningAirPlane.cs
+++ b/AirBomber/Drawnings/DrawningAirPlane.cs
@@ -69,7 +69,7 @@ public class DrawningAirPlane
/// Пустой конструктор
///
///
- private DrawningAirPlane()
+ protected DrawningAirPlane()
{
_pictureHeight = null;
_pictureHeight = null;
@@ -92,11 +92,20 @@ public class DrawningAirPlane
///
/// Ширина прорисовки самолета
/// Высота прорисовки самолета
- protected DrawningAirPlane(int drawningAirBomberWidth, int drawningAirBomberHeight) : this()
+ public DrawningAirPlane(int drawningAirBomberWidth, int drawningAirBomberHeight) : this()
{
_drawningAirPlaneHeight = drawningAirBomberHeight;
_drawningAirPlaneWidth = drawningAirBomberWidth;
}
+
+ ///
+ /// Конструктор через сущность
+ ///
+ ///
+ public DrawningAirPlane(EntityAirPlane entityAirPlane) : base()
+ {
+ EntityAirPlane = entityAirPlane;
+ }
///
/// Установка границ поля
diff --git a/AirBomber/Drawnings/ExtentionDrawningAirPlane.cs b/AirBomber/Drawnings/ExtentionDrawningAirPlane.cs
new file mode 100644
index 0000000..0edb02c
--- /dev/null
+++ b/AirBomber/Drawnings/ExtentionDrawningAirPlane.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using AirBomber.Entities;
+
+namespace AirBomber.Drawnings;
+
+public static class ExtentionDrawningAirPlane
+{
+ ///
+ /// Разделитель для записи информации по объекту в файл
+ ///
+ private static readonly string _separatorForObject = ":";
+
+ ///
+ /// Создание объекта из строки
+ ///
+ /// Строка с данными для создания объекта
+ /// Объект
+ public static DrawningAirPlane? CreateDrawningAirPlane(this string info)
+ {
+ string[] strs = info.Split(_separatorForObject);
+ EntityAirPlane? airPlane = EntityAirBomber.CreateEntityAirBomber(strs);
+ if (airPlane != null)
+ {
+ return new DrawningAirBomber(airPlane);
+ }
+
+ airPlane = EntityAirPlane.CreateEntityAirPlane(strs);
+ if (airPlane != null)
+ {
+ return new DrawningAirPlane(airPlane);
+ }
+
+ return null;
+ }
+
+ ///
+ /// Получение данных для сохранения в файл
+ ///
+ /// Сохраняемый объект
+ /// Строка с данными по объекту
+ public static string GetDataForSave(this DrawningAirPlane drawningAirPlane)
+ {
+ string[]? array = drawningAirPlane?.EntityAirPlane?.GetStringRepresentation();
+
+ if (array == null)
+ {
+ return string.Empty;
+ }
+
+ return string.Join(_separatorForObject, array);
+ }
+}
diff --git a/AirBomber/Entities/EntityAirBomber.cs b/AirBomber/Entities/EntityAirBomber.cs
index 4d70a7b..bcaf3bc 100644
--- a/AirBomber/Entities/EntityAirBomber.cs
+++ b/AirBomber/Entities/EntityAirBomber.cs
@@ -37,4 +37,19 @@ public class EntityAirBomber : EntityAirPlane
Bombs = bombs;
FuelTanks = fuelTanks;
}
+
+ public override string[] GetStringRepresentation()
+ {
+ return new[] { nameof(EntityAirBomber), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name, Bombs.ToString(), FuelTanks.ToString() };
+ }
+
+ public static EntityAirBomber? CreateEntityAirBomber(string[] strs)
+ {
+ if (strs.Length != 7 || strs[0] != nameof(EntityAirBomber))
+ {
+ return null;
+ }
+ return new EntityAirBomber(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]),
+ Color.FromName(strs[3]), Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]));
+ }
}
diff --git a/AirBomber/Entities/EntityAirPlane.cs b/AirBomber/Entities/EntityAirPlane.cs
index f358d6c..cafec64 100644
--- a/AirBomber/Entities/EntityAirPlane.cs
+++ b/AirBomber/Entities/EntityAirPlane.cs
@@ -42,4 +42,28 @@ public class EntityAirPlane
Weight = weight;
BodyColor = bodyColor;
}
+
+ ///
+ /// Получение строк со значениями свойств объекта класса-сущности
+ ///
+ ///
+ public virtual string[] GetStringRepresentation()
+ {
+ return new[] { nameof(EntityAirPlane), Speed.ToString(), Weight.ToString(), BodyColor.Name };
+ }
+
+ ///
+ /// Создание объекта из массива строк
+ ///
+ ///
+ ///
+ public static EntityAirPlane? CreateEntityAirPlane(string[] strs)
+ {
+ if (strs.Length != 4 || strs[0] != nameof(EntityAirPlane))
+ {
+ return null;
+ }
+
+ return new EntityAirPlane(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
+ }
}
diff --git a/AirBomber/FormAirPlaneCollection.Designer.cs b/AirBomber/FormAirPlaneCollection.Designer.cs
index 4a35aed..97259d8 100644
--- a/AirBomber/FormAirPlaneCollection.Designer.cs
+++ b/AirBomber/FormAirPlaneCollection.Designer.cs
@@ -46,10 +46,17 @@
labelCollectionName = new Label();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
+ menuStrip = new MenuStrip();
+ файлToolStripMenuItem = new ToolStripMenuItem();
+ saveToolStripMenuItem = new ToolStripMenuItem();
+ loadToolStripMenuItem = new ToolStripMenuItem();
+ saveFileDialog = new SaveFileDialog();
+ openFileDialog = new OpenFileDialog();
groupBoxTools.SuspendLayout();
panelCompanyTools.SuspendLayout();
panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
+ menuStrip.SuspendLayout();
SuspendLayout();
//
// groupBoxTools
@@ -59,9 +66,11 @@
groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
- groupBoxTools.Location = new Point(752, 0);
+ groupBoxTools.Location = new Point(859, 0);
+ groupBoxTools.Margin = new Padding(3, 4, 3, 4);
groupBoxTools.Name = "groupBoxTools";
- groupBoxTools.Size = new Size(208, 644);
+ groupBoxTools.Padding = new Padding(3, 4, 3, 4);
+ groupBoxTools.Size = new Size(238, 859);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструманты";
@@ -73,18 +82,18 @@
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(buttonDelAirPlane);
panelCompanyTools.Controls.Add(buttonGoToCheck);
- panelCompanyTools.Location = new Point(14, 342);
- panelCompanyTools.Margin = new Padding(3, 2, 3, 2);
+ panelCompanyTools.Location = new Point(16, 456);
panelCompanyTools.Name = "panelCompanyTools";
- panelCompanyTools.Size = new Size(184, 214);
+ panelCompanyTools.Size = new Size(210, 285);
panelCompanyTools.TabIndex = 8;
//
// buttonAddAirPlane
//
buttonAddAirPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonAddAirPlane.Location = new Point(6, 3);
+ buttonAddAirPlane.Location = new Point(7, 4);
+ buttonAddAirPlane.Margin = new Padding(3, 4, 3, 4);
buttonAddAirPlane.Name = "buttonAddAirPlane";
- buttonAddAirPlane.Size = new Size(175, 41);
+ buttonAddAirPlane.Size = new Size(200, 55);
buttonAddAirPlane.TabIndex = 1;
buttonAddAirPlane.Text = "Добавление самолета";
buttonAddAirPlane.UseVisualStyleBackColor = true;
@@ -92,18 +101,20 @@
//
// maskedTextBox
//
- maskedTextBox.Location = new Point(6, 98);
+ maskedTextBox.Location = new Point(7, 131);
+ maskedTextBox.Margin = new Padding(3, 4, 3, 4);
maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
- maskedTextBox.Size = new Size(176, 23);
+ maskedTextBox.Size = new Size(201, 27);
maskedTextBox.TabIndex = 3;
maskedTextBox.ValidatingType = typeof(int);
//
// buttonRefresh
//
- buttonRefresh.Location = new Point(6, 182);
+ buttonRefresh.Location = new Point(7, 243);
+ buttonRefresh.Margin = new Padding(3, 4, 3, 4);
buttonRefresh.Name = "buttonRefresh";
- buttonRefresh.Size = new Size(175, 22);
+ buttonRefresh.Size = new Size(200, 29);
buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
@@ -112,9 +123,10 @@
// buttonDelAirPlane
//
buttonDelAirPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- buttonDelAirPlane.Location = new Point(6, 124);
+ buttonDelAirPlane.Location = new Point(7, 165);
+ buttonDelAirPlane.Margin = new Padding(3, 4, 3, 4);
buttonDelAirPlane.Name = "buttonDelAirPlane";
- buttonDelAirPlane.Size = new Size(175, 23);
+ buttonDelAirPlane.Size = new Size(200, 31);
buttonDelAirPlane.TabIndex = 4;
buttonDelAirPlane.Text = "Удалить Самолет";
buttonDelAirPlane.UseVisualStyleBackColor = true;
@@ -122,9 +134,10 @@
//
// buttonGoToCheck
//
- buttonGoToCheck.Location = new Point(6, 154);
+ buttonGoToCheck.Location = new Point(7, 205);
+ buttonGoToCheck.Margin = new Padding(3, 4, 3, 4);
buttonGoToCheck.Name = "buttonGoToCheck";
- buttonGoToCheck.Size = new Size(175, 22);
+ buttonGoToCheck.Size = new Size(200, 29);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
@@ -132,10 +145,9 @@
//
// buttonCreateCompany
//
- buttonCreateCompany.Location = new Point(14, 274);
- buttonCreateCompany.Margin = new Padding(3, 2, 3, 2);
+ buttonCreateCompany.Location = new Point(16, 365);
buttonCreateCompany.Name = "buttonCreateCompany";
- buttonCreateCompany.Size = new Size(181, 37);
+ buttonCreateCompany.Size = new Size(207, 49);
buttonCreateCompany.TabIndex = 7;
buttonCreateCompany.Text = "Создать компанию";
buttonCreateCompany.UseVisualStyleBackColor = true;
@@ -151,18 +163,16 @@
panelStorage.Controls.Add(textBoxCollectionName);
panelStorage.Controls.Add(labelCollectionName);
panelStorage.Dock = DockStyle.Top;
- panelStorage.Location = new Point(3, 19);
- panelStorage.Margin = new Padding(3, 2, 3, 2);
+ panelStorage.Location = new Point(3, 24);
panelStorage.Name = "panelStorage";
- panelStorage.Size = new Size(202, 228);
+ panelStorage.Size = new Size(232, 304);
panelStorage.TabIndex = 7;
//
// buttonCollectionDel
//
- buttonCollectionDel.Location = new Point(11, 203);
- buttonCollectionDel.Margin = new Padding(3, 2, 3, 2);
+ buttonCollectionDel.Location = new Point(13, 271);
buttonCollectionDel.Name = "buttonCollectionDel";
- buttonCollectionDel.Size = new Size(184, 22);
+ buttonCollectionDel.Size = new Size(210, 29);
buttonCollectionDel.TabIndex = 6;
buttonCollectionDel.Text = "Удалить коллецию";
buttonCollectionDel.UseVisualStyleBackColor = true;
@@ -171,19 +181,17 @@
// listBoxCollection
//
listBoxCollection.FormattingEnabled = true;
- listBoxCollection.ItemHeight = 15;
- listBoxCollection.Location = new Point(3, 121);
- listBoxCollection.Margin = new Padding(3, 2, 3, 2);
+ listBoxCollection.ItemHeight = 20;
+ listBoxCollection.Location = new Point(3, 161);
listBoxCollection.Name = "listBoxCollection";
- listBoxCollection.Size = new Size(193, 79);
+ listBoxCollection.Size = new Size(220, 104);
listBoxCollection.TabIndex = 5;
//
// buttonCollectionAdd
//
- buttonCollectionAdd.Location = new Point(11, 94);
- buttonCollectionAdd.Margin = new Padding(3, 2, 3, 2);
+ buttonCollectionAdd.Location = new Point(13, 125);
buttonCollectionAdd.Name = "buttonCollectionAdd";
- buttonCollectionAdd.Size = new Size(189, 22);
+ buttonCollectionAdd.Size = new Size(216, 29);
buttonCollectionAdd.TabIndex = 4;
buttonCollectionAdd.Text = "Добавить коллецию";
buttonCollectionAdd.UseVisualStyleBackColor = true;
@@ -192,10 +200,9 @@
// radioButtonList
//
radioButtonList.AutoSize = true;
- radioButtonList.Location = new Point(88, 72);
- radioButtonList.Margin = new Padding(3, 2, 3, 2);
+ radioButtonList.Location = new Point(101, 96);
radioButtonList.Name = "radioButtonList";
- radioButtonList.Size = new Size(66, 19);
+ radioButtonList.Size = new Size(80, 24);
radioButtonList.TabIndex = 3;
radioButtonList.TabStop = true;
radioButtonList.Text = "Список";
@@ -204,10 +211,9 @@
// radioButtonMassive
//
radioButtonMassive.AutoSize = true;
- radioButtonMassive.Location = new Point(11, 72);
- radioButtonMassive.Margin = new Padding(3, 2, 3, 2);
+ radioButtonMassive.Location = new Point(13, 96);
radioButtonMassive.Name = "radioButtonMassive";
- radioButtonMassive.Size = new Size(67, 19);
+ radioButtonMassive.Size = new Size(82, 24);
radioButtonMassive.TabIndex = 2;
radioButtonMassive.TabStop = true;
radioButtonMassive.Text = "Массив";
@@ -215,18 +221,17 @@
//
// textBoxCollectionName
//
- textBoxCollectionName.Location = new Point(3, 40);
- textBoxCollectionName.Margin = new Padding(3, 2, 3, 2);
+ textBoxCollectionName.Location = new Point(3, 53);
textBoxCollectionName.Name = "textBoxCollectionName";
- textBoxCollectionName.Size = new Size(198, 23);
+ textBoxCollectionName.Size = new Size(226, 27);
textBoxCollectionName.TabIndex = 1;
//
// labelCollectionName
//
labelCollectionName.AutoSize = true;
- labelCollectionName.Location = new Point(11, 9);
+ labelCollectionName.Location = new Point(13, 12);
labelCollectionName.Name = "labelCollectionName";
- labelCollectionName.Size = new Size(119, 15);
+ labelCollectionName.Size = new Size(151, 20);
labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллеции:";
//
@@ -236,9 +241,10 @@
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
- comboBoxSelectorCompany.Location = new Point(14, 248);
+ comboBoxSelectorCompany.Location = new Point(16, 331);
+ comboBoxSelectorCompany.Margin = new Padding(3, 4, 3, 4);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
- comboBoxSelectorCompany.Size = new Size(184, 23);
+ comboBoxSelectorCompany.Size = new Size(210, 28);
comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged;
//
@@ -246,18 +252,64 @@
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
+ pictureBox.Margin = new Padding(3, 4, 3, 4);
pictureBox.Name = "pictureBox";
- pictureBox.Size = new Size(752, 644);
+ pictureBox.Size = new Size(859, 859);
pictureBox.TabIndex = 1;
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.Padding = new Padding(7, 3, 0, 3);
+ menuStrip.Size = new Size(859, 30);
+ menuStrip.TabIndex = 3;
+ menuStrip.Text = "menuStrip1";
+ //
+ // файлToolStripMenuItem
+ //
+ файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
+ файлToolStripMenuItem.Name = "файлToolStripMenuItem";
+ файлToolStripMenuItem.Size = new Size(59, 24);
+ файлToolStripMenuItem.Text = "Файл";
+ файлToolStripMenuItem.Click += saveToolStripMenuItem_Click;
+ //
+ // saveToolStripMenuItem
+ //
+ saveToolStripMenuItem.Name = "saveToolStripMenuItem";
+ saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
+ saveToolStripMenuItem.Size = new Size(227, 26);
+ saveToolStripMenuItem.Text = "Сохранение";
+ saveToolStripMenuItem.Click += saveToolStripMenuItem_Click;
+ //
+ // loadToolStripMenuItem
+ //
+ loadToolStripMenuItem.Name = "loadToolStripMenuItem";
+ loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
+ loadToolStripMenuItem.Size = new Size(227, 26);
+ loadToolStripMenuItem.Text = "Загрузка";
+ loadToolStripMenuItem.Click += loadToolStripMenuItem_Click;
+ //
+ // saveFileDialog
+ //
+ saveFileDialog.Filter = "txt file | *.txt";
+ //
+ // openFileDialog
+ //
+ openFileDialog.Filter = "txt file | *.txt";
+ //
// FormAirPlaneCollection
//
- AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(960, 644);
+ ClientSize = new Size(1097, 859);
+ Controls.Add(menuStrip);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
+ Margin = new Padding(3, 4, 3, 4);
Name = "FormAirPlaneCollection";
Text = "FormAirPlaneCollection";
Load += FormAirPlaneCollection_Load;
@@ -267,7 +319,10 @@
panelStorage.ResumeLayout(false);
panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
+ menuStrip.ResumeLayout(false);
+ menuStrip.PerformLayout();
ResumeLayout(false);
+ PerformLayout();
}
#endregion
@@ -290,5 +345,11 @@
private ListBox listBoxCollection;
private Button buttonCreateCompany;
private Panel panelCompanyTools;
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem файлToolStripMenuItem;
+ private ToolStripMenuItem saveToolStripMenuItem;
+ private ToolStripMenuItem loadToolStripMenuItem;
+ private SaveFileDialog saveFileDialog;
+ private OpenFileDialog openFileDialog;
}
}
\ No newline at end of file
diff --git a/AirBomber/FormAirPlaneCollection.cs b/AirBomber/FormAirPlaneCollection.cs
index 805f200..873daa6 100644
--- a/AirBomber/FormAirPlaneCollection.cs
+++ b/AirBomber/FormAirPlaneCollection.cs
@@ -47,7 +47,7 @@ namespace AirBomber
/// Создание объекта класса-перемещения
///
/// Тип создаваемого объекта
-
+
///
/// Добавление самолета
@@ -72,7 +72,7 @@ namespace AirBomber
{
return;
}
-
+
if (_company + airplane != -1)
{
MessageBox.Show("Объект добавлен");
@@ -263,5 +263,46 @@ namespace AirBomber
panelCompanyTools.Enabled = true;
RefreshListBoxItems();
}
+
+ ///
+ /// Обработка нажатия "Сохранение"
+ ///
+ ///
+ ///
+ private void saveToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (saveFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (_storageCollection.SaveData(saveFileDialog.FileName))
+ {
+ MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ ///
+ /// Обработка кнопки загрузки
+ ///
+ ///
+ ///
+ private void loadToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (openFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (_storageCollection.LoadData(openFileDialog.FileName))
+ {
+ RefreshListBoxItems();
+ MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ MessageBox.Show("Загрузка не выполнена", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
}
}
diff --git a/AirBomber/FormAirPlaneCollection.resx b/AirBomber/FormAirPlaneCollection.resx
index a395bff..8b1dfa1 100644
--- a/AirBomber/FormAirPlaneCollection.resx
+++ b/AirBomber/FormAirPlaneCollection.resx
@@ -18,7 +18,7 @@
System.Resources.ResXResourceReader, System.Windows.Forms, ...
System.Resources.ResXResourceWriter, System.Windows.Forms, ...
this is my long stringthis is a comment
- Blue
+ Blue
[base64 mime encoded serialized .NET Framework object]
@@ -117,4 +117,13 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 17, 17
+
+
+ 126, 17
+
+
+ 261, 17
+
\ No newline at end of file
diff --git a/AirBomber/FormAirPlaneConfig.Designer.cs b/AirBomber/FormAirPlaneConfig.Designer.cs
index 9218787..d1a29fc 100644
--- a/AirBomber/FormAirPlaneConfig.Designer.cs
+++ b/AirBomber/FormAirPlaneConfig.Designer.cs
@@ -73,10 +73,8 @@
groupBoxConfig.Controls.Add(labelSimpleObject);
groupBoxConfig.Dock = DockStyle.Left;
groupBoxConfig.Location = new Point(0, 0);
- groupBoxConfig.Margin = new Padding(3, 4, 3, 4);
groupBoxConfig.Name = "groupBoxConfig";
- groupBoxConfig.Padding = new Padding(3, 4, 3, 4);
- groupBoxConfig.Size = new Size(629, 346);
+ groupBoxConfig.Size = new Size(550, 260);
groupBoxConfig.TabIndex = 0;
groupBoxConfig.TabStop = false;
groupBoxConfig.Text = "Параметры";
@@ -91,11 +89,9 @@
groupBoxColors.Controls.Add(panelWhite);
groupBoxColors.Controls.Add(panelGreen);
groupBoxColors.Controls.Add(panelRed);
- groupBoxColors.Location = new Point(360, 16);
- groupBoxColors.Margin = new Padding(3, 4, 3, 4);
+ groupBoxColors.Location = new Point(315, 12);
groupBoxColors.Name = "groupBoxColors";
- groupBoxColors.Padding = new Padding(3, 4, 3, 4);
- groupBoxColors.Size = new Size(259, 149);
+ groupBoxColors.Size = new Size(227, 112);
groupBoxColors.TabIndex = 11;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "Цвета";
@@ -103,83 +99,74 @@
// panelPurple
//
panelPurple.BackColor = Color.Purple;
- panelPurple.Location = new Point(201, 88);
- panelPurple.Margin = new Padding(3, 4, 3, 4);
+ panelPurple.Location = new Point(176, 66);
panelPurple.Name = "panelPurple";
- panelPurple.Size = new Size(39, 45);
+ panelPurple.Size = new Size(34, 34);
panelPurple.TabIndex = 3;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
- panelYellow.Location = new Point(201, 29);
- panelYellow.Margin = new Padding(3, 4, 3, 4);
+ panelYellow.Location = new Point(176, 22);
panelYellow.Name = "panelYellow";
- panelYellow.Size = new Size(39, 45);
+ panelYellow.Size = new Size(34, 34);
panelYellow.TabIndex = 1;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
- panelBlack.Location = new Point(137, 88);
- panelBlack.Margin = new Padding(3, 4, 3, 4);
+ panelBlack.Location = new Point(120, 66);
panelBlack.Name = "panelBlack";
- panelBlack.Size = new Size(39, 45);
+ panelBlack.Size = new Size(34, 34);
panelBlack.TabIndex = 4;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
- panelGray.Location = new Point(77, 88);
- panelGray.Margin = new Padding(3, 4, 3, 4);
+ panelGray.Location = new Point(67, 66);
panelGray.Name = "panelGray";
- panelGray.Size = new Size(39, 45);
+ panelGray.Size = new Size(34, 34);
panelGray.TabIndex = 5;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
- panelBlue.Location = new Point(137, 29);
- panelBlue.Margin = new Padding(3, 4, 3, 4);
+ panelBlue.Location = new Point(120, 22);
panelBlue.Name = "panelBlue";
- panelBlue.Size = new Size(39, 45);
+ panelBlue.Size = new Size(34, 34);
panelBlue.TabIndex = 1;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
- panelWhite.Location = new Point(17, 88);
- panelWhite.Margin = new Padding(3, 4, 3, 4);
+ panelWhite.Location = new Point(15, 66);
panelWhite.Name = "panelWhite";
- panelWhite.Size = new Size(39, 45);
+ panelWhite.Size = new Size(34, 34);
panelWhite.TabIndex = 2;
//
// panelGreen
//
panelGreen.BackColor = Color.Green;
- panelGreen.Location = new Point(77, 29);
- panelGreen.Margin = new Padding(3, 4, 3, 4);
+ panelGreen.Location = new Point(67, 22);
panelGreen.Name = "panelGreen";
- panelGreen.Size = new Size(39, 45);
+ panelGreen.Size = new Size(34, 34);
panelGreen.TabIndex = 1;
//
// panelRed
//
panelRed.BackColor = Color.Red;
- panelRed.Location = new Point(17, 29);
- panelRed.Margin = new Padding(3, 4, 3, 4);
+ panelRed.Location = new Point(15, 22);
panelRed.Name = "panelRed";
- panelRed.Size = new Size(39, 45);
+ panelRed.Size = new Size(34, 34);
panelRed.TabIndex = 0;
panelRed.MouseDown += Panel_MouseDown;
//
// checkBoxFuelTanks
//
checkBoxFuelTanks.AutoSize = true;
- checkBoxFuelTanks.Location = new Point(14, 237);
- checkBoxFuelTanks.Margin = new Padding(3, 4, 3, 4);
+ checkBoxFuelTanks.Location = new Point(12, 178);
checkBoxFuelTanks.Name = "checkBoxFuelTanks";
- checkBoxFuelTanks.Size = new Size(312, 24);
+ checkBoxFuelTanks.Size = new Size(248, 19);
checkBoxFuelTanks.TabIndex = 7;
checkBoxFuelTanks.Text = "Признак наличия доп. топливных баков";
checkBoxFuelTanks.UseVisualStyleBackColor = true;
@@ -187,60 +174,57 @@
// checkBoxBombs
//
checkBoxBombs.AutoSize = true;
- checkBoxBombs.Location = new Point(14, 176);
- checkBoxBombs.Margin = new Padding(3, 4, 3, 4);
+ checkBoxBombs.Location = new Point(12, 132);
checkBoxBombs.Name = "checkBoxBombs";
- checkBoxBombs.Size = new Size(196, 24);
+ checkBoxBombs.Size = new Size(156, 19);
checkBoxBombs.TabIndex = 6;
checkBoxBombs.Text = "Признак наличия бомб";
checkBoxBombs.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
- numericUpDownWeight.Location = new Point(91, 109);
- numericUpDownWeight.Margin = new Padding(3, 4, 3, 4);
+ numericUpDownWeight.Location = new Point(80, 82);
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(101, 27);
+ numericUpDownWeight.Size = new Size(88, 23);
numericUpDownWeight.TabIndex = 5;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelWeight
//
labelWeight.AutoSize = true;
- labelWeight.Location = new Point(14, 112);
+ labelWeight.Location = new Point(12, 84);
labelWeight.Name = "labelWeight";
- labelWeight.Size = new Size(36, 20);
+ labelWeight.Size = new Size(29, 15);
labelWeight.TabIndex = 4;
labelWeight.Text = "Вес:";
//
// numericUpDownSpeed
//
- numericUpDownSpeed.Location = new Point(91, 51);
- numericUpDownSpeed.Margin = new Padding(3, 4, 3, 4);
+ numericUpDownSpeed.Location = new Point(80, 38);
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(101, 27);
+ numericUpDownSpeed.Size = new Size(88, 23);
numericUpDownSpeed.TabIndex = 3;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelSpeed
//
labelSpeed.AutoSize = true;
- labelSpeed.Location = new Point(14, 53);
+ labelSpeed.Location = new Point(12, 40);
labelSpeed.Name = "labelSpeed";
- labelSpeed.Size = new Size(76, 20);
+ labelSpeed.Size = new Size(62, 15);
labelSpeed.TabIndex = 2;
labelSpeed.Text = "Скорость:";
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
- labelModifiedObject.Location = new Point(466, 222);
+ labelModifiedObject.Location = new Point(408, 166);
labelModifiedObject.Name = "labelModifiedObject";
- labelModifiedObject.Size = new Size(117, 53);
+ labelModifiedObject.Size = new Size(103, 40);
labelModifiedObject.TabIndex = 1;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
@@ -249,9 +233,9 @@
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
- labelSimpleObject.Location = new Point(330, 222);
+ labelSimpleObject.Location = new Point(289, 166);
labelSimpleObject.Name = "labelSimpleObject";
- labelSimpleObject.Size = new Size(117, 53);
+ labelSimpleObject.Size = new Size(103, 40);
labelSimpleObject.TabIndex = 0;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
@@ -259,19 +243,17 @@
//
// pictureBoxObject
//
- pictureBoxObject.Location = new Point(15, 69);
- pictureBoxObject.Margin = new Padding(3, 4, 3, 4);
+ pictureBoxObject.Location = new Point(13, 45);
pictureBoxObject.Name = "pictureBoxObject";
- pictureBoxObject.Size = new Size(194, 161);
+ pictureBoxObject.Size = new Size(170, 136);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
// buttonAdd
//
- buttonAdd.Location = new Point(672, 254);
- buttonAdd.Margin = new Padding(3, 4, 3, 4);
+ buttonAdd.Location = new Point(588, 190);
buttonAdd.Name = "buttonAdd";
- buttonAdd.Size = new Size(101, 53);
+ buttonAdd.Size = new Size(88, 40);
buttonAdd.TabIndex = 2;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
@@ -279,10 +261,9 @@
//
// buttonCancel
//
- buttonCancel.Location = new Point(786, 254);
- buttonCancel.Margin = new Padding(3, 4, 3, 4);
+ buttonCancel.Location = new Point(688, 190);
buttonCancel.Name = "buttonCancel";
- buttonCancel.Size = new Size(102, 53);
+ buttonCancel.Size = new Size(89, 40);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
@@ -293,10 +274,9 @@
panelObject.Controls.Add(labelBodyColor);
panelObject.Controls.Add(labelAdditionalColor);
panelObject.Controls.Add(pictureBoxObject);
- panelObject.Location = new Point(679, 0);
- panelObject.Margin = new Padding(3, 4, 3, 4);
+ panelObject.Location = new Point(594, 0);
panelObject.Name = "panelObject";
- panelObject.Size = new Size(222, 246);
+ panelObject.Size = new Size(194, 184);
panelObject.TabIndex = 4;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
@@ -305,9 +285,9 @@
//
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
- labelBodyColor.Location = new Point(15, 12);
+ labelBodyColor.Location = new Point(13, 9);
labelBodyColor.Name = "labelBodyColor";
- labelBodyColor.Size = new Size(85, 43);
+ labelBodyColor.Size = new Size(75, 33);
labelBodyColor.TabIndex = 2;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
@@ -318,9 +298,9 @@
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
- labelAdditionalColor.Location = new Point(123, 12);
+ labelAdditionalColor.Location = new Point(108, 9);
labelAdditionalColor.Name = "labelAdditionalColor";
- labelAdditionalColor.Size = new Size(85, 43);
+ labelAdditionalColor.Size = new Size(75, 33);
labelAdditionalColor.TabIndex = 3;
labelAdditionalColor.Text = "Доп. Цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
@@ -329,14 +309,13 @@
//
// FormAirPlaneConfig
//
- AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(909, 346);
+ ClientSize = new Size(795, 260);
Controls.Add(panelObject);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(groupBoxConfig);
- Margin = new Padding(3, 4, 3, 4);
Name = "FormAirPlaneConfig";
Text = "Создание объекта";
groupBoxConfig.ResumeLayout(false);
diff --git a/AirBomber/FormAirPlaneConfig.resx b/AirBomber/FormAirPlaneConfig.resx
index af32865..a395bff 100644
--- a/AirBomber/FormAirPlaneConfig.resx
+++ b/AirBomber/FormAirPlaneConfig.resx
@@ -18,7 +18,7 @@
System.Resources.ResXResourceReader, System.Windows.Forms, ...
System.Resources.ResXResourceWriter, System.Windows.Forms, ...
this is my long stringthis is a comment
- Blue
+ Blue
[base64 mime encoded serialized .NET Framework object]