diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/AbstractCompany.cs b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/AbstractCompany.cs index f85d558..5d0f55d 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/AbstractCompany.cs @@ -47,14 +47,14 @@ public abstract class AbstractCompany _pictureWidth = picWidth; _pictureHeight = picHeight; _collection = collection; - _collection.SetMaxCount = GetMaxCount; + _collection.MaxCount = GetMaxCount; } /// /// Перегрузка оператора сложения для класса /// /// Компания - /// Добавляемый объект + /// Добавляемый объект /// public static int operator +(AbstractCompany company, DrawingTruck truck) { diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/ICollectionGenericObjects.cs index 4edfcb5..0b12797 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/ICollectionGenericObjects.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -15,7 +15,7 @@ public interface ICollectionGenericObjects /// /// Установка максимального количества элементов /// - int SetMaxCount { set; } + int MaxCount { get; set; } /// /// Добавление объекта в коллекцию @@ -45,4 +45,15 @@ public interface ICollectionGenericObjects /// Объект T? Get(int position); + /// + /// Получение типа коллекции + /// + CollectionType GetCollectionType { get; } + + /// + /// Получение объектов коллекции по одному + /// + /// Поэлементый вывод элементов коллекции + IEnumerable GetItems(); + } diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/ListGenericObjects.cs b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/ListGenericObjects.cs index caf4ac0..8f5cca2 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/ListGenericObjects.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/ListGenericObjects.cs @@ -18,7 +18,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; /// /// Конструктор @@ -27,7 +42,7 @@ public class ListGenericObjects : ICollectionGenericObjects { _collection = new(); } - public T Get(int position) + public T? Get(int position) { // проверка позиции if (position >= Count || position < 0) @@ -74,4 +89,12 @@ public class ListGenericObjects : ICollectionGenericObjects return obj; } + + public IEnumerable GetItems() + { + for (int i = 0; i < Count; ++i) + { + yield return _collection[i]; + } + } } diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/MassiveGenericObjects.cs index b76553d..1d73d67 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/MassiveGenericObjects.cs @@ -14,8 +14,12 @@ public class MassiveGenericObjects : ICollectionGenericObjects public int Count => _collection.Length; - public int SetMaxCount + public int MaxCount { + get + { + return _collection.Length; + } set { if (value > 0) @@ -30,8 +34,10 @@ public class MassiveGenericObjects : ICollectionGenericObjects } } } + } + public CollectionType GetCollectionType => CollectionType.Massive; /// /// Конструктор @@ -41,7 +47,6 @@ public class MassiveGenericObjects : ICollectionGenericObjects _collection = Array.Empty(); } - public T? Get(int position) { // проверка позиции @@ -64,7 +69,6 @@ public class MassiveGenericObjects : ICollectionGenericObjects } return -1; - } public int Insert(T obj, int position) { @@ -115,4 +119,12 @@ public class MassiveGenericObjects : ICollectionGenericObjects _collection[position] = null; return temp; } + + public IEnumerable GetItems() + { + for (int i = 0; i < _collection.Length; ++i) + { + yield return _collection[i]; + } + } } diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/StorageCollection.cs b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/StorageCollection.cs index 4f17eae..f6bffb6 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/StorageCollection.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/CollectionGenericObjects/StorageCollection.cs @@ -1,11 +1,14 @@ -namespace ProjectGasolineTanker.CollectionGenericObjects; +using ProjectGasolineTanker.Drawings; +using System.Text; + +namespace ProjectGasolineTanker.CollectionGenericObjects; /// /// Класс-хранилище коллекций /// /// public class StorageCollection - where T : class + where T : DrawingTruck { /// /// Словарь (хранилище) с коллекциями @@ -42,16 +45,16 @@ public class StorageCollection { return; } - else if (collectionType == CollectionType.Massive) + else if (collectionType == CollectionType.Massive) { _storages[name] = new MassiveGenericObjects(); } - - else if (collectionType == CollectionType.List) + + else if (collectionType == CollectionType.List) { _storages[name] = new ListGenericObjects(); } - + } /// @@ -60,7 +63,7 @@ public class StorageCollection /// Название коллекции public void DelCollection(string name) { - // Прописать логику для удаления коллекции + // Логика для удаления коллекции if (_storages.ContainsKey(name)) { _storages.Remove(name); @@ -78,11 +81,158 @@ public class StorageCollection { // логика получения объекта 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?.CreateDrawingTruck() is T truck) + { + if (collection.Insert(truck) == -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/ProjectGasolineTanker/ProjectGasolineTanker/Drawings/DrawingGasolineTanker.cs b/ProjectGasolineTanker/ProjectGasolineTanker/Drawings/DrawingGasolineTanker.cs index 4762e9e..23013fa 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/Drawings/DrawingGasolineTanker.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/Drawings/DrawingGasolineTanker.cs @@ -20,7 +20,11 @@ public class DrawingGasolineTanker : DrawingTruck { EntityTruck = new EntityGasolineTanker(speed, weight, bodyColor, additionalColor, gasTank, signalBeacon); + } + public DrawingGasolineTanker(EntityGasolineTanker truck) : base(105,70) + { + EntityTruck = new EntityGasolineTanker(truck.Speed, truck.Weight, truck.BodyColor, truck.AdditionalColor, truck.GasTank, truck.SignalBeacon); } public override void DrawTransport(Graphics g) diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/Drawings/DrawingTruck.cs b/ProjectGasolineTanker/ProjectGasolineTanker/Drawings/DrawingTruck.cs index 8c19991..9d254e8 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/Drawings/DrawingTruck.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/Drawings/DrawingTruck.cs @@ -49,12 +49,12 @@ public class DrawingTruck public int? GetPosY => _startPosY; /// - /// Ширина прорисовки воза(грузовика) + /// Ширина прорисовки грузовика /// public int GetWidth => _drawingTruckWidth; /// - /// Высота прорисовки воза(грузовика) + /// Высота прорисовки грузовика /// public int GetHeight => _drawingTruckHeight; @@ -93,6 +93,11 @@ public class DrawingTruck _drawingTruckHeight = drawingTruckHeight; } + + public DrawingTruck(EntityTruck truck) : this() + { + EntityTruck = new EntityTruck(truck.Speed, truck.Weight, truck.BodyColor); + } /// /// Установка границ поля /// diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/Drawings/ExtentionDrawingTruck.cs b/ProjectGasolineTanker/ProjectGasolineTanker/Drawings/ExtentionDrawingTruck.cs new file mode 100644 index 0000000..08e6474 --- /dev/null +++ b/ProjectGasolineTanker/ProjectGasolineTanker/Drawings/ExtentionDrawingTruck.cs @@ -0,0 +1,50 @@ +namespace ProjectGasolineTanker.Drawings; +using ProjectGasolineTanker.Entities; +/// +/// Расширение для класса EntityTruck +/// + +public static class ExtentionDrawingTruck +{ + /// + /// Разделитель для записи информации по объекту в файл + /// + private static readonly string _separatorForObject = ":"; + + /// + /// Создание объекта из строки + /// + /// Строка с данными для создания объекта + /// Объект + + public static DrawingTruck? CreateDrawingTruck(this string info) + { + string[] strs = info.Split(_separatorForObject); + EntityTruck? truck = EntityGasolineTanker.CreateEntityGasolineTanker(strs); + if (truck != null) + { + return new DrawingGasolineTanker((EntityGasolineTanker)truck); + } + truck = EntityTruck.CreateEntityTruck(strs); + if (truck != null) + { + return new DrawingTruck(truck); + } + return null; + } + + /// + /// Получение данных для сохранения в файл + /// + /// Сохраняемый объект + /// Строка с данными по объекту + public static string GetDataForSave(this DrawingTruck drawingTruck) + { + string[]? array = drawingTruck?.EntityTruck?.GetStringRepresentation(); + if (array == null) + { + return string.Empty; + } + return string.Join(_separatorForObject, array); + } +} diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityGasolineTanker.cs b/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityGasolineTanker.cs index 9262375..534da43 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityGasolineTanker.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityGasolineTanker.cs @@ -34,4 +34,29 @@ public class EntityGasolineTanker : EntityTruck SignalBeacon = signalBeacon; } + /// + /// Получение строк со значениями свойств объекта класса-сущности + /// + /// + public override string[] GetStringRepresentation() + { + return new string[] {nameof(EntityGasolineTanker), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name, GasTank.ToString(), SignalBeacon.ToString()}; + } + + /// + /// Создание объекта из массива строк + /// + /// + /// + public static EntityGasolineTanker? CreateEntityGasolineTanker(string[] strs) + { + if (strs.Length != 7 || strs[0] != nameof(EntityGasolineTanker)) + { + return null; + } + return new EntityGasolineTanker(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/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityTruck.cs b/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityTruck.cs index 2c13570..6d19104 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityTruck.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/Entities/EntityTruck.cs @@ -1,4 +1,6 @@ -namespace ProjectGasolineTanker.Entities; +using System.Reflection.Metadata; + +namespace ProjectGasolineTanker.Entities; /// /// Класс-сущность "Грузовик" /// @@ -41,4 +43,27 @@ public class EntityTruck BodyColor = bodyColor; } + /// + /// Получение строк со значениями свойств объекта класса-сущности + /// + /// + public virtual string[] GetStringRepresentation() + { + return new[] { nameof(EntityTruck), Speed.ToString(), Weight.ToString(), BodyColor.Name }; + } + /// + /// Создание объекта из массива строк + /// + /// + /// + public static EntityTruck? CreateEntityTruck(string[] strs) + { + if (strs.Length != 4 || strs[0] != nameof(EntityTruck)) + { + return null; + } + return new EntityTruck(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3])); + } + + } diff --git a/ProjectGasolineTanker/ProjectGasolineTanker/FormTruckCollection.Designer.cs b/ProjectGasolineTanker/ProjectGasolineTanker/FormTruckCollection.Designer.cs index a585798..777fa00 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/FormTruckCollection.Designer.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/FormTruckCollection.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(953, 0); + groupBoxTools.Location = new Point(941, 28); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(241, 702); + groupBoxTools.Size = new Size(241, 802); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; @@ -92,7 +99,7 @@ // // buttonRefresh // - buttonRefresh.Location = new Point(10, 273); + buttonRefresh.Location = new Point(10, 215); buttonRefresh.Name = "buttonRefresh"; buttonRefresh.Size = new Size(222, 52); buttonRefresh.TabIndex = 5; @@ -102,7 +109,7 @@ // // maskedTextBoxPosition // - maskedTextBoxPosition.Location = new Point(10, 124); + maskedTextBoxPosition.Location = new Point(9, 66); maskedTextBoxPosition.Mask = "00"; maskedTextBoxPosition.Name = "maskedTextBoxPosition"; maskedTextBoxPosition.Size = new Size(222, 27); @@ -111,9 +118,9 @@ // // buttonGoToCheck // - buttonGoToCheck.Location = new Point(10, 215); + buttonGoToCheck.Location = new Point(13, 157); buttonGoToCheck.Name = "buttonGoToCheck"; - buttonGoToCheck.Size = new Size(225, 52); + buttonGoToCheck.Size = new Size(223, 52); buttonGoToCheck.TabIndex = 4; buttonGoToCheck.Text = "Передать на тесты"; buttonGoToCheck.UseVisualStyleBackColor = true; @@ -121,7 +128,7 @@ // // buttonRemoveTruck // - buttonRemoveTruck.Location = new Point(9, 157); + buttonRemoveTruck.Location = new Point(10, 99); buttonRemoveTruck.Name = "buttonRemoveTruck"; buttonRemoveTruck.Size = new Size(226, 52); buttonRemoveTruck.TabIndex = 3; @@ -237,19 +244,62 @@ // pictureBox.Dock = DockStyle.Fill; pictureBox.Enabled = false; - pictureBox.Location = new Point(0, 0); + pictureBox.Location = new Point(0, 28); pictureBox.Name = "pictureBox"; - pictureBox.Size = new Size(953, 702); + pictureBox.Size = new Size(941, 802); 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(1182, 28); + menuStrip.TabIndex = 2; + menuStrip.Text = "menuStrip"; + // + // файл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"; + // // FormTruckCollection // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1194, 702); + ClientSize = new Size(1182, 830); Controls.Add(pictureBox); Controls.Add(groupBoxTools); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; Name = "FormTruckCollection"; Text = "Коллекция грузовиков"; groupBoxTools.ResumeLayout(false); @@ -258,7 +308,10 @@ panelStorage.ResumeLayout(false); panelStorage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); ResumeLayout(false); + PerformLayout(); } @@ -283,5 +336,11 @@ private Button buttonCreateCompany; private Button buttonCollectionDel; 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/ProjectGasolineTanker/ProjectGasolineTanker/FormTruckCollection.cs b/ProjectGasolineTanker/ProjectGasolineTanker/FormTruckCollection.cs index 0f5537a..c95d780 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/FormTruckCollection.cs +++ b/ProjectGasolineTanker/ProjectGasolineTanker/FormTruckCollection.cs @@ -1,5 +1,6 @@ using ProjectGasolineTanker.CollectionGenericObjects; using ProjectGasolineTanker.Drawings; +using System.Windows.Forms; namespace ProjectGasolineTanker; @@ -48,7 +49,7 @@ public partial class FormTruckCollection : Form form.Show(); form.AddEvent(SetTruck); } - + /// /// Добавление грузовика в коллекцию /// @@ -240,5 +241,52 @@ public partial class FormTruckCollection : 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/ProjectGasolineTanker/ProjectGasolineTanker/FormTruckCollection.resx b/ProjectGasolineTanker/ProjectGasolineTanker/FormTruckCollection.resx index af32865..745440d 100644 --- a/ProjectGasolineTanker/ProjectGasolineTanker/FormTruckCollection.resx +++ b/ProjectGasolineTanker/ProjectGasolineTanker/FormTruckCollection.resx @@ -117,4 +117,16 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 145, 17 + + + 310, 17 + + + 35 + \ No newline at end of file