diff --git a/ProjectFighterJet/CollectionGenericObjects/AbstractCompany.cs b/ProjectFighterJet/CollectionGenericObjects/AbstractCompany.cs index 0c86c81..57e4327 100644 --- a/ProjectFighterJet/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectFighterJet/CollectionGenericObjects/AbstractCompany.cs @@ -49,7 +49,7 @@ public abstract class AbstractCompany _pictureWidth = picWidth; _pictureHeight = picHeight; _collection = collection; - _collection.SetMaxCount = GetMaxCount; + _collection.MaxCount = GetMaxCount; } /// diff --git a/ProjectFighterJet/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectFighterJet/CollectionGenericObjects/ICollectionGenericObjects.cs index a56527e..159589d 100644 --- a/ProjectFighterJet/CollectionGenericObjects/ICollectionGenericObjects.cs +++ b/ProjectFighterJet/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -17,7 +17,7 @@ where T : class /// /// Установка максимального количества элементов /// - int SetMaxCount { set; } + int MaxCount { set; get; } /// /// Добавление объекта в коллекцию @@ -47,4 +47,13 @@ where T : class /// Позиция /// Объект T? Get(int position); + /// + /// Получение типа коллекции + /// + CollectionType GetCollectionType { get; } + /// + /// Получение объектов коллекции по одному + /// + /// Поэлементый вывод элементов коллекции + IEnumerable GetItems(); } diff --git a/ProjectFighterJet/CollectionGenericObjects/ListGenericObjects.cs b/ProjectFighterJet/CollectionGenericObjects/ListGenericObjects.cs index cfab0c7..3cb313e 100644 --- a/ProjectFighterJet/CollectionGenericObjects/ListGenericObjects.cs +++ b/ProjectFighterJet/CollectionGenericObjects/ListGenericObjects.cs @@ -23,7 +23,23 @@ where T : class /// 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; + /// /// Конструктор /// @@ -68,4 +84,11 @@ where T : class return null; } + public IEnumerable GetItems() + { + for (int i = 0; i < Count; ++i) + { + yield return _collection[i]; + } + } } diff --git a/ProjectFighterJet/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectFighterJet/CollectionGenericObjects/MassiveGenericObjects.cs index b1cdf01..19be99a 100644 --- a/ProjectFighterJet/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectFighterJet/CollectionGenericObjects/MassiveGenericObjects.cs @@ -1,4 +1,5 @@ using ProjectFighterJet.Drawnings; + namespace ProjectFighterJet.CollectionGenericObjects; public class MassiveGenericObjects : ICollectionGenericObjects @@ -11,8 +12,13 @@ where T : class public int Count => _collection.Length; - public int SetMaxCount + public CollectionType GetCollectionType => CollectionType.Massive; + public int MaxCount { + get + { + return _collection.Length; + } set { if (value > 0) @@ -31,6 +37,9 @@ where T : class /// /// Конструктор /// + /// + /// Конструктор + /// public MassiveGenericObjects() { _collection = Array.Empty(); @@ -97,4 +106,12 @@ where T : class _collection[position] = null; return temp; } + + public IEnumerable GetItems() + { + for (int i = 0; i < _collection.Length; ++i) + { + yield return _collection[i]; + } + } } diff --git a/ProjectFighterJet/CollectionGenericObjects/StorageCollection.cs b/ProjectFighterJet/CollectionGenericObjects/StorageCollection.cs index f23f5e2..ecf0b7e 100644 --- a/ProjectFighterJet/CollectionGenericObjects/StorageCollection.cs +++ b/ProjectFighterJet/CollectionGenericObjects/StorageCollection.cs @@ -1,8 +1,11 @@ -using System; +using ProjectFighterJet.Drawnings; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Text; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace ProjectFighterJet.CollectionGenericObjects; @@ -11,7 +14,7 @@ namespace ProjectFighterJet.CollectionGenericObjects; /// /// public class StorageCollection -where T : class +where T : DrawningJet { /// /// Словарь (хранилище) с коллекциями @@ -71,4 +74,227 @@ where T : class return null; } } + /// + /// Ключевое слово, с которого должен начинаться файл + /// + private readonly string _collectionKey = "CollectionsStorage"; + /// + /// Разделитель для записи ключа и значения элемента словаря + /// + private readonly string _separatorForKeyValue = "|"; + /// + /// Разделитель для записей коллекции данных в файл + /// + private readonly string _separatorItems = ";"; + /// + /// Сохранение информации по автомобилям в хранилище в файл + /// + /// Путь и имя файла + /// 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); + } + + } + //if (_storages.Count == 0) + //{ + // return false; + //} + //if (File.Exists(filename)) + //{ + // File.Delete(filename); + //} + //StringBuilder sb = new(); + //sb.Append(_collectionKey); + //foreach (KeyValuePair> 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; + } + /// + /// Загрузка информации по автомобилям в хранилище из файла + /// + /// Путь и имя файла + /// 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?.CreateDrawningJet() is T jet) + { + if (collection.Insert(jet) == -1) + { + return false; + } + } + } + _storages.Add(record[0], collection); + } + return true; + //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? 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?.CreateDrawningShip() is T ship) + // { + // if (collection.Insert(ship) == -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/ProjectFighterJet/Drawnings/DrawlingFighterJet.cs b/ProjectFighterJet/Drawnings/DrawlingFighterJet.cs index 7f3069b..529681c 100644 --- a/ProjectFighterJet/Drawnings/DrawlingFighterJet.cs +++ b/ProjectFighterJet/Drawnings/DrawlingFighterJet.cs @@ -12,6 +12,7 @@ namespace ProjectFighterJet.Drawnings; /// public class DrawningFighterJet : DrawningJet { + /// /// Конструктор /// @@ -27,6 +28,12 @@ public class DrawningFighterJet : DrawningJet EntityJet = new EntityFighterJet(speed, weight, bodyColor, additionalColor, rockets, fuel, engines); } + + public DrawningFighterJet(EntityFighterJet jet) : base(140, 135) + { + EntityJet = new EntityFighterJet(jet.Speed, jet.Weight, jet.BodyColor, jet.AdditionalColor, jet.Rockets, jet.Fuel, jet.Engines); + } + public override void DrawTransport(Graphics g) { diff --git a/ProjectFighterJet/Drawnings/DrawningJet.cs b/ProjectFighterJet/Drawnings/DrawningJet.cs index bd39ac3..f86e7fb 100644 --- a/ProjectFighterJet/Drawnings/DrawningJet.cs +++ b/ProjectFighterJet/Drawnings/DrawningJet.cs @@ -94,6 +94,11 @@ public class DrawningJet _drawningJetrHeight = drawningJetrHeight; } + public DrawningJet(EntityJet ship) : this() + { + EntityJet = new EntityJet(ship.Speed, ship.Weight, ship.BodyColor); + } + /// /// Установка границ поля /// diff --git a/ProjectFighterJet/Drawnings/ExtentionDrawningJet.cs b/ProjectFighterJet/Drawnings/ExtentionDrawningJet.cs new file mode 100644 index 0000000..45999b3 --- /dev/null +++ b/ProjectFighterJet/Drawnings/ExtentionDrawningJet.cs @@ -0,0 +1,53 @@ +using ProjectFighterJet.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectFighterJet.Drawnings; + +public static class ExtentionDrawningJet +{ + /// + /// Разделитель для записи информации по объекту в файл + /// + private static readonly string _separatorForObject = ":"; + /// + /// Создание объекта из строки + /// + /// Строка с данными для создания объекта + /// Объект + public static DrawningJet? CreateDrawningJet(this string info) + { + string[] strs = info.Split(_separatorForObject); + EntityJet? jet = EntityFighterJet.CreateEntityFighterJet(strs); + if (jet != null) + { + return new DrawningFighterJet((EntityFighterJet)jet); + } + + jet = EntityJet.CreateEntityJet(strs); + + if (jet != null) + { + return new DrawningJet(jet); + } + return null; + } + /// + /// Получение данных для сохранения в файл + /// + /// Сохраняемый объект + /// Строка с данными по объекту + public static string GetDataForSave(this DrawningJet drawningJet) + { + string[]? array = drawningJet?.EntityJet?.GetStringRepresentation(); + if (array == null) + { + return string.Empty; + } + return string.Join(_separatorForObject, array); + } + +} diff --git a/ProjectFighterJet/Entities/EntityFighterJet.cs b/ProjectFighterJet/Entities/EntityFighterJet.cs index 821e3ee..e525fda 100644 --- a/ProjectFighterJet/Entities/EntityFighterJet.cs +++ b/ProjectFighterJet/Entities/EntityFighterJet.cs @@ -1,49 +1,71 @@ -namespace ProjectFighterJet.Entities +using System.Net.Sockets; + +namespace ProjectFighterJet.Entities; + +public class EntityFighterJet : EntityJet { - public class EntityFighterJet : EntityJet + + /// + /// Дополнительный цвет (для опциональных элементов) + /// + public Color AdditionalColor { get; private set; } + public void SetAdditionalColor(Color additionalColor) { - - /// - /// Дополнительный цвет (для опциональных элементов) - /// - public Color AdditionalColor { get; private set; } - public void SetAdditionalColor(Color additionalColor) - { - AdditionalColor = additionalColor; - } - - /// - /// Признак (опция) наличия ракет - /// - public bool Rockets { get; private set; } - /// - /// Признак (опция) наличия топливного бака - /// - public bool Fuel { get; private set; } - /// - /// Признак (опция) наличия двигателя - /// - public bool Engines { get; private set; } - - /// - /// Инициализация полей объекта-класса спортивного автомобиля - /// - /// Скорость - /// Вес истрибителя - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия ракет - /// Признак наличия топливного бака - /// Признак наличия двигателей - public EntityFighterJet (int speed, double weight, Color bodyColor, Color additionalColor, bool rockets, bool fuel, bool engines) : base(speed, weight, bodyColor) - { - - AdditionalColor = additionalColor; - Rockets = rockets; - Fuel = fuel; - Engines = engines; - } + AdditionalColor = additionalColor; } + /// + /// Признак (опция) наличия ракет + /// + public bool Rockets { get; private set; } + /// + /// Признак (опция) наличия топливного бака + /// + public bool Fuel { get; private set; } + /// + /// Признак (опция) наличия двигателя + /// + public bool Engines { get; private set; } + + /// + /// Инициализация полей объекта-класса спортивного автомобиля + /// + /// Скорость + /// Вес истрибителя + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия ракет + /// Признак наличия топливного бака + /// Признак наличия двигателей + public EntityFighterJet (int speed, double weight, Color bodyColor, Color additionalColor, bool rockets, bool fuel, bool engines) : base(speed, weight, bodyColor) + { + + AdditionalColor = additionalColor; + Rockets = rockets; + Fuel = fuel; + Engines = engines; + } + /// + /// Получение строк со значениями свойств продвинутого объекта класса-сущности + /// + /// + public override string[] GetStringRepresentation() + { + return new[] { nameof(EntityFighterJet), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name, + Rockets.ToString(), Fuel.ToString(), Engines.ToString()}; + } + /// + /// Создание продвинутого объекта из массива строк + /// + /// + /// + public static EntityFighterJet? CreateEntityFighterJet(string[] strs) + { + if (strs.Length != 8 || strs[0] != nameof(EntityFighterJet)) + { + return null; + } + return new EntityFighterJet(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]), Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]), Convert.ToBoolean(strs[7])); + } } diff --git a/ProjectFighterJet/Entities/EntityJet.cs b/ProjectFighterJet/Entities/EntityJet.cs index 077a1a6..2fa9fa1 100644 --- a/ProjectFighterJet/Entities/EntityJet.cs +++ b/ProjectFighterJet/Entities/EntityJet.cs @@ -39,14 +39,29 @@ public class EntityJet /// Скорость /// Вес истрибителя /// Основной цвет - /// Дополнительный цвет - /// Признак наличия ракет - /// Признак наличия топливного бака - /// Признак наличия двигателей + public EntityJet(int speed, double weight, Color bodyColor) { Speed = speed; Weight = weight; BodyColor = bodyColor; } + + public virtual string[] GetStringRepresentation() + { + return new[] { nameof(EntityJet), Speed.ToString(), Weight.ToString(), BodyColor.Name }; + } + /// + /// Создание объекта из массива строк + /// + /// + /// + public static EntityJet? CreateEntityJet(string[] strs) + { + if (strs.Length != 4 || strs[0] != nameof(EntityJet)) + { + return null; + } + return new EntityJet(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3])); + } } diff --git a/ProjectFighterJet/FormJetCollection.Designer.cs b/ProjectFighterJet/FormJetCollection.Designer.cs index 08518dc..be8c1a2 100644 --- a/ProjectFighterJet/FormJetCollection.Designer.cs +++ b/ProjectFighterJet/FormJetCollection.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,9 @@ groupBoxTools.Controls.Add(panelStorage); groupBoxTools.Controls.Add(comboBoxSelectorCompany); groupBoxTools.Dock = DockStyle.Right; - groupBoxTools.Location = new Point(911, 0); + groupBoxTools.Location = new Point(911, 28); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(208, 665); + groupBoxTools.Size = new Size(208, 637); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты "; @@ -241,12 +248,53 @@ // pictureBox // pictureBox.Dock = DockStyle.Fill; - pictureBox.Location = new Point(0, 0); + pictureBox.Location = new Point(0, 28); pictureBox.Name = "pictureBox"; - pictureBox.Size = new Size(911, 665); + pictureBox.Size = new Size(911, 637); 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.Size = new Size(1119, 28); + menuStrip.TabIndex = 2; + menuStrip.Text = "menuStrip1"; + // + // файлToolStripMenuItem + // + файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem }); + файлToolStripMenuItem.Name = "файлToolStripMenuItem"; + файлToolStripMenuItem.Size = new Size(59, 24); + файлToolStripMenuItem.Text = "Файл"; + // + // SaveToolStripMenuItem + // + SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; + SaveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S; + SaveToolStripMenuItem.Size = new Size(227, 26); + SaveToolStripMenuItem.Text = "Сохранение"; + SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click; + // + // LoadToolStripMenuItem + // + LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; + LoadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L; + LoadToolStripMenuItem.Size = new Size(227, 26); + LoadToolStripMenuItem.Text = "Загрузка"; + LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click; + // + // saveFileDialog + // + saveFileDialog.Filter = "txt file | *.txt"; + // + // openFileDialog + // + openFileDialog.Filter = "txt file | *.txt"; + // // FormJetCollection // AutoScaleDimensions = new SizeF(8F, 20F); @@ -254,6 +302,8 @@ ClientSize = new Size(1119, 665); Controls.Add(pictureBox); Controls.Add(groupBoxTools); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; Name = "FormJetCollection"; Text = "Коллекция самолётов"; groupBoxTools.ResumeLayout(false); @@ -262,7 +312,10 @@ panelStorage.ResumeLayout(false); panelStorage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); ResumeLayout(false); + PerformLayout(); } #endregion @@ -285,5 +338,11 @@ private RadioButton radioButtonList; 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/ProjectFighterJet/FormJetCollection.cs b/ProjectFighterJet/FormJetCollection.cs index eff5da4..17baf7a 100644 --- a/ProjectFighterJet/FormJetCollection.cs +++ b/ProjectFighterJet/FormJetCollection.cs @@ -47,7 +47,7 @@ public partial class FormJetCollection : Form /// private void SetJet(DrawningJet jet) { - + if (_company + jet != -1) { MessageBox.Show("Объект добавлен"); @@ -230,4 +230,49 @@ public partial class FormJetCollection : Form panelCompanyTools.Enabled = true; RerfreshListBoxItems(); } + /// + /// Обработка нажатия "Сохранение" + /// + /// + /// + private void SaveToolStripMenuItem_Click(object sender, EventArgs e) + { + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + if (_storageCollection.SaveData(saveFileDialog.FileName)) + { + MessageBox.Show("Сохранение прошло успешно", + "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Не сохранилось", "Результат", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + /// + /// Обработка нажатия "Загрузка" + /// + /// + /// + + private void LoadToolStripMenuItem_Click(object sender, EventArgs e) + { + + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + if (_storageCollection.LoadData(openFileDialog.FileName)) + { + MessageBox.Show("Загрузка прошла успешно", + "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + RerfreshListBoxItems(); + } + else + { + MessageBox.Show("Загрузка не удалась", "Результат", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } } diff --git a/ProjectFighterJet/FormJetCollection.resx b/ProjectFighterJet/FormJetCollection.resx index af32865..ee1748a 100644 --- a/ProjectFighterJet/FormJetCollection.resx +++ b/ProjectFighterJet/FormJetCollection.resx @@ -117,4 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 145, 17 + + + 310, 17 + \ No newline at end of file