From cb5c91f8848e11c6db459f4974009958052e3087 Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Mon, 27 Nov 2023 16:54:00 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=9B=D1=8E=D1=82=D0=BE=20=D0=BD=D0=B0?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D0=B9=D0=BA=D0=B5=D1=82=D1=87=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Monorail/Monorail/FormMonorailCollection.cs | 37 +++++++++++-------- .../Monorail/MonorailGenericCollection.cs | 3 +- Monorail/Monorail/MonorailGenericStorage.cs | 10 ++--- .../Monorail/MonorailNotFoundException.cs | 20 ++++++++++ Monorail/Monorail/SetGeneric.cs | 12 ++++-- Monorail/Monorail/StorageOverflowException.cs | 19 ++++++++++ 6 files changed, 74 insertions(+), 27 deletions(-) create mode 100644 Monorail/Monorail/MonorailNotFoundException.cs create mode 100644 Monorail/Monorail/StorageOverflowException.cs diff --git a/Monorail/Monorail/FormMonorailCollection.cs b/Monorail/Monorail/FormMonorailCollection.cs index 975e8c0..50d5d19 100644 --- a/Monorail/Monorail/FormMonorailCollection.cs +++ b/Monorail/Monorail/FormMonorailCollection.cs @@ -1,4 +1,5 @@ using Monorail.DrawningObjects; +using Monorail.Exceptions; using Monorail.Generics; using Monorail.MovementStrategy; using System; @@ -63,16 +64,16 @@ namespace Monorail form.Show(); Action? monorailDelegate = new((m) => { - bool q = (obj + m); - if (q) + try { + bool q = obj + m; MessageBox.Show("Объект добавлен"); m.ChangePictureBoxSize(pictureBoxCollection.Width, pictureBoxCollection.Height); pictureBoxCollection.Image = obj.ShowMonorails(); } - else + catch (StorageOverflowException ex) { - MessageBox.Show("Не удалось добавить объект"); + MessageBox.Show(ex.Message); } }); form.AddEvent(monorailDelegate); @@ -96,14 +97,15 @@ namespace Monorail return; } int pos = Convert.ToInt32(maskedTextBox.Text); - if (obj - pos != null) + try { + var q = obj - pos; MessageBox.Show("Объект удален"); pictureBoxCollection.Image = obj.ShowMonorails(); } - else + catch (MonorailNotFoundException ex) { - MessageBox.Show("Не удалось удалить объект"); + MessageBox.Show(ex.Message); } } @@ -161,15 +163,17 @@ MessageBoxIcon.Question) == DialogResult.Yes) { if (saveFileDialog.ShowDialog() == DialogResult.OK) { - if (_storage.SaveData(saveFileDialog.FileName)) + try { + _storage.SaveData(saveFileDialog.FileName); MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); } - else + catch (Exception ex) { - MessageBox.Show("Не сохранилось", "Результат", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"Не сохранилось: {ex.Message}", +"Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } @@ -179,8 +183,8 @@ MessageBoxIcon.Question) == DialogResult.Yes) { if (openFileDialog.ShowDialog() == DialogResult.OK) { - if (_storage.LoadData(openFileDialog.FileName)) - { + try { + _storage.LoadData(openFileDialog.FileName); MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); foreach(var collection in _storage.Keys) @@ -188,10 +192,11 @@ MessageBoxIcon.Question) == DialogResult.Yes) listBoxStorages.Items.Add(collection); } } - else + catch (Exception ex) { - MessageBox.Show("Не загрузилось", "Результат", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"Не загрузилось: {ex.Message}", +"Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } } diff --git a/Monorail/Monorail/MonorailGenericCollection.cs b/Monorail/Monorail/MonorailGenericCollection.cs index 294242b..d029dd1 100644 --- a/Monorail/Monorail/MonorailGenericCollection.cs +++ b/Monorail/Monorail/MonorailGenericCollection.cs @@ -45,8 +45,7 @@ namespace Monorail.Generics pos) { T? obj = collect._collection[pos]; - if (obj != null) - collect._collection.Remove(pos); + collect._collection.Remove(pos); return obj; } diff --git a/Monorail/Monorail/MonorailGenericStorage.cs b/Monorail/Monorail/MonorailGenericStorage.cs index aa87182..ab8e734 100644 --- a/Monorail/Monorail/MonorailGenericStorage.cs +++ b/Monorail/Monorail/MonorailGenericStorage.cs @@ -50,7 +50,7 @@ MonorailGenericCollection> record in _ if (data.Length == 0) { - return false; + throw new Exception("Невалиданя операция, нет данных для сохранения"); } string toWrite = $"MonorailStorage{Environment.NewLine}{data}"; var strs = toWrite.Split(new char[] { '\n', '\r' }, @@ -70,7 +70,7 @@ StringSplitOptions.RemoveEmptyEntries); { if (!File.Exists(filename)) { - return false; + throw new Exception("Файл не найден"); } using (StreamReader sr = new(filename)) { @@ -79,11 +79,11 @@ StringSplitOptions.RemoveEmptyEntries); StringSplitOptions.RemoveEmptyEntries); if (strs == null || strs.Length == 0) { - return false; + throw new Exception("Нет данных для загрузки"); } if (!strs[0].StartsWith("MonorailStorage")) { - return false; + throw new Exception("Неверный формат данных"); } _monorailStorages.Clear(); do @@ -107,7 +107,7 @@ StringSplitOptions.RemoveEmptyEntries); { if (!(collection + monorail)) { - return false; + throw new Exception("Ошибка добавления в коллекцию"); } } } diff --git a/Monorail/Monorail/MonorailNotFoundException.cs b/Monorail/Monorail/MonorailNotFoundException.cs new file mode 100644 index 0000000..ce76086 --- /dev/null +++ b/Monorail/Monorail/MonorailNotFoundException.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Runtime.Serialization; + + +namespace Monorail.Exceptions +{ + [Serializable] + internal class MonorailNotFoundException : ApplicationException + { + public MonorailNotFoundException(int i) : base($"Не найден объект по позиции {i}") { } + public MonorailNotFoundException() : base () { } + public MonorailNotFoundException(string message) : base(message) { } + public MonorailNotFoundException(string message, Exception exception) : base(message, exception) { } + protected MonorailNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } + } +} diff --git a/Monorail/Monorail/SetGeneric.cs b/Monorail/Monorail/SetGeneric.cs index 421b2ef..9ec3dcf 100644 --- a/Monorail/Monorail/SetGeneric.cs +++ b/Monorail/Monorail/SetGeneric.cs @@ -1,8 +1,10 @@ -using System; +using Monorail.Exceptions; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; namespace Monorail.Generics { @@ -23,7 +25,7 @@ namespace Monorail.Generics public bool Insert(T monorail) { if (_places.Count == _maxCount) - return false; + throw new StorageOverflowException(_maxCount); Insert(monorail, 0); return true; @@ -31,7 +33,9 @@ namespace Monorail.Generics public bool Insert(T monorail, int position) { - if (!(position >= 0 && position <= Count && _places.Count < _maxCount)) + if (_places.Count == _maxCount) + throw new StorageOverflowException(_maxCount); + if (!(position >= 0 && position <= Count)) return false; _places.Insert(position, monorail); return true; @@ -39,7 +43,7 @@ namespace Monorail.Generics public bool Remove(int position) { if (!(position >= 0 && position < Count)) - return false; + throw new MonorailNotFoundException(position); _places.RemoveAt(position); return true; } diff --git a/Monorail/Monorail/StorageOverflowException.cs b/Monorail/Monorail/StorageOverflowException.cs new file mode 100644 index 0000000..882a917 --- /dev/null +++ b/Monorail/Monorail/StorageOverflowException.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Runtime.Serialization; + +namespace Monorail.Exceptions +{ + [Serializable] + internal class StorageOverflowException : ApplicationException + { + public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: { count}") { } + public StorageOverflowException() : base() { } + public StorageOverflowException(string message) : base(message) { } + public StorageOverflowException(string message, Exception exception) : base(message, exception) { } + protected StorageOverflowException(SerializationInfo info, StreamingContext context) : base(info, context) { } + } +} -- 2.25.1 From 157ab08659a3e947fb82a818e5d474613a2d5b56 Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Mon, 27 Nov 2023 20:02:51 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=81=20nlog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Monorail/Monorail/FormMonorailCollection.cs | 30 ++++++++++++++----- Monorail/Monorail/Monorail.csproj | 11 +++++++ Monorail/Monorail/MonorailGenericStorage.cs | 8 +++--- Monorail/Monorail/Program.cs | 32 +++++++++++++++++---- Monorail/Monorail/nlog.config | 14 +++++++++ 5 files changed, 78 insertions(+), 17 deletions(-) create mode 100644 Monorail/Monorail/nlog.config diff --git a/Monorail/Monorail/FormMonorailCollection.cs b/Monorail/Monorail/FormMonorailCollection.cs index 50d5d19..18cfdc3 100644 --- a/Monorail/Monorail/FormMonorailCollection.cs +++ b/Monorail/Monorail/FormMonorailCollection.cs @@ -1,4 +1,5 @@ -using Monorail.DrawningObjects; +using Microsoft.Extensions.Logging; +using Monorail.DrawningObjects; using Monorail.Exceptions; using Monorail.Generics; using Monorail.MovementStrategy; @@ -12,18 +13,21 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using System.Xml.Linq; namespace Monorail { public partial class FormMonorailCollection : Form { private readonly MonorailGenericStorage _storage; + private readonly ILogger _logger; - public FormMonorailCollection() + public FormMonorailCollection(ILogger logger) { InitializeComponent(); _storage = new MonorailGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height); + _logger = logger; } private void ReloadObjects() @@ -68,6 +72,7 @@ namespace Monorail { bool q = obj + m; MessageBox.Show("Объект добавлен"); + _logger.LogInformation($"Добавлен объект в коллекцию {listBoxStorages.SelectedItem.ToString() ?? string.Empty}"); m.ChangePictureBoxSize(pictureBoxCollection.Width, pictureBoxCollection.Height); pictureBoxCollection.Image = obj.ShowMonorails(); } @@ -96,17 +101,23 @@ namespace Monorail { return; } - int pos = Convert.ToInt32(maskedTextBox.Text); try { + + int pos = Convert.ToInt32(maskedTextBox.Text); var q = obj - pos; MessageBox.Show("Объект удален"); + _logger.LogInformation($"Удален объект из коллекции {listBoxStorages.SelectedItem.ToString() ?? string.Empty} по номеру {pos}"); pictureBoxCollection.Image = obj.ShowMonorails(); } catch (MonorailNotFoundException ex) { MessageBox.Show(ex.Message); } + catch(FormatException ex) + { + MessageBox.Show("Введите число"); + } } private void updateCollectionButton_Click(object sender, EventArgs e) @@ -137,12 +148,14 @@ _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowMonorail { return; } - if (MessageBox.Show($"Удалить объект{listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, + if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - _storage.DelSet(listBoxStorages.SelectedItem.ToString() - ?? string.Empty); + string name = listBoxStorages.SelectedItem.ToString() + ?? string.Empty; + _storage.DelSet(name); ReloadObjects(); + _logger.LogInformation($"Удален набор: {name}"); } } @@ -157,6 +170,7 @@ MessageBoxIcon.Question) == DialogResult.Yes) } _storage.AddSet(storageAddNameBox.Text); ReloadObjects(); + _logger.LogInformation($"Добавлен набор: {storageAddNameBox.Text}"); } private void SaveToolStripMenuItem_Click(object sender, EventArgs e) @@ -168,6 +182,7 @@ MessageBoxIcon.Question) == DialogResult.Yes) _storage.SaveData(saveFileDialog.FileName); MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + _logger.LogInformation($"Файл {saveFileDialog.FileName} успешно сохранен"); } catch (Exception ex) { @@ -187,7 +202,8 @@ MessageBoxIcon.Question) == DialogResult.Yes) _storage.LoadData(openFileDialog.FileName); MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); - foreach(var collection in _storage.Keys) + _logger.LogInformation($"Файл {openFileDialog.FileName} успешно загружен"); + foreach (var collection in _storage.Keys) { listBoxStorages.Items.Add(collection); } diff --git a/Monorail/Monorail/Monorail.csproj b/Monorail/Monorail/Monorail.csproj index a30a3e2..9aebb36 100644 --- a/Monorail/Monorail/Monorail.csproj +++ b/Monorail/Monorail/Monorail.csproj @@ -6,6 +6,11 @@ true + + + + + True @@ -21,4 +26,10 @@ + + + Always + + + \ No newline at end of file diff --git a/Monorail/Monorail/MonorailGenericStorage.cs b/Monorail/Monorail/MonorailGenericStorage.cs index ab8e734..707cfda 100644 --- a/Monorail/Monorail/MonorailGenericStorage.cs +++ b/Monorail/Monorail/MonorailGenericStorage.cs @@ -70,7 +70,7 @@ StringSplitOptions.RemoveEmptyEntries); { if (!File.Exists(filename)) { - throw new Exception("Файл не найден"); + throw new IOException("Файл не найден"); } using (StreamReader sr = new(filename)) { @@ -79,11 +79,11 @@ StringSplitOptions.RemoveEmptyEntries); StringSplitOptions.RemoveEmptyEntries); if (strs == null || strs.Length == 0) { - throw new Exception("Нет данных для загрузки"); + throw new IOException("Нет данных для загрузки"); } if (!strs[0].StartsWith("MonorailStorage")) { - throw new Exception("Неверный формат данных"); + throw new IOException("Неверный формат данных"); } _monorailStorages.Clear(); do @@ -107,7 +107,7 @@ StringSplitOptions.RemoveEmptyEntries); { if (!(collection + monorail)) { - throw new Exception("Ошибка добавления в коллекцию"); + return false; } } } diff --git a/Monorail/Monorail/Program.cs b/Monorail/Monorail/Program.cs index 2934ef4..d23d4e6 100644 --- a/Monorail/Monorail/Program.cs +++ b/Monorail/Monorail/Program.cs @@ -1,23 +1,43 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; + using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; namespace Monorail { - static class Program + internal static class Program { /// - /// The main entry point for the application. + /// The main entry point for the application. /// [STAThread] static void Main() { - Application.SetHighDpiMode(HighDpiMode.SystemAware); - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new FormMonorailCollection()); + + ApplicationConfiguration.Initialize(); + var services = new ServiceCollection(); + ConfigureServices(services); + using (ServiceProvider serviceProvider = + services.BuildServiceProvider()) + { + + Application.Run(serviceProvider.GetRequiredService()); + } + } + private static void ConfigureServices(ServiceCollection services) + { + services.AddSingleton() + .AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); } } } diff --git a/Monorail/Monorail/nlog.config b/Monorail/Monorail/nlog.config new file mode 100644 index 0000000..f35d051 --- /dev/null +++ b/Monorail/Monorail/nlog.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file -- 2.25.1 From 0898a6c9d866ed05aafd111694f1469405a9a4a7 Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Mon, 27 Nov 2023 20:37:21 +0400 Subject: [PATCH 3/5] All done --- Monorail/Monorail/FormMonorailCollection.cs | 18 ++++++------ Monorail/Monorail/Monorail.csproj | 8 ++---- Monorail/Monorail/Program.cs | 32 ++++++++------------- Monorail/Monorail/log.txt | 0 Monorail/Monorail/nlog.config | 14 --------- 5 files changed, 23 insertions(+), 49 deletions(-) create mode 100644 Monorail/Monorail/log.txt delete mode 100644 Monorail/Monorail/nlog.config diff --git a/Monorail/Monorail/FormMonorailCollection.cs b/Monorail/Monorail/FormMonorailCollection.cs index 18cfdc3..9ae6367 100644 --- a/Monorail/Monorail/FormMonorailCollection.cs +++ b/Monorail/Monorail/FormMonorailCollection.cs @@ -14,20 +14,19 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Xml.Linq; +using Serilog; namespace Monorail { public partial class FormMonorailCollection : Form { private readonly MonorailGenericStorage _storage; - private readonly ILogger _logger; - public FormMonorailCollection(ILogger logger) + public FormMonorailCollection() { InitializeComponent(); _storage = new MonorailGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height); - _logger = logger; } private void ReloadObjects() @@ -72,7 +71,7 @@ namespace Monorail { bool q = obj + m; MessageBox.Show("Объект добавлен"); - _logger.LogInformation($"Добавлен объект в коллекцию {listBoxStorages.SelectedItem.ToString() ?? string.Empty}"); + Log.Information($"Добавлен объект в коллекцию {listBoxStorages.SelectedItem.ToString() ?? string.Empty}"); m.ChangePictureBoxSize(pictureBoxCollection.Width, pictureBoxCollection.Height); pictureBoxCollection.Image = obj.ShowMonorails(); } @@ -107,7 +106,7 @@ namespace Monorail int pos = Convert.ToInt32(maskedTextBox.Text); var q = obj - pos; MessageBox.Show("Объект удален"); - _logger.LogInformation($"Удален объект из коллекции {listBoxStorages.SelectedItem.ToString() ?? string.Empty} по номеру {pos}"); + Log.Information($"Удален объект из коллекции {listBoxStorages.SelectedItem.ToString() ?? string.Empty} по номеру {pos}"); pictureBoxCollection.Image = obj.ShowMonorails(); } catch (MonorailNotFoundException ex) @@ -155,7 +154,7 @@ MessageBoxIcon.Question) == DialogResult.Yes) ?? string.Empty; _storage.DelSet(name); ReloadObjects(); - _logger.LogInformation($"Удален набор: {name}"); + Log.Information($"Удален набор: {name}"); } } @@ -170,7 +169,7 @@ MessageBoxIcon.Question) == DialogResult.Yes) } _storage.AddSet(storageAddNameBox.Text); ReloadObjects(); - _logger.LogInformation($"Добавлен набор: {storageAddNameBox.Text}"); + Log.Information($"Добавлен набор: {storageAddNameBox.Text}"); } private void SaveToolStripMenuItem_Click(object sender, EventArgs e) @@ -182,7 +181,7 @@ MessageBoxIcon.Question) == DialogResult.Yes) _storage.SaveData(saveFileDialog.FileName); MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); - _logger.LogInformation($"Файл {saveFileDialog.FileName} успешно сохранен"); + Log.Information($"Файл {saveFileDialog.FileName} успешно сохранен"); } catch (Exception ex) { @@ -202,11 +201,12 @@ MessageBoxIcon.Question) == DialogResult.Yes) _storage.LoadData(openFileDialog.FileName); MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); - _logger.LogInformation($"Файл {openFileDialog.FileName} успешно загружен"); + Log.Information($"Файл {openFileDialog.FileName} успешно загружен"); foreach (var collection in _storage.Keys) { listBoxStorages.Items.Add(collection); } + ReloadObjects(); } catch (Exception ex) { diff --git a/Monorail/Monorail/Monorail.csproj b/Monorail/Monorail/Monorail.csproj index 9aebb36..7271e69 100644 --- a/Monorail/Monorail/Monorail.csproj +++ b/Monorail/Monorail/Monorail.csproj @@ -9,6 +9,8 @@ + + @@ -26,10 +28,4 @@ - - - Always - - - \ No newline at end of file diff --git a/Monorail/Monorail/Program.cs b/Monorail/Monorail/Program.cs index d23d4e6..5a4cf29 100644 --- a/Monorail/Monorail/Program.cs +++ b/Monorail/Monorail/Program.cs @@ -8,36 +8,28 @@ using System.Drawing; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; +using Serilog; +using Serilog.Events; +using Serilog.Formatting.Json; namespace Monorail { internal static class Program { /// - /// The main entry point for the application. + /// The main entry point for the application. /// [STAThread] static void Main() { - - ApplicationConfiguration.Initialize(); - var services = new ServiceCollection(); - ConfigureServices(services); - using (ServiceProvider serviceProvider = - services.BuildServiceProvider()) - { - - Application.Run(serviceProvider.GetRequiredService()); - } - } - private static void ConfigureServices(ServiceCollection services) - { - services.AddSingleton() - .AddLogging(option => - { - option.SetMinimumLevel(LogLevel.Information); - option.AddNLog("nlog.config"); - }); + Log.Logger = new LoggerConfiguration() + .WriteTo.File("log.txt") + .MinimumLevel.Debug() + .CreateLogger(); + Application.SetHighDpiMode(HighDpiMode.SystemAware); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new FormMonorailCollection()); } } } diff --git a/Monorail/Monorail/log.txt b/Monorail/Monorail/log.txt new file mode 100644 index 0000000..e69de29 diff --git a/Monorail/Monorail/nlog.config b/Monorail/Monorail/nlog.config deleted file mode 100644 index f35d051..0000000 --- a/Monorail/Monorail/nlog.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file -- 2.25.1 From b7b8f43b95ac10a91c8c2802f8b93762a611b058 Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Mon, 27 Nov 2023 20:38:03 +0400 Subject: [PATCH 4/5] All done 2.0 --- Monorail/Monorail/log.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Monorail/Monorail/log.txt diff --git a/Monorail/Monorail/log.txt b/Monorail/Monorail/log.txt deleted file mode 100644 index e69de29..0000000 -- 2.25.1 From b854383cbe5941789e254b89354786fd73ca3297 Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Tue, 28 Nov 2023 12:32:20 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=9A=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=81=D0=B2=D0=BE=D0=B8=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Monorail/Monorail/DrawningMonorail.cs | 2 ++ Monorail/Monorail/ExtentionDrawningMonorail.cs | 4 +++- Monorail/Monorail/FormMonorailCollection.cs | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Monorail/Monorail/DrawningMonorail.cs b/Monorail/Monorail/DrawningMonorail.cs index c28d4e6..570a851 100644 --- a/Monorail/Monorail/DrawningMonorail.cs +++ b/Monorail/Monorail/DrawningMonorail.cs @@ -15,6 +15,8 @@ namespace Monorail.DrawningObjects public int GetPosX => _startPosX; + char separator = '|'; + public int GetPosY => _startPosY; public int GetWidth => _monoRailWidth; diff --git a/Monorail/Monorail/ExtentionDrawningMonorail.cs b/Monorail/Monorail/ExtentionDrawningMonorail.cs index 7b646a7..b4e5908 100644 --- a/Monorail/Monorail/ExtentionDrawningMonorail.cs +++ b/Monorail/Monorail/ExtentionDrawningMonorail.cs @@ -1,6 +1,8 @@ -using Monorail.Entities; +using Microsoft.VisualBasic.Logging; +using Monorail.Entities; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text; diff --git a/Monorail/Monorail/FormMonorailCollection.cs b/Monorail/Monorail/FormMonorailCollection.cs index 9ae6367..34d6162 100644 --- a/Monorail/Monorail/FormMonorailCollection.cs +++ b/Monorail/Monorail/FormMonorailCollection.cs @@ -77,6 +77,7 @@ namespace Monorail } catch (StorageOverflowException ex) { + Log.Warning($"Коллекция {listBoxStorages.SelectedItem.ToString() ?? string.Empty} переполнена"); MessageBox.Show(ex.Message); } }); @@ -111,10 +112,12 @@ namespace Monorail } catch (MonorailNotFoundException ex) { + Log.Warning($"Не получилось удалить объект из коллекции {listBoxStorages.SelectedItem.ToString() ?? string.Empty}"); MessageBox.Show(ex.Message); } catch(FormatException ex) { + Log.Warning($"Было введено не число"); MessageBox.Show("Введите число"); } } @@ -185,6 +188,7 @@ MessageBoxIcon.Question) == DialogResult.Yes) } catch (Exception ex) { + Log.Warning("Не удалось сохранить"); MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -210,6 +214,7 @@ MessageBoxIcon.Question) == DialogResult.Yes) } catch (Exception ex) { + Log.Warning("Не удалось загрузить"); MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); -- 2.25.1