From 9953e40a20d87fc623f5f3effc8939f0abef7050 Mon Sep 17 00:00:00 2001 From: "safiulova.k" Date: Wed, 20 Dec 2023 09:17:34 +0400 Subject: [PATCH] =?UTF-8?q?=D1=82=D1=80=D0=B5=D1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Catamaran/FormCatamaranCollection.cs | 65 ++++++++++--------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/base/Catamaran/Catamaran/FormCatamaranCollection.cs b/base/Catamaran/Catamaran/FormCatamaranCollection.cs index 1c6b6e7..466a155 100644 --- a/base/Catamaran/Catamaran/FormCatamaranCollection.cs +++ b/base/Catamaran/Catamaran/FormCatamaranCollection.cs @@ -81,40 +81,43 @@ namespace Catamaran } private void AddCatamaran(DrawningCatamaran drawningCatamaran) { - if (listBoxStorages.SelectedIndex == -1) { - return; - } - var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; - if (obj == null) - { - return; - } - - if (obj + drawningCatamaran) - { - MessageBox.Show("Объект добавлен"); - pictureBoxCollection.Image = obj.ShowCatamarans(); - _logger.LogInformation($"Объект {obj.GetType()} добавлен"); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - _logger.LogInformation($"Не удалось добавить объект"); + if (listBoxStorages.SelectedIndex == -1) + { + return; + } + var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + _logger.LogWarning("Добавление пустого объекта"); + return; + } + try + { + if (obj + drawningCatamaran) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = obj.ShowCatamarans(); + _logger.LogInformation($"Объект {obj.GetType()} добавлен"); + } + } + catch (StorageOverflowException ex) + { + MessageBox.Show(ex.Message); + _logger.LogWarning($"{ex.Message} в наборе {listBoxStorages.SelectedItem.ToString()}"); + } } } - - /// - /// Выбор набора - /// - /// - /// - private void ListBoxObjects_SelectedIndexChanged(object sender, - EventArgs e) - { - pictureBoxCollection.Image = - _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowCatamarans(); - } + /// + /// Выбор набора + /// + /// + /// + private void ListBoxObjects_SelectedIndexChanged(object sender, EventArgs e) + { + pictureBoxCollection.Image = + _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowCatamarans(); + } /// /// Удаление набора ///