From a8323ce73cd1775bdc1fdad5fafcf93c34afa631 Mon Sep 17 00:00:00 2001 From: 1SooNoo1 Date: Mon, 20 Nov 2023 23:24:07 +0400 Subject: [PATCH 1/2] =?UTF-8?q?=D0=BF=D0=BE=D1=87=D1=82=D0=B8=20=D0=B3?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExcavatorGenericCollection.cs | 4 + .../ExcavatorsGenericStorage.cs | 108 +++++++++++++++++- .../ExtentionDrawningExcavator.cs | 63 ++++++++++ .../FormExcavatorCollection.Designer.cs | 76 ++++++++++-- .../FormExcavatorCollection.cs | 52 ++++++++- .../FormExcavatorCollection.resx | 9 ++ 6 files changed, 297 insertions(+), 15 deletions(-) create mode 100644 ProjectExcavator/ProjectExcavator/ExtentionDrawningExcavator.cs diff --git a/ProjectExcavator/ProjectExcavator/ExcavatorGenericCollection.cs b/ProjectExcavator/ProjectExcavator/ExcavatorGenericCollection.cs index c5fc52a..a443262 100644 --- a/ProjectExcavator/ProjectExcavator/ExcavatorGenericCollection.cs +++ b/ProjectExcavator/ProjectExcavator/ExcavatorGenericCollection.cs @@ -18,6 +18,10 @@ namespace ProjectExcavator.Generic private readonly int _placeSizeWidth = 200; private readonly int _placeSizeHeight = 110; private readonly SetGeneric _collection; + /// + /// Получение объектов коллекции + /// + public IEnumerable GetCars => _collection.GetExcavators(); public ExcavatorGenericCollection(int picWidth, int picHeight) { int width = picWidth / _placeSizeWidth; diff --git a/ProjectExcavator/ProjectExcavator/ExcavatorsGenericStorage.cs b/ProjectExcavator/ProjectExcavator/ExcavatorsGenericStorage.cs index 6a424c4..8f2b095 100644 --- a/ProjectExcavator/ProjectExcavator/ExcavatorsGenericStorage.cs +++ b/ProjectExcavator/ProjectExcavator/ExcavatorsGenericStorage.cs @@ -27,6 +27,19 @@ namespace ProjectExcavator.Generic /// Высота окна отрисовки /// private readonly int _pictureHeight; + /// + /// Разделитель для записи ключа и значения элемента словаря + /// + private static readonly char _separatorForKeyValue = '|'; + /// + /// Разделитель для записей коллекции данных в файл + /// + private readonly char _separatorRecords = ';'; + /// + /// Разделитель для записи информации по объекту в файл + /// + private static readonly char _separatorForObject = ':'; + /// /// Конструктор /// @@ -40,16 +53,107 @@ namespace ProjectExcavator.Generic _pictureHeight = pictureHeight; } /// + /// Сохранение информации по автомобилям в хранилище в файл + /// + /// Путь и имя файла + /// true - сохранение прошло успешно, false - ошибка при сохранении данных + public bool SaveData(string filename) + { + if (File.Exists(filename)) + { + File.Delete(filename); + } + StringBuilder data = new(); + foreach (KeyValuePair> record in _excavatorStorages) + { + StringBuilder records = new(); + foreach (DrawningExcavator? elem in record.Value.GetCars) + { + records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}"); + } + data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}"); + } + if (data.Length == 0) + { + return false; + } + using FileStream fs = new(filename, FileMode.Create); + byte[] info = new + UTF8Encoding(true).GetBytes($"CarStorage{Environment.NewLine}{data}"); + fs.Write(info, 0, info.Length); + return true; + } + /// + /// Загрузка информации по автомобилям в хранилище из файла + /// + /// Путь и имя файла + /// true - загрузка прошла успешно, false - ошибка при загрузке данных + public bool LoadData(string filename) + { + if (!File.Exists(filename)) + { + return false; + } + 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); + } + } + var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); + if (strs == null || strs.Length == 0) + { + return false; + } + if (!strs[0].StartsWith("ExcavatorStorage")) + { + //если нет такой записи, то это не те данные + return false; + } + _excavatorStorages.Clear(); + foreach (string data in strs) + + + { + string[] record = data.Split(_separatorForKeyValue, + StringSplitOptions.RemoveEmptyEntries); + if (record.Length != 2) + { + continue; + } + ExcavatorGenericCollection collection = new(_pictureWidth,_pictureHeight); + string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries); + foreach(string elem in set) + { + DrawningExcavator? excavator = elem?.CreateDrawningExcavator(_separatorForObject, _pictureWidth, _pictureHeight); + if(excavator != null) + { + if (collection + excavator == -1) + { + return false; + } + } + } + _excavatorStorages.Add(record[0], collection); + } + return true; + } + /// /// Добавление набора /// /// Название набора public void AddSet(string name) { - if(_excavatorStorages.ContainsKey(name)) + if (_excavatorStorages.ContainsKey(name)) { return; } - _excavatorStorages[name] = new ExcavatorGenericCollection(_pictureWidth,_pictureHeight); + _excavatorStorages[name] = new ExcavatorGenericCollection(_pictureWidth, _pictureHeight); } /// /// Удаление набора diff --git a/ProjectExcavator/ProjectExcavator/ExtentionDrawningExcavator.cs b/ProjectExcavator/ProjectExcavator/ExtentionDrawningExcavator.cs new file mode 100644 index 0000000..b80bdbb --- /dev/null +++ b/ProjectExcavator/ProjectExcavator/ExtentionDrawningExcavator.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectExcavator.Entities; + +namespace ProjectExcavator +{ + public static class ExtentionDrawningExcavator + { + /// + /// Создание объекта из строки + /// + /// Строка с данными для создания объекта + /// Разделитель даннных + /// Ширина + /// Высота + /// Объект + public static DrawningExcavator? CreateDrawningExcavator(this string info, char + separatorForObject, int width, int height) + { + string[] strs = info.Split(separatorForObject); + if (strs.Length == 3) + { + return new DrawningExcavator(Convert.ToInt32(strs[0]), + Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height); + } + if (strs.Length == 6) + { + return new DrawningExcavatorBodyKits(Convert.ToInt32(strs[0]), + Convert.ToInt32(strs[1]), + Color.FromName(strs[2]), + Color.FromName(strs[3]), + Convert.ToBoolean(strs[4]), + Convert.ToBoolean(strs[5]), + width, height); + } + return null; + } + /// + /// Получение данных для сохранения в файл + /// + /// Сохраняемый объект + /// Разделитель даннных + /// Строка с данными по объекту + public static string GetDataForSave(this DrawningExcavator drawningExcavator, + char separatorForObject) + { + var excavator = drawningExcavator.EntityExcavator; + if (excavator == null) + { + return string.Empty; + } + var str = $"{excavator.Speed}{separatorForObject}{excavator.Weight}{separatorForObject}{excavator.BodyColor.Name}"; + if (excavator is not EntityExcavatorBodyKits excavatorBodyKits) + { + return str; + } + return $"{str}{separatorForObject}{excavatorBodyKits.AdditionalColor.Name}{separatorForObject}{excavatorBodyKits.BodyKit}{separatorForObject}{excavatorBodyKits.Bucket}"; + } + } +} diff --git a/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.Designer.cs b/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.Designer.cs index e9d2d89..22a4935 100644 --- a/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.Designer.cs +++ b/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.Designer.cs @@ -37,7 +37,15 @@ AddCollectButton = new Button(); DeleteCollectButton = new Button(); textBoxStorageName = new TextBox(); + menuStripItem = new MenuStrip(); + StripMenuItem = new ToolStripMenuItem(); + toolStripMenuItem1 = new ToolStripMenuItem(); + сохранитьToolStripMenuItem = new ToolStripMenuItem(); + загрузитьToolStripMenuItem = new ToolStripMenuItem(); + openFileDialog = new OpenFileDialog(); + saveFileDialog = new SaveFileDialog(); ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit(); + menuStripItem.SuspendLayout(); SuspendLayout(); // // pictureBoxCollection @@ -50,7 +58,7 @@ // // buttonAddExcavator // - buttonAddExcavator.Location = new Point(623, 244); + buttonAddExcavator.Location = new Point(623, 275); buttonAddExcavator.Name = "buttonAddExcavator"; buttonAddExcavator.Size = new Size(174, 51); buttonAddExcavator.TabIndex = 1; @@ -60,14 +68,14 @@ // // maskedTextBoxNumber // - maskedTextBoxNumber.Location = new Point(623, 301); + maskedTextBoxNumber.Location = new Point(623, 332); maskedTextBoxNumber.Name = "maskedTextBoxNumber"; maskedTextBoxNumber.Size = new Size(174, 23); maskedTextBoxNumber.TabIndex = 2; // // buttonRemoveExcavator // - buttonRemoveExcavator.Location = new Point(623, 330); + buttonRemoveExcavator.Location = new Point(623, 361); buttonRemoveExcavator.Name = "buttonRemoveExcavator"; buttonRemoveExcavator.Size = new Size(174, 38); buttonRemoveExcavator.TabIndex = 3; @@ -77,7 +85,7 @@ // // buttonRefreshCollection // - buttonRefreshCollection.Location = new Point(623, 374); + buttonRefreshCollection.Location = new Point(623, 405); buttonRefreshCollection.Name = "buttonRefreshCollection"; buttonRefreshCollection.Size = new Size(174, 33); buttonRefreshCollection.TabIndex = 4; @@ -89,7 +97,7 @@ // listBoxStorages.FormattingEnabled = true; listBoxStorages.ItemHeight = 15; - listBoxStorages.Location = new Point(623, 90); + listBoxStorages.Location = new Point(623, 156); listBoxStorages.Name = "listBoxStorages"; listBoxStorages.Size = new Size(174, 79); listBoxStorages.TabIndex = 5; @@ -97,7 +105,7 @@ // // AddCollectButton // - AddCollectButton.Location = new Point(623, 53); + AddCollectButton.Location = new Point(623, 119); AddCollectButton.Name = "AddCollectButton"; AddCollectButton.Size = new Size(174, 31); AddCollectButton.TabIndex = 6; @@ -107,7 +115,7 @@ // // DeleteCollectButton // - DeleteCollectButton.Location = new Point(623, 175); + DeleteCollectButton.Location = new Point(623, 241); DeleteCollectButton.Name = "DeleteCollectButton"; DeleteCollectButton.Size = new Size(174, 28); DeleteCollectButton.TabIndex = 7; @@ -117,11 +125,52 @@ // // textBoxStorageName // - textBoxStorageName.Location = new Point(623, 24); + textBoxStorageName.Location = new Point(623, 90); textBoxStorageName.Name = "textBoxStorageName"; textBoxStorageName.Size = new Size(174, 23); textBoxStorageName.TabIndex = 8; // + // menuStripItem + // + menuStripItem.Anchor = AnchorStyles.Top | AnchorStyles.Right; + menuStripItem.Dock = DockStyle.None; + menuStripItem.Items.AddRange(new ToolStripItem[] { StripMenuItem }); + menuStripItem.Location = new Point(623, 9); + menuStripItem.Name = "menuStripItem"; + menuStripItem.Size = new Size(170, 24); + menuStripItem.TabIndex = 9; + menuStripItem.Text = "File"; + // + // StripMenuItem + // + StripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItem1, сохранитьToolStripMenuItem, загрузитьToolStripMenuItem }); + StripMenuItem.Name = "StripMenuItem"; + StripMenuItem.Size = new Size(42, 20); + StripMenuItem.Text = "Files"; + // + // toolStripMenuItem1 + // + toolStripMenuItem1.Name = "toolStripMenuItem1"; + toolStripMenuItem1.Size = new Size(133, 22); + // + // сохранитьToolStripMenuItem + // + сохранитьToolStripMenuItem.Name = "сохранитьToolStripMenuItem"; + сохранитьToolStripMenuItem.Size = new Size(133, 22); + сохранитьToolStripMenuItem.Text = "Сохранить"; + сохранитьToolStripMenuItem.Click += SaveToolStripMenuItem_Click; + // + // загрузитьToolStripMenuItem + // + загрузитьToolStripMenuItem.Name = "загрузитьToolStripMenuItem"; + загрузитьToolStripMenuItem.Size = new Size(133, 22); + загрузитьToolStripMenuItem.Text = "Загрузить"; + загрузитьToolStripMenuItem.Click += LoadToolStripMenuItem_Click; + // + // openFileDialog + // + openFileDialog.FileName = "openFileDialog1"; + // // FormExcavatorCollection // AutoScaleDimensions = new SizeF(7F, 15F); @@ -136,9 +185,13 @@ Controls.Add(maskedTextBoxNumber); Controls.Add(buttonAddExcavator); Controls.Add(pictureBoxCollection); + Controls.Add(menuStripItem); + MainMenuStrip = menuStripItem; Name = "FormExcavatorCollection"; Text = "Набор экскаваторов"; ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit(); + menuStripItem.ResumeLayout(false); + menuStripItem.PerformLayout(); ResumeLayout(false); PerformLayout(); } @@ -154,5 +207,12 @@ private Button AddCollectButton; private Button DeleteCollectButton; private TextBox textBoxStorageName; + private MenuStrip menuStripItem; + private OpenFileDialog openFileDialog; + private SaveFileDialog saveFileDialog; + private ToolStripMenuItem StripMenuItem; + private ToolStripMenuItem toolStripMenuItem1; + private ToolStripMenuItem сохранитьToolStripMenuItem; + private ToolStripMenuItem загрузитьToolStripMenuItem; } } \ No newline at end of file diff --git a/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.cs b/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.cs index 21ed9ec..e9b0ac0 100644 --- a/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.cs +++ b/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.cs @@ -2,7 +2,7 @@ using ProjectExcavator.Generic; using ProjectExcavator.MovementStrategy; using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; @@ -14,7 +14,7 @@ using System.Windows.Forms; namespace ProjectExcavator { public partial class FormExcavatorCollection : Form - { + { /// /// Набор объектов /// @@ -86,7 +86,7 @@ pictureBoxCollection.Height); } private void AddExcavator(DrawningExcavator excavator) { - if(listBoxStorages.SelectedIndex == -1) + if (listBoxStorages.SelectedIndex == -1) { return; } @@ -95,7 +95,7 @@ pictureBoxCollection.Height); { return; } - if((obj + excavator) != -1) + if ((obj + excavator) != -1) { MessageBox.Show("Объект добавлен"); pictureBoxCollection.Image = obj.ShowExcavator(); @@ -166,6 +166,48 @@ e) } pictureBoxCollection.Image = obj.ShowExcavator(); } - + /// + /// Обработка нажатия "Сохранение" + /// + /// + /// + private void SaveToolStripMenuItem_Click(object sender, EventArgs e) + { + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + if (_storage.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 (_storage.LoadData(openFileDialog.FileName)) + { + MessageBox.Show("Загрузка прошла успешно", + "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Не загрузилось", "Результат", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + ReloadObjects(); + } } } diff --git a/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.resx b/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.resx index af32865..018fd97 100644 --- a/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.resx +++ b/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.resx @@ -117,4 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 149, 22 + + + 289, 17 + \ No newline at end of file -- 2.25.1 From a6bdc22ffef66723977be1be6633566367ce47f5 Mon Sep 17 00:00:00 2001 From: SooNooClose Date: Tue, 21 Nov 2023 13:27:12 +0400 Subject: [PATCH 2/2] lab_6_done --- .../ExcavatorGenericCollection.cs | 3 +- .../ExcavatorsGenericStorage.cs | 99 ++++++++----------- .../FormExcavatorCollection.cs | 20 ++-- 3 files changed, 54 insertions(+), 68 deletions(-) diff --git a/ProjectExcavator/ProjectExcavator/ExcavatorGenericCollection.cs b/ProjectExcavator/ProjectExcavator/ExcavatorGenericCollection.cs index a443262..323aecc 100644 --- a/ProjectExcavator/ProjectExcavator/ExcavatorGenericCollection.cs +++ b/ProjectExcavator/ProjectExcavator/ExcavatorGenericCollection.cs @@ -21,7 +21,7 @@ namespace ProjectExcavator.Generic /// /// Получение объектов коллекции /// - public IEnumerable GetCars => _collection.GetExcavators(); + public IEnumerable GetExcavators => _collection.GetExcavators(); public ExcavatorGenericCollection(int picWidth, int picHeight) { int width = picWidth / _placeSizeWidth; @@ -74,6 +74,7 @@ namespace ProjectExcavator.Generic _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight); } } + private void DrawObjects(Graphics g) { int i = 0; diff --git a/ProjectExcavator/ProjectExcavator/ExcavatorsGenericStorage.cs b/ProjectExcavator/ProjectExcavator/ExcavatorsGenericStorage.cs index 8f2b095..a35b5c7 100644 --- a/ProjectExcavator/ProjectExcavator/ExcavatorsGenericStorage.cs +++ b/ProjectExcavator/ProjectExcavator/ExcavatorsGenericStorage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.DirectoryServices.ActiveDirectory; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -63,25 +64,20 @@ namespace ProjectExcavator.Generic { File.Delete(filename); } - StringBuilder data = new(); - foreach (KeyValuePair> record in _excavatorStorages) + using (StreamWriter sw = File.CreateText(filename)) { - StringBuilder records = new(); - foreach (DrawningExcavator? elem in record.Value.GetCars) - { - records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}"); + sw.WriteLine($"ExcavatorStorage"); + string storageString; + foreach (var storage in _excavatorStorages) + { + storageString = ""; + foreach (var excavator in storage.Value.GetExcavators) + { + storageString += $"{excavator?.GetDataForSave(_separatorForObject)}{_separatorRecords}"; + } + sw.WriteLine($"{storage.Key}{_separatorForKeyValue}{storageString}"); + } } - data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}"); - } - if (data.Length == 0) - { - return false; - } - using FileStream fs = new(filename, FileMode.Create); - byte[] info = new - UTF8Encoding(true).GetBytes($"CarStorage{Environment.NewLine}{data}"); - fs.Write(info, 0, info.Length); return true; } /// @@ -95,58 +91,45 @@ namespace ProjectExcavator.Generic { return false; } - string bufferTextFromFile = ""; - using (FileStream fs = new(filename, FileMode.Open)) + using (StreamReader sr = new StreamReader(filename)) { - byte[] b = new byte[fs.Length]; - UTF8Encoding temp = new(true); - while (fs.Read(b, 0, b.Length) > 0) + string? currentLine = sr.ReadLine(); + if (currentLine == null || !currentLine.Contains("ExcavatorStorage")) { - bufferTextFromFile += temp.GetString(b); + return false; } - } - var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); - if (strs == null || strs.Length == 0) - { - return false; - } - if (!strs[0].StartsWith("ExcavatorStorage")) - { - //если нет такой записи, то это не те данные - return false; - } - _excavatorStorages.Clear(); - foreach (string data in strs) - - - { - string[] record = data.Split(_separatorForKeyValue, - StringSplitOptions.RemoveEmptyEntries); - if (record.Length != 2) + _excavatorStorages.Clear(); + currentLine = sr.ReadLine(); + while (currentLine != null) { - continue; - } - ExcavatorGenericCollection collection = new(_pictureWidth,_pictureHeight); - string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries); - foreach(string elem in set) - { - DrawningExcavator? excavator = elem?.CreateDrawningExcavator(_separatorForObject, _pictureWidth, _pictureHeight); - if(excavator != null) + string[] record = currentLine.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries); + if (record.Length != 2) { - if (collection + excavator == -1) + continue; + } + ExcavatorGenericCollection collection = new(_pictureWidth, _pictureHeight); + string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries); + foreach (string elem in set) + { + DrawningExcavator? excavator = elem?.CreateDrawningExcavator(_separatorForObject, _pictureWidth, _pictureHeight); + if (excavator != null) { - return false; + if (collection + excavator == -1) + { + return false; + } } } + _excavatorStorages.Add(record[0], collection); + currentLine = sr.ReadLine(); } - _excavatorStorages.Add(record[0], collection); + return true; } - return true; } - /// - /// Добавление набора - /// - /// Название набора + /// + /// Добавление набора + /// + /// Название набора public void AddSet(string name) { if (_excavatorStorages.ContainsKey(name)) diff --git a/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.cs b/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.cs index e9b0ac0..695af45 100644 --- a/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.cs +++ b/ProjectExcavator/ProjectExcavator/FormExcavatorCollection.cs @@ -150,9 +150,7 @@ pictureBoxCollection.Height); MessageBox.Show("Не удалось удалить объект"); } } - - private void buttonRefreshCollection_Click(object sender, EventArgs -e) + private void RefreshCollection() { if (listBoxStorages.SelectedIndex == -1) { @@ -166,6 +164,11 @@ e) } pictureBoxCollection.Image = obj.ShowExcavator(); } + + private void buttonRefreshCollection_Click(object sender, EventArgs e) + { + RefreshCollection(); + } /// /// Обработка нажатия "Сохранение" /// @@ -182,8 +185,7 @@ e) } else { - MessageBox.Show("Не сохранилось", "Результат", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Не сохранилось", "Результат",MessageBoxButtons.OK, MessageBoxIcon.Error); } } } @@ -198,13 +200,13 @@ e) { if (_storage.LoadData(openFileDialog.FileName)) { - MessageBox.Show("Загрузка прошла успешно", - "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + ReloadObjects(); + RefreshCollection(); + MessageBox.Show("Загрузка прошла успешно","Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { - MessageBox.Show("Не загрузилось", "Результат", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); } } ReloadObjects(); -- 2.25.1