diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs
index 831db09..245df64 100644
--- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs
@@ -12,9 +12,9 @@ using ProjectTractor.DrawningObjects;
using ProjectTractor.Generics;
using ProjectTractor.MovementStrategy;
using ProjectTractor.Exceptions;
-using Microsoft.VisualBasic.Logging;
using System.Xml.Linq;
using System.Linq.Expressions;
+using Serilog;
namespace ProjectTractor
{
@@ -27,12 +27,10 @@ namespace ProjectTractor
///
private readonly TractorsGenericStorage _storage;
- private readonly ILogger _logger;
-
///
/// Конструктор
///
- public FormTractorCollection(ILogger logger)
+ public FormTractorCollection()
{
InitializeComponent();
_storage = new TractorsGenericStorage(pictureBoxCollection.Width,
@@ -76,7 +74,7 @@ namespace ProjectTractor
}
_storage.AddSet(textBoxStorageName.Text);
ReloadObjects();
- _logger.LogInformation($"Добавлен набор: { textBoxStorageName.Text}");
+ Log.Information($"Добавлен набор: {textBoxStorageName.Text}");
}
///
/// Выбор набора
@@ -107,7 +105,7 @@ namespace ProjectTractor
{
_storage.DelSet(name);
ReloadObjects();
- _logger.LogInformation($"Удален набор: {name}");
+ Log.Information($"Удален набор: {name}");
}
}
@@ -136,6 +134,7 @@ namespace ProjectTractor
if (isAdditionSuccessful)
{
MessageBox.Show("Объект добавлен");
+ Log.Information($"Добавлен объект в коллекцию {listBoxStorages.SelectedItem.ToString() ?? string.Empty}");
m.ChangePictureBoxSize(pictureBoxCollection.Width, pictureBoxCollection.Height);
pictureBoxCollection.Image = obj.ShowTractors();
}
@@ -244,7 +243,7 @@ namespace ProjectTractor
_storage.LoadData(openFileDialog.FileName);
MessageBox.Show("Загрузка прошла успешно",
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
- _logger.LogInformation("Загрузка прошла успешно:");
+ Log.Information("Загрузка прошла успешно:");
foreach (var collection in _storage.Keys)
{
listBoxStorages.Items.Add(collection);
@@ -253,7 +252,7 @@ namespace ProjectTractor
}
catch (Exception ex)
{
- _logger.LogWarning("Не удалось загрузить");
+ Log.Warning("Не удалось загрузить");
MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs
index 94e4901..5bf42a7 100644
--- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs
@@ -8,39 +8,30 @@ namespace ProjectTractor
{
internal static class Program
{
+ ///
+ /// The main entry point for the application.
+ ///
[STAThread]
static void Main()
{
- // To customize application configuration such as set high DPI settings or default font,
- // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- var services = new ServiceCollection();
- ConfigureServices(services);
- using (ServiceProvider serviceProvider = services.BuildServiceProvider())
+ string[] path = Directory.GetCurrentDirectory().Split('\\');
+ string pathNeed = "";
+ for (int i = 0; i < path.Length - 3; i++)
{
- Application.Run(serviceProvider.GetRequiredService());
+ pathNeed += path[i] + "\\";
}
- }
- private static void ConfigureServices(ServiceCollection services)
- {
- services.AddSingleton().AddLogging(option =>
- {
- string[] path = Directory.GetCurrentDirectory().Split('\\');
- string pathNeed = "";
- for (int i = 0; i < path.Length - 3; i++)
- {
- pathNeed += path[i] + "\\";
- }
- var configuration = new ConfigurationBuilder()
+ var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
- .AddJsonFile("appsettings.json")
- .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", true)
+ .AddJsonFile(path: $"{pathNeed}appSettings.json", optional: false, reloadOnChange: true)
.Build();
-
- var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
- option.SetMinimumLevel(LogLevel.Information);
- option.AddSerilog(logger);
- });
+ Log.Logger = new LoggerConfiguration()
+ .ReadFrom.Configuration(configuration)
+ .CreateLogger();
+ Application.SetHighDpiMode(HighDpiMode.SystemAware);
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new FormTractorCollection());
}
}
}
\ No newline at end of file
diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ProjectTractor.csproj b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ProjectTractor.csproj
index 83002d2..858ead4 100644
--- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ProjectTractor.csproj
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ProjectTractor.csproj
@@ -40,6 +40,6 @@
-
+
\ No newline at end of file
diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/g.txt b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/g.txt
new file mode 100644
index 0000000..e69de29