Конец 7ой лабы
This commit is contained in:
parent
a8ae769f5c
commit
fec308c18b
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormTractorCollection(ILogger<FormTractorCollection> 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}");
|
||||
}
|
||||
/// <summary>
|
||||
/// Выбор набора
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -8,39 +8,30 @@ namespace ProjectTractor
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[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<FormTractorCollection>());
|
||||
pathNeed += path[i] + "\\";
|
||||
}
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<FormTractorCollection>().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());
|
||||
}
|
||||
}
|
||||
}
|
@ -40,6 +40,6 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
|
||||
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="https://appsemble.app/api.json" /></VisualStudio></ProjectExtensions>
|
||||
|
||||
</Project>
|
0
RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/g.txt
Normal file
0
RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/g.txt
Normal file
Loading…
Reference in New Issue
Block a user