From dbce9c8b1dc4efc7dd138a21f067c1fe5970521b Mon Sep 17 00:00:00 2001 From: alhimek17 Date: Sun, 21 Apr 2024 22:59:52 +0400 Subject: [PATCH] =?UTF-8?q?6=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 2 +- .../ICollectionGenericObjects.cs | 11 +- .../ListGenericObjects.cs | 26 ++- .../MassiveGenericObjects.cs | 22 ++- .../StorageCollection.cs | 149 +++++++++++++++++- .../Drawnings/DrawningAirPlane.cs | 4 + .../Drawnings/DrawningPlane.cs | 5 +- .../Drawnings/ExtentionDrawningPlane.cs | 49 ++++++ .../ProjectAirPlane/Entites/EntityAirPlane.cs | 24 +++ .../ProjectAirPlane/Entites/EntityPlane.cs | 22 +++ .../FormPlaneCollection.Designer.cs | 78 +++++++-- .../ProjectAirPlane/FormPlaneCollection.cs | 44 ++++++ .../ProjectAirPlane/FormPlaneCollection.resx | 9 ++ 13 files changed, 421 insertions(+), 24 deletions(-) create mode 100644 ProjectAirPlane/ProjectAirPlane/Drawnings/ExtentionDrawningPlane.cs diff --git a/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/AbstractCompany.cs b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/AbstractCompany.cs index 5788d0b..b944027 100644 --- a/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/AbstractCompany.cs @@ -50,7 +50,7 @@ public abstract class AbstractCompany _pictureWidth = picWidth; _pictureHeight = picHeight; _collection = collection; - _collection.SetMaxCount = GetMaxCount; + _collection.MaxCount = GetMaxCount; } /// diff --git a/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/ICollectionGenericObjects.cs index d609f17..901e1cc 100644 --- a/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/ICollectionGenericObjects.cs +++ b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -17,7 +17,7 @@ public interface ICollectionGenericObjects /// /// Установка максимального количества элементов /// - int SetMaxCount { set; } + int MaxCount { set; get; } /// /// Добавление объекта в коллекцию @@ -47,4 +47,13 @@ public interface ICollectionGenericObjects /// Позиция /// Объект T? Get(int position); + /// + /// Получение типа коллекции + /// + CollectionType GetCollectionType { get; } + /// + /// Получение объектов коллекции по одному + /// + /// Поэлементый вывод элементов коллекции + IEnumerable GetItems(); } diff --git a/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/ListGenericObjects.cs b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/ListGenericObjects.cs index f356dfc..18e91d3 100644 --- a/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/ListGenericObjects.cs +++ b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/ListGenericObjects.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using ProjectAirPlane.Drawnings; namespace ProjectAirPlane.CollectionGenericObjects; @@ -13,7 +14,7 @@ public class ListGenericObjects : ICollectionGenericObjects /// Список объектов, которые храним /// private readonly List _collection; - + public CollectionType GetCollectionType => CollectionType.List; /// /// Максимально допустимое число объектов в списке /// @@ -21,7 +22,20 @@ public class ListGenericObjects : ICollectionGenericObjects 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; + } + } + } + /// /// Конструктор @@ -67,4 +81,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/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/MassiveGenericObjects.cs index 32c4e8f..606c4e1 100644 --- a/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/MassiveGenericObjects.cs @@ -16,8 +16,12 @@ public class MassiveGenericObjects : ICollectionGenericObjects public int Count => _collection.Length; - public int SetMaxCount + public int MaxCount { + get + { + return _collection.Length; + } set { if (value > 0) @@ -34,10 +38,12 @@ public class MassiveGenericObjects : ICollectionGenericObjects } } + public CollectionType GetCollectionType => CollectionType.Massive; + /// - /// Конструктор - /// - public MassiveGenericObjects() + /// Конструктор + /// + public MassiveGenericObjects() { _collection = Array.Empty(); } @@ -115,4 +121,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]; + } + } } diff --git a/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/StorageCollection.cs b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/StorageCollection.cs index d1b2c3d..d304ba8 100644 --- a/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/StorageCollection.cs +++ b/ProjectAirPlane/ProjectAirPlane/CollectionGenericObjects/StorageCollection.cs @@ -1,11 +1,14 @@ -namespace ProjectAirPlane.CollectionGenericObjects; +using System.Text; +using ProjectAirPlane.Drawnings; + +namespace ProjectAirPlane.CollectionGenericObjects; /// /// Класс-хранилище коллекций /// /// public class StorageCollection - where T : class + where T : DrawningPlane { /// /// Словарь (хранилище) с коллекциями @@ -57,6 +60,12 @@ public class StorageCollection if (_storages.ContainsKey(name)) { _storages.Remove(name); } } + /// + /// Доступ к коллекции + /// + /// Название коллекции + /// + /// /// Доступ к коллекции /// @@ -68,11 +77,141 @@ public class StorageCollection { // TODO Продумать логику получения объекта if (_storages.ContainsKey(name)) - { return _storages[name]; - } 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); + } -} + } + + 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) + { + + 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?.CreateDrawningPlane() is T plane) + { + if (collection.Insert(plane) == -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/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningAirPlane.cs b/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningAirPlane.cs index 396042e..96a537c 100644 --- a/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningAirPlane.cs +++ b/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningAirPlane.cs @@ -25,6 +25,10 @@ public class DrawningAirPlane : DrawningPlane } + public DrawningAirPlane(EntityAirPlane plane) : base(195, 70) + { + EntityPlane = new EntityAirPlane(plane.Speed, plane.Weight, plane.BodyColor, plane.AdditionalColor, plane.Radar, plane.DopBak); + } public override void DrawTransport(Graphics g) { diff --git a/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningPlane.cs b/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningPlane.cs index ffcadd5..4421ba0 100644 --- a/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningPlane.cs +++ b/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningPlane.cs @@ -97,7 +97,10 @@ public class DrawningPlane _drawningAirPlaneHeight = drawningPlaneHeight; } - + public DrawningPlane(EntityPlane plane) : this() + { + EntityPlane = new EntityPlane(plane.Speed, plane.Weight, plane.BodyColor); + } /// /// Установка границ поля diff --git a/ProjectAirPlane/ProjectAirPlane/Drawnings/ExtentionDrawningPlane.cs b/ProjectAirPlane/ProjectAirPlane/Drawnings/ExtentionDrawningPlane.cs new file mode 100644 index 0000000..32c26de --- /dev/null +++ b/ProjectAirPlane/ProjectAirPlane/Drawnings/ExtentionDrawningPlane.cs @@ -0,0 +1,49 @@ + + +using ProjectAirPlane.Entites; + +namespace ProjectAirPlane.Drawnings; +/// +/// Расширение для класса EntityPlane +/// +public static class ExtentionDrawningPlane +{ + /// + /// Разделитель для записи информации по объекту в файл + /// + private static readonly string _separatorForObject = ":"; + /// + /// Создание объекта из строки + /// + /// Строка с данными для создания объекта + /// Объект + public static DrawningPlane? CreateDrawningPlane(this string info) + { + string[] strs = info.Split(_separatorForObject); + EntityPlane? plane = EntityAirPlane.CreateEntityAirPlane(strs); + if (plane != null) + { + return new DrawningAirPlane((EntityAirPlane)plane); + } + plane = EntityPlane.CreateEntityPlane(strs); + if (plane != null) + { + return new DrawningPlane(plane); + } + return null; + } + /// + /// Получение данных для сохранения в файл + /// + /// Сохраняемый объект + /// Строка с данными по объекту + public static string GetDataForSave(this DrawningPlane drawningPlane) + { + string[]? array = drawningPlane?.EntityPlane?.GetStringRepresentation(); + if (array == null) + { + return string.Empty; + } + return string.Join(_separatorForObject, array); + } +} diff --git a/ProjectAirPlane/ProjectAirPlane/Entites/EntityAirPlane.cs b/ProjectAirPlane/ProjectAirPlane/Entites/EntityAirPlane.cs index 41c349d..d413163 100644 --- a/ProjectAirPlane/ProjectAirPlane/Entites/EntityAirPlane.cs +++ b/ProjectAirPlane/ProjectAirPlane/Entites/EntityAirPlane.cs @@ -57,4 +57,28 @@ public class EntityAirPlane : EntityPlane } + /// + /// Получение строк со значениями свойств продвинутого объекта класса-сущности + /// + /// + public override string[] GetStringRepresentation() + { + return new[] { nameof(EntityAirPlane), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name, + Radar.ToString(), DopBak.ToString()}; + } + /// + /// Создание продвинутого объекта из массива строк + /// + /// + /// + public static EntityAirPlane? CreateEntityAirPlane(string[] strs) + { + if (strs.Length != 7 || strs[0] != nameof(EntityAirPlane)) + { + return null; + } + return new EntityAirPlane(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]), + Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6])); + } + } \ No newline at end of file diff --git a/ProjectAirPlane/ProjectAirPlane/Entites/EntityPlane.cs b/ProjectAirPlane/ProjectAirPlane/Entites/EntityPlane.cs index bf667d0..c41acca 100644 --- a/ProjectAirPlane/ProjectAirPlane/Entites/EntityPlane.cs +++ b/ProjectAirPlane/ProjectAirPlane/Entites/EntityPlane.cs @@ -48,4 +48,26 @@ public class EntityPlane } + /// + /// Получение строк со значениями свойств объекта класса-сущности + /// + /// + public virtual string[] GetStringRepresentation() + { + return new[] { nameof(EntityPlane), Speed.ToString(), Weight.ToString(), BodyColor.Name }; + } + /// + /// Создание объекта из массива строк + /// + /// + /// + public static EntityPlane? CreateEntityPlane(string[] strs) + { + if (strs.Length != 4 || strs[0] != nameof(EntityPlane)) + { + return null; + } + return new EntityPlane(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3])); + } + } diff --git a/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.Designer.cs b/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.Designer.cs index 136ed8b..b3b42ee 100644 --- a/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.Designer.cs +++ b/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.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(686, 0); + groupBoxTools.Location = new Point(686, 24); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(195, 558); + groupBoxTools.Size = new Size(195, 534); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; @@ -75,9 +82,9 @@ panelCompanyTools.Controls.Add(buttonGoToCheck); panelCompanyTools.Dock = DockStyle.Bottom; panelCompanyTools.Enabled = false; - panelCompanyTools.Location = new Point(3, 340); + panelCompanyTools.Location = new Point(3, 343); panelCompanyTools.Name = "panelCompanyTools"; - panelCompanyTools.Size = new Size(189, 215); + panelCompanyTools.Size = new Size(189, 188); panelCompanyTools.TabIndex = 8; // // buttonAddPlane @@ -93,7 +100,7 @@ // // maskedTextBox // - maskedTextBox.Location = new Point(3, 91); + maskedTextBox.Location = new Point(6, 57); maskedTextBox.Mask = "00"; maskedTextBox.Name = "maskedTextBox"; maskedTextBox.Size = new Size(166, 23); @@ -104,7 +111,7 @@ // buttonRefresh // buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRefresh.Location = new Point(4, 181); + buttonRefresh.Location = new Point(6, 156); buttonRefresh.Name = "buttonRefresh"; buttonRefresh.Size = new Size(166, 25); buttonRefresh.TabIndex = 6; @@ -115,7 +122,7 @@ // buttonRemovePlane // buttonRemovePlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRemovePlane.Location = new Point(3, 120); + buttonRemovePlane.Location = new Point(7, 86); buttonRemovePlane.Name = "buttonRemovePlane"; buttonRemovePlane.Size = new Size(166, 24); buttonRemovePlane.TabIndex = 4; @@ -126,7 +133,7 @@ // buttonGoToCheck // buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonGoToCheck.Location = new Point(4, 150); + buttonGoToCheck.Location = new Point(6, 125); buttonGoToCheck.Name = "buttonGoToCheck"; buttonGoToCheck.Size = new Size(166, 25); buttonGoToCheck.TabIndex = 5; @@ -241,12 +248,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(686, 558); + pictureBox.Size = new Size(686, 534); pictureBox.TabIndex = 1; pictureBox.TabStop = false; // + // menuStrip + // + menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(881, 24); + menuStrip.TabIndex = 2; + menuStrip.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; + // + // saveFileDialog + // + saveFileDialog.Filter = "txt file | *.txt"; + // + // openFileDialog + // + openFileDialog.Filter = "txt file | *.txt"; + // // FormPlaneCollection // AutoScaleDimensions = new SizeF(7F, 15F); @@ -254,6 +301,8 @@ ClientSize = new Size(881, 558); Controls.Add(pictureBox); Controls.Add(groupBoxTools); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; Name = "FormPlaneCollection"; Text = "Коллекция самолётов"; groupBoxTools.ResumeLayout(false); @@ -262,7 +311,10 @@ panelStorage.ResumeLayout(false); panelStorage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); ResumeLayout(false); + PerformLayout(); } #endregion @@ -285,5 +337,11 @@ private Button buttonCollectionDel; 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/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.cs b/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.cs index 2263292..2658f96 100644 --- a/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.cs +++ b/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.cs @@ -240,5 +240,49 @@ public partial class FormPlaneCollection : 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/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.resx b/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.resx index af32865..8b1dfa1 100644 --- a/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.resx +++ b/ProjectAirPlane/ProjectAirPlane/FormPlaneCollection.resx @@ -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