diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/AbstractCompany.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/AbstractCompany.cs
index 0249924..c90a7a3 100644
--- a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/AbstractCompany.cs
+++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/AbstractCompany.cs
@@ -47,7 +47,7 @@ public abstract class AbstractCompany
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = collection;
- _collection.SetMaxCount = GetMaxCount;
+ _collection.MaxCount = GetMaxCount;
}
///
diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs
index d27a8ef..5a44d16 100644
--- a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs
+++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs
@@ -13,9 +13,9 @@ public interface ICollectionGenericObjects
int Count { get; }
///
- /// Установка максимального количества элементов
- ///
- int SetMaxCount { set; }
+ /// Установка максимального количества элементов
+ ///
+ int MaxCount { get; set; }
///
/// Добавление объекта в коллекцию
@@ -45,4 +45,13 @@ public interface ICollectionGenericObjects
/// Позиция
/// Объект
T? Get(int position);
+ ///
+ /// получение типа коллекции
+ ///
+ CollectionType GetCollectionType { get; }
+ ///
+ /// получение объектов коллекции по одному
+ ///
+ ///
+ IEnumerable GetItems();
}
\ No newline at end of file
diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ListGenericObjects.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ListGenericObjects.cs
index 5ab70ed..38697ae 100644
--- a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ListGenericObjects.cs
+++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ListGenericObjects.cs
@@ -12,7 +12,22 @@ 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
+ {
+ return Count;
+ }
+ set
+ {
+ if (value > 0)
+ {
+ _maxCount = value;
+ }
+ }
+ }
+ public CollectionType GetCollectionType => CollectionType.List;
+
///
/// Конструктор
///
@@ -53,4 +68,12 @@ public class ListGenericObjects : ICollectionGenericObjects
_collection.RemoveAt(position);
return obj;
}
+
+ public IEnumerable GetItems()
+ {
+ for (int i = 0; i < Count; i++)
+ {
+ yield return _collection[i];
+ }
+ }
}
diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs
index 209e421..ab8d45b 100644
--- a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs
+++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs
@@ -13,8 +13,13 @@ public class MassiveGenericObjects : ICollectionGenericObjects
private T?[] _collection;
public int Count => _collection.Length;
- public int SetMaxCount
+ public int MaxCount
{
+ get
+ {
+ return _collection.Length;
+ }
+
set
{
if (value > 0)
@@ -31,6 +36,8 @@ public class MassiveGenericObjects : ICollectionGenericObjects
}
}
+ public CollectionType GetCollectionType => CollectionType.Massive;
+
///
/// Конструктор
///
@@ -117,4 +124,12 @@ public class MassiveGenericObjects : ICollectionGenericObjects
_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/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/StorageCollection.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/StorageCollection.cs
index cd2bc9f..7e72de6 100644
--- a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/StorageCollection.cs
+++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/StorageCollection.cs
@@ -1,19 +1,39 @@
-namespace ProjectSeaplane.CollectionGenericObjects;
+using ProjectSeaplane.Drawnings;
+using System.Text;
+
+namespace ProjectSeaplane.CollectionGenericObjects;
///
/// класс-хранилище
///
///
public class StorageCollection
- where T : class
+ where T : DrawingBasicSeaplane
{
///
/// Словарь (хранилище) с коллекциями
///
readonly Dictionary> _storages;
+
///
/// Возвращение списка названий коллекций
///
public List Keys => _storages.Keys.ToList();
+
+ ///
+ /// Ключевое слово, с которого должен начинаться файл
+ ///
+ private readonly string _collectionKey = "CollectionsStorage";
+
+ ///
+ /// Разделитель для записи ключа и значения элемента словаря
+ ///
+ private readonly string _separatorForKeyValue = "|";
+
+ ///
+ /// Разделитель для записей коллекции данных в файл
+ ///
+ private readonly string _separatorItems = ";";
+
///
/// Конструктор
///
@@ -61,7 +81,133 @@ public class StorageCollection
// TODO Продумать логику получения объекта
if (_storages.ContainsKey(name))
return _storages[name];
+
return null;
}
}
+
+ ///
+ /// Сохранение информации по самолетам в хранилище в файл
+ ///
+ /// Путь и имя файла
+ /// true - сохранение прошло успешно, false - ошибка при
+ ///сохранении данных
+ public bool SaveData(string filename)
+ {
+ if (_storages.Count == 0)
+ {
+ return false;
+ }
+ if (File.Exists(filename))
+ {
+ File.Delete(filename);
+ }
+ using (StreamWriter writer = new StreamWriter(filename))
+ {
+ writer.Write(_collectionKey);
+ foreach (KeyValuePair> value in _storages)
+ {
+ StringBuilder sb = new();
+ sb.Append(Environment.NewLine);
+ // не сохраняем пустые коллекции
+ if (value.Value.Count == 0)
+ {
+ continue;
+ }
+ sb.Append(value.Key);
+ sb.Append(_separatorForKeyValue);
+ sb.Append(value.Value.GetCollectionType);
+ sb.Append(_separatorForKeyValue);
+ sb.Append(value.Value.MaxCount);
+ sb.Append(_separatorForKeyValue);
+ foreach (T? item in value.Value.GetItems())
+ {
+ string data = item?.GetDataForSave() ?? string.Empty;
+ if (string.IsNullOrEmpty(data))
+ {
+ continue;
+ }
+ sb.Append(data);
+ sb.Append(_separatorItems);
+ }
+ writer.Write(sb);
+ }
+
+ }
+ return true;
+ }
+ ///
+ /// Загрузка информации по автомобилям в хранилище из файла
+ ///
+ /// Путь и имя файла/// true - загрузка прошла успешно, false - ошибка при загрузке
+ ///данных
+ public bool LoadData(string filename)
+ {
+ if (!File.Exists(filename))
+ {
+ return false;
+ }
+ using (StreamReader fs = File.OpenText(filename))
+ {
+ string str = fs.ReadLine();
+ if (str == null || str.Length == 0)
+ {
+ return false;
+ }
+ if (!str.StartsWith(_collectionKey))
+ {
+ return false;
+ }
+ _storages.Clear();
+ string strs = "";
+ while ((strs = fs.ReadLine()) != null)
+ {
+ //по идее этого произойти не должно
+ //if (strs == null)
+ //{
+ // return false;
+ //}
+ string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
+ 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?.CreateDrawningBasicSeaplane() is T seaplane)
+ {
+ if (collection.Insert(seaplane) == -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,
+ };
+ }
}
+
diff --git a/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawingBasicSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawingBasicSeaplane.cs
index 6e7ab09..61c6a70 100644
--- a/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawingBasicSeaplane.cs
+++ b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawingBasicSeaplane.cs
@@ -93,6 +93,10 @@ public class DrawingBasicSeaplane
_drawningSeaplaneHeight = drawningSeaplaneHeight;
}
+ public DrawingBasicSeaplane(EntityBasicSeaplane seaplane) : this()
+ {
+ EntityBasicSeaplane = new EntityBasicSeaplane(seaplane.Speed, seaplane.Weight, seaplane.BodyColor);
+ }
///
/// Установка границ поля
diff --git a/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawingSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawingSeaplane.cs
index bbe56ad..fbe3ff9 100644
--- a/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawingSeaplane.cs
+++ b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawingSeaplane.cs
@@ -1,4 +1,5 @@
using ProjectSeaplane.Entities;
+using System.Windows.Forms.Design.Behavior;
namespace ProjectSeaplane.Drawnings;
///
@@ -31,6 +32,10 @@ public class DrawingSeaplane : DrawingBasicSeaplane
EntityBasicSeaplane = new EntitySeaplane(speed, weight, bodyColor, additionalColor, landingGear, radar);
}
+ public DrawingSeaplane(EntitySeaplane seaplane) : base(155, 70)
+ {
+ EntityBasicSeaplane = new EntitySeaplane(seaplane.Speed, seaplane.Weight, seaplane.BodyColor, seaplane.AdditionalColor, seaplane.LandingGear, seaplane.Radar);
+ }
public override void DrawTransport(Graphics g)
{
@@ -49,9 +54,9 @@ public class DrawingSeaplane : DrawingBasicSeaplane
g.DrawLine(penKraya, _startPosX.Value + 70, _startPosY.Value + 53, _startPosX.Value + 90, _startPosY.Value + 63);
}
- //Чет надо но не понял
+
base.DrawTransport(g);
- //also
+
if (seaplane.Radar)
{
Point point5 = new Point(_startPosX.Value + 50, _startPosY.Value + 22);
diff --git a/ProjectSeaplane/ProjectSeaplane/Drawnings/ExtensionDrawningPlane.cs b/ProjectSeaplane/ProjectSeaplane/Drawnings/ExtensionDrawningPlane.cs
new file mode 100644
index 0000000..fda75df
--- /dev/null
+++ b/ProjectSeaplane/ProjectSeaplane/Drawnings/ExtensionDrawningPlane.cs
@@ -0,0 +1,47 @@
+using ProjectSeaplane.Entities;
+
+namespace ProjectSeaplane.Drawnings;
+///
+/// расширение для класса EntitySeaplane
+///
+public static class ExtentionDrawningBasicSeaplane
+{
+ ///
+ /// Разделитель для записи информации по объекту в файл
+ ///
+ private static readonly string _separatorForObject = ":";
+ ///
+ /// Создание объекта из строки
+ ///
+ /// Строка с данными для создания объекта
+ /// Объект
+ public static DrawingBasicSeaplane? CreateDrawningBasicSeaplane(this string info)
+ {
+ string[] strs = info.Split(_separatorForObject);
+ EntityBasicSeaplane? seaplane = EntitySeaplane.CreateEntitySeaplane(strs);
+ if (seaplane != null)
+ {
+ return new DrawingSeaplane((EntitySeaplane)seaplane);
+ }
+ seaplane = EntityBasicSeaplane.CreateEntityBasicSeaplane(strs);
+ if (seaplane!= null)
+ {
+ return new DrawingBasicSeaplane(seaplane);
+ }
+ return null;
+ }
+ ///
+ /// Получение данных для сохранения в файл
+ ///
+ /// Сохраняемый объект
+ /// Строка с данными по объекту
+ public static string GetDataForSave(this DrawingBasicSeaplane drawningBasicSeaplane)
+ {
+ string[]? array = drawningBasicSeaplane?.EntityBasicSeaplane?.GetStringRepresentation();
+ if (array == null)
+ {
+ return string.Empty;
+ }
+ return string.Join(_separatorForObject, array);
+ }
+}
diff --git a/ProjectSeaplane/ProjectSeaplane/Entities/EntityBasicSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Entities/EntityBasicSeaplane.cs
index 4ef27b8..615cc70 100644
--- a/ProjectSeaplane/ProjectSeaplane/Entities/EntityBasicSeaplane.cs
+++ b/ProjectSeaplane/ProjectSeaplane/Entities/EntityBasicSeaplane.cs
@@ -41,5 +41,26 @@ public class EntityBasicSeaplane
Weight = weight;
BodyColor = bodyColor;
}
+ ///
+ /// Получение строк со значениями свойств объекта класса-сущности
+ ///
+ ///
+ public virtual string[] GetStringRepresentation()
+ {
+ return new[] { nameof(EntityBasicSeaplane), Speed.ToString(), Weight.ToString(), BodyColor.Name };
+ }
+ ///
+ /// Создание объекта из массива строк
+ ///
+ ///
+ ///
+ public static EntityBasicSeaplane? CreateEntityBasicSeaplane(string[] strs)
+ {
+ if (strs.Length != 4 || strs[0] != nameof(EntityBasicSeaplane))
+ {
+ return null;
+ }
+ return new EntityBasicSeaplane(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
+ }
}
diff --git a/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs
index 1dc08f5..6dc2094 100644
--- a/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs
+++ b/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs
@@ -1,4 +1,6 @@
+using System.Net.Sockets;
+
namespace ProjectSeaplane.Entities;
///
/// Класс-сущность "Гидросамолет"
@@ -42,4 +44,28 @@ public class EntitySeaplane : EntityBasicSeaplane
Radar = radar;
}
+ ///
+ /// Получение строк со значениями свойств объекта класса-сущности
+ ///
+ ///
+ public override string[] GetStringRepresentation()
+ {
+ return new[] { nameof(EntitySeaplane), Speed.ToString(), Weight.ToString(), BodyColor.Name,
+ AdditionalColor.Name, LandingGear.ToString(), Radar.ToString()};
+ }
+ ///
+ /// Создание объекта из массива строк
+ ///
+ ///
+ ///
+ public static EntitySeaplane? CreateEntitySeaplane(string[] strs)
+ {
+ if (strs.Length != 8 || strs[0] != nameof(EntitySeaplane))
+ {
+ return null;
+ }
+ return new EntitySeaplane(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/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs
index 873657a..4d275b8 100644
--- a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs
+++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs
@@ -46,10 +46,17 @@
labelCollectionName = new Label();
СomboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
+ menuStrip1 = new MenuStrip();
+ файлToolStripMenuItem = new ToolStripMenuItem();
+ saveToolStripMenuItem = new ToolStripMenuItem();
+ loadToolStripMenuItem = new ToolStripMenuItem();
+ openFileDialog = new OpenFileDialog();
+ saveFileDialog = new SaveFileDialog();
groupBoxTools.SuspendLayout();
panelCompanyTools.SuspendLayout();
panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
+ menuStrip1.SuspendLayout();
SuspendLayout();
//
// groupBoxTools
@@ -59,9 +66,9 @@
groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(СomboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
- groupBoxTools.Location = new Point(854, 0);
+ groupBoxTools.Location = new Point(854, 24);
groupBoxTools.Name = "groupBoxTools";
- groupBoxTools.Size = new Size(180, 614);
+ groupBoxTools.Size = new Size(180, 590);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
@@ -74,9 +81,9 @@
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Controls.Add(buttonDelSeaplane);
panelCompanyTools.Dock = DockStyle.Bottom;
- panelCompanyTools.Location = new Point(3, 366);
+ panelCompanyTools.Location = new Point(3, 361);
panelCompanyTools.Name = "panelCompanyTools";
- panelCompanyTools.Size = new Size(174, 245);
+ panelCompanyTools.Size = new Size(174, 226);
panelCompanyTools.TabIndex = 9;
//
// buttonAddBasicSeaplane
@@ -95,7 +102,7 @@
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.FlatStyle = FlatStyle.Flat;
- buttonRefresh.Location = new Point(0, 197);
+ buttonRefresh.Location = new Point(0, 183);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(174, 31);
buttonRefresh.TabIndex = 6;
@@ -105,7 +112,7 @@
//
// maskedTextBox
//
- maskedTextBox.Location = new Point(0, 97);
+ maskedTextBox.Location = new Point(0, 83);
maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(174, 23);
@@ -116,7 +123,7 @@
//
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToCheck.FlatStyle = FlatStyle.Flat;
- buttonGoToCheck.Location = new Point(0, 162);
+ buttonGoToCheck.Location = new Point(0, 148);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(174, 29);
buttonGoToCheck.TabIndex = 5;
@@ -128,7 +135,7 @@
//
buttonDelSeaplane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonDelSeaplane.FlatStyle = FlatStyle.Flat;
- buttonDelSeaplane.Location = new Point(0, 126);
+ buttonDelSeaplane.Location = new Point(0, 112);
buttonDelSeaplane.Name = "buttonDelSeaplane";
buttonDelSeaplane.Size = new Size(174, 30);
buttonDelSeaplane.TabIndex = 4;
@@ -242,12 +249,52 @@
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
- pictureBox.Location = new Point(0, 0);
+ pictureBox.Location = new Point(0, 24);
pictureBox.Name = "pictureBox";
- pictureBox.Size = new Size(854, 614);
+ pictureBox.Size = new Size(854, 590);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
+ // menuStrip1
+ //
+ menuStrip1.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
+ menuStrip1.Location = new Point(0, 0);
+ menuStrip1.Name = "menuStrip1";
+ menuStrip1.Size = new Size(1034, 24);
+ menuStrip1.TabIndex = 2;
+ menuStrip1.Text = "menuStrip";
+ //
+ // файлToolStripMenuItem
+ //
+ файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
+ файлToolStripMenuItem.Name = "файлToolStripMenuItem";
+ файлToolStripMenuItem.Size = new Size(48, 20);
+ файлToolStripMenuItem.Text = "Файл";
+ //
+ // saveToolStripMenuItem
+ //
+ saveToolStripMenuItem.Name = "saveToolStripMenuItem";
+ saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
+ saveToolStripMenuItem.Size = new Size(181, 22);
+ saveToolStripMenuItem.Text = "Сохранение";
+ saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
+ //
+ // loadToolStripMenuItem
+ //
+ loadToolStripMenuItem.Name = "loadToolStripMenuItem";
+ loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
+ loadToolStripMenuItem.Size = new Size(181, 22);
+ loadToolStripMenuItem.Text = "Загрузка";
+ loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
+ //
+ // openFileDialog
+ //
+ openFileDialog.Filter = "txt file |*.txt";
+ //
+ // saveFileDialog
+ //
+ saveFileDialog.Filter = "txt file |*.txt";
+ //
// FormPlaneCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
@@ -255,6 +302,8 @@
ClientSize = new Size(1034, 614);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
+ Controls.Add(menuStrip1);
+ MainMenuStrip = menuStrip1;
Name = "FormPlaneCollection";
Text = "Коллекция самолетов";
groupBoxTools.ResumeLayout(false);
@@ -263,7 +312,10 @@
panelStorage.ResumeLayout(false);
panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
+ menuStrip1.ResumeLayout(false);
+ menuStrip1.PerformLayout();
ResumeLayout(false);
+ PerformLayout();
}
#endregion
@@ -286,5 +338,11 @@
private RadioButton radioButtonMassive;
private Button buttonCreateCompany;
private Panel panelCompanyTools;
+ private MenuStrip menuStrip1;
+ private ToolStripMenuItem файлToolStripMenuItem;
+ private ToolStripMenuItem saveToolStripMenuItem;
+ private ToolStripMenuItem loadToolStripMenuItem;
+ private OpenFileDialog openFileDialog;
+ private SaveFileDialog saveFileDialog;
}
}
\ No newline at end of file
diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs
index b3500ec..73775e0 100644
--- a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs
+++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs
@@ -1,5 +1,7 @@
using ProjectSeaplane.CollectionGenericObjects;
using ProjectSeaplane.Drawnings;
+using System.Windows.Forms;
+
namespace ProjectSeaplane;
///
@@ -243,5 +245,49 @@ public partial class FormPlaneCollection : Form
}
+ ///
+ /// Обработка нажатия "Сохранение"
+ ///
+ ///
+ ///
+ private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (saveFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (_storageCollection.SaveData(saveFileDialog.FileName))
+ {
+ MessageBox.Show("Сохранение прошло успешно",
+ "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ MessageBox.Show("Не сохранилось", "Результат",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ ///
+ /// Обработка нажатия "Загрузка"
+ ///
+ ///
+ ///
+ private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (openFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (_storageCollection.LoadData(openFileDialog.FileName))
+ {
+ MessageBox.Show("Загрузка прошла успешно",
+ "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ RerfreshListBoxItems();
+ }
+ else
+ {
+ MessageBox.Show("Не загрузилось", "Результат",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
}
+
diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.resx b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.resx
index af32865..8a67c96 100644
--- a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.resx
+++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.resx
@@ -117,4 +117,13 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 17, 17
+
+
+ 132, 17
+
+
+ 271, 17
+
\ No newline at end of file