Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d2629e9ec | |||
| c768bdc104 | |||
| e810b85e3b | |||
| b4d3dfbd11 | |||
| 1284f2afaa | |||
| 05134ead4f | |||
| 6cfe8083f8 |
@@ -8,6 +8,18 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
|
||||||
|
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ namespace AirBomber.Generics
|
|||||||
where T : DrawningBomber
|
where T : DrawningBomber
|
||||||
where U : IMoveableObject
|
where U : IMoveableObject
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получение объектов коллекции
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<T?> GetPlane => _collection.GetPlane();
|
||||||
|
|
||||||
private readonly int _pictureWidth;
|
private readonly int _pictureWidth;
|
||||||
private readonly int _pictureHeight;
|
private readonly int _pictureHeight;
|
||||||
private readonly int _placeSizeWidth = 155;
|
private readonly int _placeSizeWidth = 155;
|
||||||
@@ -38,15 +43,14 @@ namespace AirBomber.Generics
|
|||||||
return collect._collection.Insert(obj);
|
return collect._collection.Insert(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator -(BomberGenericCollection<T, U> collect, int
|
public static T? operator -(BomberGenericCollection<T, U> collect, int pos)
|
||||||
pos)
|
|
||||||
{
|
{
|
||||||
T? obj = collect._collection[pos];
|
T? obj = collect._collection[pos];
|
||||||
if (obj == null)
|
if (obj != null)
|
||||||
{
|
{
|
||||||
return false;
|
collect._collection.Remove(pos);
|
||||||
}
|
}
|
||||||
return collect._collection.Remove(pos);
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public U? GetU(int pos)
|
public U? GetU(int pos)
|
||||||
@@ -99,6 +103,5 @@ namespace AirBomber.Generics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AirBomber.DrawningObjects;
|
using AirBomber.DrawningObjects;
|
||||||
|
using AirBomber.Exceptions;
|
||||||
using AirBomber.MovementStrategy;
|
using AirBomber.MovementStrategy;
|
||||||
|
|
||||||
namespace AirBomber.Generics
|
namespace AirBomber.Generics
|
||||||
@@ -25,6 +26,18 @@ namespace AirBomber.Generics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _pictureHeight;
|
private readonly int _pictureHeight;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Разделитель для записи ключа и значения элемента словаря
|
||||||
|
/// </summary>
|
||||||
|
private static readonly char _separatorForKeyValue = '|';
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записей коллекции данных в файл
|
||||||
|
/// </summary>
|
||||||
|
private readonly char _separatorRecords = ';';
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записи информации по объекту в файл
|
||||||
|
/// </summary>
|
||||||
|
private static readonly char _separatorForObject = ':';
|
||||||
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pictureWidth"></param>
|
/// <param name="pictureWidth"></param>
|
||||||
@@ -65,5 +78,93 @@ namespace AirBomber.Generics
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void SaveData(string filename)
|
||||||
|
{
|
||||||
|
if (File.Exists(filename))
|
||||||
|
{
|
||||||
|
File.Delete(filename);
|
||||||
|
}
|
||||||
|
StringBuilder data = new();
|
||||||
|
foreach (KeyValuePair<string, BomberGenericCollection<DrawningBomber, DrawningObjectBomber>> record in _bomberStorage)
|
||||||
|
{
|
||||||
|
StringBuilder records = new();
|
||||||
|
foreach (DrawningBomber? elem in record.Value.GetPlane)
|
||||||
|
{
|
||||||
|
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||||
|
}
|
||||||
|
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||||
|
}
|
||||||
|
if (data.Length == 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Невалидная операция, нет данных для сохранения");
|
||||||
|
}
|
||||||
|
|
||||||
|
using (StreamWriter writer = new StreamWriter(filename))
|
||||||
|
{
|
||||||
|
writer.Write($"BomberStorage{Environment.NewLine}{data}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Загрузка информации по установкам в хранилище из файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Путь и имя файла</param>
|
||||||
|
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||||
|
public void LoadData(string filename)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filename))
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException("Файл не найден");
|
||||||
|
}
|
||||||
|
|
||||||
|
using (StreamReader reader = new StreamReader(filename))
|
||||||
|
{
|
||||||
|
string cheker = reader.ReadLine();
|
||||||
|
if (cheker == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Нет данных для загрузки");
|
||||||
|
}
|
||||||
|
if (!cheker.StartsWith("BomberStorage"))
|
||||||
|
{
|
||||||
|
throw new FormatException("Неверный формат ввода");
|
||||||
|
}
|
||||||
|
_bomberStorage.Clear();
|
||||||
|
string strs;
|
||||||
|
bool firstinit = true;
|
||||||
|
while ((strs = reader.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
if (strs == null && firstinit)
|
||||||
|
{
|
||||||
|
throw new Exception("Нет данных для загрузки");
|
||||||
|
}
|
||||||
|
if (strs == null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
firstinit = false;
|
||||||
|
string name = strs.Split(_separatorForKeyValue)[0];
|
||||||
|
BomberGenericCollection<DrawningBomber, DrawningObjectBomber> collection = new(_pictureWidth, _pictureHeight);
|
||||||
|
foreach (string data in strs.Split(_separatorForKeyValue)[1].Split(_separatorRecords))
|
||||||
|
{
|
||||||
|
DrawningBomber? air =
|
||||||
|
data?.CreateDrawningBomber(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||||
|
if (air != null)
|
||||||
|
{
|
||||||
|
try { _ = collection + air; }
|
||||||
|
catch (BomberNotFoundException e)
|
||||||
|
{
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
catch (StorageOverflowException e)
|
||||||
|
{
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
_bomberStorage.Add(name, collection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
AirBomber/BomberNotFoundException.cs
Normal file
19
AirBomber/BomberNotFoundException.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirBomber.Exceptions
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
internal class BomberNotFoundException : ApplicationException
|
||||||
|
{
|
||||||
|
public BomberNotFoundException(int i) : base($"Не найден объект по позиции {i}") { }
|
||||||
|
public BomberNotFoundException() : base() { }
|
||||||
|
public BomberNotFoundException(string message) : base(message) { }
|
||||||
|
public BomberNotFoundException(string message, Exception exception) : base(message, exception) { }
|
||||||
|
protected BomberNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
62
AirBomber/ExtentionDrawningBomber.cs
Normal file
62
AirBomber/ExtentionDrawningBomber.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
using AirBomber.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirBomber.DrawningObjects
|
||||||
|
{
|
||||||
|
public static class ExtentionDrawningBomber
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Создание объекта из строки
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">Строка с данными для создания объекта</param>
|
||||||
|
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||||
|
/// <param name="width">Ширина</param>
|
||||||
|
/// <param name="height">Высота</param>
|
||||||
|
/// <returns>Объект</returns>
|
||||||
|
public static DrawningBomber? CreateDrawningBomber(this string info, char separatorForObject, int width, int height)
|
||||||
|
{
|
||||||
|
string[] strs = info.Split(separatorForObject);
|
||||||
|
if (strs.Length == 3)
|
||||||
|
{
|
||||||
|
return new DrawningBomber(Convert.ToInt32(strs[0]),
|
||||||
|
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
||||||
|
}
|
||||||
|
else if (strs.Length == 6)
|
||||||
|
{
|
||||||
|
return new DrawningAirBomber(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;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Получение данных для сохранения в файл
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="drawningBomber">Сохраняемый объект</param>
|
||||||
|
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||||
|
/// <returns>Строка с данными по объекту</returns>
|
||||||
|
public static string GetDataForSave(this DrawningBomber drawningBomber,
|
||||||
|
char separatorForAir)
|
||||||
|
{
|
||||||
|
var air = drawningBomber.EntityBomber;
|
||||||
|
if (air == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
var str =
|
||||||
|
$"{air.Speed}{separatorForAir}{air.Weight}{separatorForAir}{air.BodyColor.Name}";
|
||||||
|
if (air is not EntityAirBomber airBomber)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return $"{str}{separatorForAir}{airBomber.DopColor.Name}{separatorForAir}{airBomber.Toplivo}{separatorForAir}{airBomber.Rocket}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
124
AirBomber/FormBomberCollection.Designer.cs
generated
124
AirBomber/FormBomberCollection.Designer.cs
generated
@@ -39,9 +39,16 @@
|
|||||||
ButtonAddBomber = new Button();
|
ButtonAddBomber = new Button();
|
||||||
MessageBoxBomber = new TextBox();
|
MessageBoxBomber = new TextBox();
|
||||||
PicBoxBomberCollection = new PictureBox();
|
PicBoxBomberCollection = new PictureBox();
|
||||||
|
menuStrip = new MenuStrip();
|
||||||
|
fileToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
SaveToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
LoadToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
openFileDialog = new OpenFileDialog();
|
||||||
|
saveFileDialog = new OpenFileDialog();
|
||||||
Tools.SuspendLayout();
|
Tools.SuspendLayout();
|
||||||
Kit.SuspendLayout();
|
Kit.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)PicBoxBomberCollection).BeginInit();
|
((System.ComponentModel.ISupportInitialize)PicBoxBomberCollection).BeginInit();
|
||||||
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// Tools
|
// Tools
|
||||||
@@ -51,9 +58,11 @@
|
|||||||
Tools.Controls.Add(ButtonRemoveBomber);
|
Tools.Controls.Add(ButtonRemoveBomber);
|
||||||
Tools.Controls.Add(ButtonAddBomber);
|
Tools.Controls.Add(ButtonAddBomber);
|
||||||
Tools.Controls.Add(MessageBoxBomber);
|
Tools.Controls.Add(MessageBoxBomber);
|
||||||
Tools.Location = new Point(538, 5);
|
Tools.Location = new Point(471, 4);
|
||||||
|
Tools.Margin = new Padding(3, 2, 3, 2);
|
||||||
Tools.Name = "Tools";
|
Tools.Name = "Tools";
|
||||||
Tools.Size = new Size(250, 556);
|
Tools.Padding = new Padding(3, 2, 3, 2);
|
||||||
|
Tools.Size = new Size(219, 417);
|
||||||
Tools.TabIndex = 0;
|
Tools.TabIndex = 0;
|
||||||
Tools.TabStop = false;
|
Tools.TabStop = false;
|
||||||
Tools.Text = "Инструменты";
|
Tools.Text = "Инструменты";
|
||||||
@@ -64,18 +73,21 @@
|
|||||||
Kit.Controls.Add(AddKit);
|
Kit.Controls.Add(AddKit);
|
||||||
Kit.Controls.Add(KitTextbox);
|
Kit.Controls.Add(KitTextbox);
|
||||||
Kit.Controls.Add(listBoxStorages);
|
Kit.Controls.Add(listBoxStorages);
|
||||||
Kit.Location = new Point(17, 33);
|
Kit.Location = new Point(15, 25);
|
||||||
|
Kit.Margin = new Padding(3, 2, 3, 2);
|
||||||
Kit.Name = "Kit";
|
Kit.Name = "Kit";
|
||||||
Kit.Size = new Size(227, 282);
|
Kit.Padding = new Padding(3, 2, 3, 2);
|
||||||
|
Kit.Size = new Size(199, 212);
|
||||||
Kit.TabIndex = 4;
|
Kit.TabIndex = 4;
|
||||||
Kit.TabStop = false;
|
Kit.TabStop = false;
|
||||||
Kit.Text = "Наборы";
|
Kit.Text = "Наборы";
|
||||||
//
|
//
|
||||||
// RemoveKit
|
// RemoveKit
|
||||||
//
|
//
|
||||||
RemoveKit.Location = new Point(11, 231);
|
RemoveKit.Location = new Point(10, 173);
|
||||||
|
RemoveKit.Margin = new Padding(3, 2, 3, 2);
|
||||||
RemoveKit.Name = "RemoveKit";
|
RemoveKit.Name = "RemoveKit";
|
||||||
RemoveKit.Size = new Size(193, 36);
|
RemoveKit.Size = new Size(169, 27);
|
||||||
RemoveKit.TabIndex = 3;
|
RemoveKit.TabIndex = 3;
|
||||||
RemoveKit.Text = "Удалить набор";
|
RemoveKit.Text = "Удалить набор";
|
||||||
RemoveKit.UseVisualStyleBackColor = true;
|
RemoveKit.UseVisualStyleBackColor = true;
|
||||||
@@ -83,9 +95,10 @@
|
|||||||
//
|
//
|
||||||
// AddKit
|
// AddKit
|
||||||
//
|
//
|
||||||
AddKit.Location = new Point(11, 63);
|
AddKit.Location = new Point(10, 47);
|
||||||
|
AddKit.Margin = new Padding(3, 2, 3, 2);
|
||||||
AddKit.Name = "AddKit";
|
AddKit.Name = "AddKit";
|
||||||
AddKit.Size = new Size(193, 36);
|
AddKit.Size = new Size(169, 27);
|
||||||
AddKit.TabIndex = 2;
|
AddKit.TabIndex = 2;
|
||||||
AddKit.Text = "Добавить набор";
|
AddKit.Text = "Добавить набор";
|
||||||
AddKit.UseVisualStyleBackColor = true;
|
AddKit.UseVisualStyleBackColor = true;
|
||||||
@@ -93,26 +106,29 @@
|
|||||||
//
|
//
|
||||||
// KitTextbox
|
// KitTextbox
|
||||||
//
|
//
|
||||||
KitTextbox.Location = new Point(15, 30);
|
KitTextbox.Location = new Point(13, 22);
|
||||||
|
KitTextbox.Margin = new Padding(3, 2, 3, 2);
|
||||||
KitTextbox.Name = "KitTextbox";
|
KitTextbox.Name = "KitTextbox";
|
||||||
KitTextbox.Size = new Size(189, 27);
|
KitTextbox.Size = new Size(166, 23);
|
||||||
KitTextbox.TabIndex = 1;
|
KitTextbox.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// listBoxStorages
|
// listBoxStorages
|
||||||
//
|
//
|
||||||
listBoxStorages.FormattingEnabled = true;
|
listBoxStorages.FormattingEnabled = true;
|
||||||
listBoxStorages.ItemHeight = 20;
|
listBoxStorages.ItemHeight = 15;
|
||||||
listBoxStorages.Location = new Point(11, 109);
|
listBoxStorages.Location = new Point(10, 82);
|
||||||
|
listBoxStorages.Margin = new Padding(3, 2, 3, 2);
|
||||||
listBoxStorages.Name = "listBoxStorages";
|
listBoxStorages.Name = "listBoxStorages";
|
||||||
listBoxStorages.Size = new Size(193, 104);
|
listBoxStorages.Size = new Size(169, 79);
|
||||||
listBoxStorages.TabIndex = 0;
|
listBoxStorages.TabIndex = 0;
|
||||||
listBoxStorages.SelectedIndexChanged += ListBoxObjects_SelectedIndexChanged;
|
listBoxStorages.SelectedIndexChanged += ListBoxObjects_SelectedIndexChanged;
|
||||||
//
|
//
|
||||||
// ButtonRefreshCollection
|
// ButtonRefreshCollection
|
||||||
//
|
//
|
||||||
ButtonRefreshCollection.Location = new Point(28, 481);
|
ButtonRefreshCollection.Location = new Point(24, 336);
|
||||||
|
ButtonRefreshCollection.Margin = new Padding(3, 2, 3, 2);
|
||||||
ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
||||||
ButtonRefreshCollection.Size = new Size(193, 37);
|
ButtonRefreshCollection.Size = new Size(169, 28);
|
||||||
ButtonRefreshCollection.TabIndex = 3;
|
ButtonRefreshCollection.TabIndex = 3;
|
||||||
ButtonRefreshCollection.Text = "Обновить коллекцию";
|
ButtonRefreshCollection.Text = "Обновить коллекцию";
|
||||||
ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
||||||
@@ -120,9 +136,10 @@
|
|||||||
//
|
//
|
||||||
// ButtonRemoveBomber
|
// ButtonRemoveBomber
|
||||||
//
|
//
|
||||||
ButtonRemoveBomber.Location = new Point(28, 416);
|
ButtonRemoveBomber.Location = new Point(24, 301);
|
||||||
|
ButtonRemoveBomber.Margin = new Padding(3, 2, 3, 2);
|
||||||
ButtonRemoveBomber.Name = "ButtonRemoveBomber";
|
ButtonRemoveBomber.Name = "ButtonRemoveBomber";
|
||||||
ButtonRemoveBomber.Size = new Size(193, 41);
|
ButtonRemoveBomber.Size = new Size(169, 31);
|
||||||
ButtonRemoveBomber.TabIndex = 2;
|
ButtonRemoveBomber.TabIndex = 2;
|
||||||
ButtonRemoveBomber.Text = "Удалить самолёт";
|
ButtonRemoveBomber.Text = "Удалить самолёт";
|
||||||
ButtonRemoveBomber.UseVisualStyleBackColor = true;
|
ButtonRemoveBomber.UseVisualStyleBackColor = true;
|
||||||
@@ -130,9 +147,10 @@
|
|||||||
//
|
//
|
||||||
// ButtonAddBomber
|
// ButtonAddBomber
|
||||||
//
|
//
|
||||||
ButtonAddBomber.Location = new Point(28, 321);
|
ButtonAddBomber.Location = new Point(24, 241);
|
||||||
|
ButtonAddBomber.Margin = new Padding(3, 2, 3, 2);
|
||||||
ButtonAddBomber.Name = "ButtonAddBomber";
|
ButtonAddBomber.Name = "ButtonAddBomber";
|
||||||
ButtonAddBomber.Size = new Size(193, 41);
|
ButtonAddBomber.Size = new Size(169, 31);
|
||||||
ButtonAddBomber.TabIndex = 1;
|
ButtonAddBomber.TabIndex = 1;
|
||||||
ButtonAddBomber.Text = "Добавить самолёт";
|
ButtonAddBomber.Text = "Добавить самолёт";
|
||||||
ButtonAddBomber.UseVisualStyleBackColor = true;
|
ButtonAddBomber.UseVisualStyleBackColor = true;
|
||||||
@@ -140,26 +158,73 @@
|
|||||||
//
|
//
|
||||||
// MessageBoxBomber
|
// MessageBoxBomber
|
||||||
//
|
//
|
||||||
MessageBoxBomber.Location = new Point(28, 368);
|
MessageBoxBomber.Location = new Point(24, 276);
|
||||||
|
MessageBoxBomber.Margin = new Padding(3, 2, 3, 2);
|
||||||
MessageBoxBomber.Name = "MessageBoxBomber";
|
MessageBoxBomber.Name = "MessageBoxBomber";
|
||||||
MessageBoxBomber.Size = new Size(193, 27);
|
MessageBoxBomber.Size = new Size(169, 23);
|
||||||
MessageBoxBomber.TabIndex = 0;
|
MessageBoxBomber.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// PicBoxBomberCollection
|
// PicBoxBomberCollection
|
||||||
//
|
//
|
||||||
PicBoxBomberCollection.Location = new Point(1, -2);
|
PicBoxBomberCollection.Location = new Point(7, 28);
|
||||||
|
PicBoxBomberCollection.Margin = new Padding(3, 2, 3, 2);
|
||||||
PicBoxBomberCollection.Name = "PicBoxBomberCollection";
|
PicBoxBomberCollection.Name = "PicBoxBomberCollection";
|
||||||
PicBoxBomberCollection.Size = new Size(473, 563);
|
PicBoxBomberCollection.Size = new Size(473, 422);
|
||||||
PicBoxBomberCollection.TabIndex = 1;
|
PicBoxBomberCollection.TabIndex = 1;
|
||||||
PicBoxBomberCollection.TabStop = false;
|
PicBoxBomberCollection.TabStop = false;
|
||||||
//
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||||
|
menuStrip.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem });
|
||||||
|
menuStrip.Location = new Point(0, 0);
|
||||||
|
menuStrip.Name = "menuStrip";
|
||||||
|
menuStrip.Padding = new Padding(5, 2, 0, 2);
|
||||||
|
menuStrip.Size = new Size(700, 24);
|
||||||
|
menuStrip.TabIndex = 2;
|
||||||
|
menuStrip.Text = "Файл";
|
||||||
|
//
|
||||||
|
// fileToolStripMenuItem
|
||||||
|
//
|
||||||
|
fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem });
|
||||||
|
fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||||
|
fileToolStripMenuItem.Size = new Size(48, 20);
|
||||||
|
fileToolStripMenuItem.Text = "Файл";
|
||||||
|
//
|
||||||
|
// SaveToolStripMenuItem
|
||||||
|
//
|
||||||
|
SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||||
|
SaveToolStripMenuItem.Size = new Size(141, 22);
|
||||||
|
SaveToolStripMenuItem.Text = "Сохранение";
|
||||||
|
SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// LoadToolStripMenuItem
|
||||||
|
//
|
||||||
|
LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||||
|
LoadToolStripMenuItem.Size = new Size(141, 22);
|
||||||
|
LoadToolStripMenuItem.Text = "Загрузка";
|
||||||
|
LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
openFileDialog.FileName = "openFileDialog";
|
||||||
|
openFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
|
// saveFileDialog
|
||||||
|
//
|
||||||
|
saveFileDialog.FileName = "saveFileDialog";
|
||||||
|
saveFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
// FormBomberCollection
|
// FormBomberCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 581);
|
ClientSize = new Size(700, 467);
|
||||||
Controls.Add(PicBoxBomberCollection);
|
Controls.Add(PicBoxBomberCollection);
|
||||||
Controls.Add(Tools);
|
Controls.Add(Tools);
|
||||||
|
Controls.Add(menuStrip);
|
||||||
|
MainMenuStrip = menuStrip;
|
||||||
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
Name = "FormBomberCollection";
|
Name = "FormBomberCollection";
|
||||||
Text = "FormBomberCollection";
|
Text = "FormBomberCollection";
|
||||||
Tools.ResumeLayout(false);
|
Tools.ResumeLayout(false);
|
||||||
@@ -167,7 +232,10 @@
|
|||||||
Kit.ResumeLayout(false);
|
Kit.ResumeLayout(false);
|
||||||
Kit.PerformLayout();
|
Kit.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)PicBoxBomberCollection).EndInit();
|
((System.ComponentModel.ISupportInitialize)PicBoxBomberCollection).EndInit();
|
||||||
|
menuStrip.ResumeLayout(false);
|
||||||
|
menuStrip.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -183,5 +251,11 @@
|
|||||||
private Button RemoveKit;
|
private Button RemoveKit;
|
||||||
private Button AddKit;
|
private Button AddKit;
|
||||||
private TextBox KitTextbox;
|
private TextBox KitTextbox;
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem fileToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
|
private OpenFileDialog saveFileDialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using AirBomber.Exceptions;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace AirBomber
|
namespace AirBomber
|
||||||
{
|
{
|
||||||
@@ -17,10 +20,13 @@ namespace AirBomber
|
|||||||
{
|
{
|
||||||
private readonly BomberGenericStorage _bomber;
|
private readonly BomberGenericStorage _bomber;
|
||||||
|
|
||||||
public FormBomberCollection()
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
public FormBomberCollection(ILogger<FormBomberCollection> logger)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_bomber = new BomberGenericStorage(PicBoxBomberCollection.Width, PicBoxBomberCollection.Height);
|
_bomber = new BomberGenericStorage(PicBoxBomberCollection.Width, PicBoxBomberCollection.Height);
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReloadObjects()
|
private void ReloadObjects()
|
||||||
@@ -57,41 +63,45 @@ namespace AirBomber
|
|||||||
}
|
}
|
||||||
PicBoxBomberCollection.Image = obj.ShowBomber();
|
PicBoxBomberCollection.Image = obj.ShowBomber();
|
||||||
}
|
}
|
||||||
|
private void AddBomber(DrawningBomber bomber)
|
||||||
|
{
|
||||||
|
|
||||||
|
var obj = _bomber[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Добавление пустого объекта");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_ = obj + bomber;
|
||||||
|
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
PicBoxBomberCollection.Image = obj.ShowBomber();
|
||||||
|
_logger.LogInformation($"Добавлен объект в набор {listBoxStorages.SelectedItem.ToString()}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
_logger.LogWarning($"{ex.Message} в наборе {listBoxStorages.SelectedItem.ToString()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
private void ButtonAddBomber_Click(object sender, EventArgs e)
|
private void ButtonAddBomber_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var formBomberConfig = new FormBomberConfig();
|
FormBomberConfig form = new FormBomberConfig();
|
||||||
|
form.Show();
|
||||||
formBomberConfig.AddEvent(bomber =>
|
form.AddEvent(AddBomber);
|
||||||
{
|
|
||||||
if (listBoxStorages.SelectedIndex != -1)
|
|
||||||
{
|
|
||||||
var obj = _bomber[listBoxStorages.SelectedItem?.ToString() ?? string.Empty];
|
|
||||||
if (obj != null)
|
|
||||||
{
|
|
||||||
if (obj + bomber != 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
PicBoxBomberCollection.Image = obj.ShowBomber();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
formBomberConfig.Show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonRemoveBomber_Click(object sender, EventArgs e)
|
private void ButtonRemoveBomber_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
|
_logger.LogWarning("Удаление объекта из несуществующего набора");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var obj = _bomber[listBoxStorages.SelectedItem.ToString() ??
|
var obj = _bomber[listBoxStorages.SelectedItem.ToString() ??
|
||||||
@@ -106,14 +116,24 @@ namespace AirBomber
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(MessageBoxBomber.Text);
|
int pos = Convert.ToInt32(MessageBoxBomber.Text);
|
||||||
|
try
|
||||||
|
{
|
||||||
if (obj - pos != null)
|
if (obj - pos != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
PicBoxBomberCollection.Image = obj.ShowBomber();
|
PicBoxBomberCollection.Image = obj.ShowBomber();
|
||||||
|
_logger.LogInformation($"Удален объект из набора {listBoxStorages.SelectedItem.ToString()}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
|
_logger.LogWarning($"Не удалось удалить объект из набора {listBoxStorages.SelectedItem.ToString()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (BomberNotFoundException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
_logger.LogWarning($"{ex.Message} из набора {listBoxStorages.SelectedItem.ToString()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,23 +143,28 @@ namespace AirBomber
|
|||||||
{
|
{
|
||||||
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
_logger.LogWarning("Пустое название набора");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_bomber.AddSet(KitTextbox.Text);
|
_bomber.AddSet(KitTextbox.Text);
|
||||||
ReloadObjects();
|
ReloadObjects();
|
||||||
|
_logger.LogInformation($"Добавлен набор: {KitTextbox.Text}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveKit_Click(object sender, EventArgs e)
|
private void RemoveKit_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
|
_logger.LogWarning("Удаление невыбранного набора");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
string name = listBoxStorages.SelectedItem.ToString() ?? string.Empty;
|
||||||
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
_bomber.DelSet(listBoxStorages.SelectedItem.ToString()
|
_bomber.DelSet(listBoxStorages.SelectedItem.ToString()
|
||||||
?? string.Empty);
|
?? string.Empty);
|
||||||
ReloadObjects();
|
ReloadObjects();
|
||||||
|
_logger.LogInformation($"Удален набор: {name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ListBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
|
private void ListBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
@@ -147,5 +172,42 @@ namespace AirBomber
|
|||||||
PicBoxBomberCollection.Image =
|
PicBoxBomberCollection.Image =
|
||||||
_bomber[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowBomber();
|
_bomber[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowBomber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_bomber.SaveData(saveFileDialog.FileName);
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
_logger.LogInformation($"Сохранение наборов в файл {saveFileDialog.FileName}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
_logger.LogWarning($"Не удалось сохранить наборы с ошибкой: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_bomber.LoadData(openFileDialog.FileName);
|
||||||
|
ReloadObjects();
|
||||||
|
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
_logger.LogInformation($"Загрузились наборы из файла {openFileDialog.FileName}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
_logger.LogWarning($"Не удалось сохранить наборы с ошибкой: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,4 +117,16 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>145, 1</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>315, 1</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>62</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace AirBomber
|
namespace AirBomber
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
@@ -11,7 +16,30 @@ namespace AirBomber
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormBomberCollection());
|
var services = new ServiceCollection();
|
||||||
|
ConfigureServices(services);
|
||||||
|
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
|
||||||
|
{
|
||||||
|
Application.Run(serviceProvider.GetRequiredService<FormBomberCollection>());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddSingleton<FormBomberCollection>().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().SetBasePath(Directory.GetCurrentDirectory()).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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using AirBomber.Exceptions;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
@@ -53,12 +54,11 @@ namespace ProjectBomber.Generics
|
|||||||
public int Insert(T plane, int position)
|
public int Insert(T plane, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= _maxCount)
|
if (position < 0 || position >= _maxCount)
|
||||||
return -1;
|
throw new BomberNotFoundException(position);
|
||||||
|
|
||||||
if (Count >= _maxCount)
|
if (Count >= _maxCount)
|
||||||
return -1;
|
throw new StorageOverflowException(position);
|
||||||
|
_places.Insert(0, plane);
|
||||||
_places.Insert(position, plane);
|
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -69,10 +69,10 @@ namespace ProjectBomber.Generics
|
|||||||
public bool Remove(int position)
|
public bool Remove(int position)
|
||||||
{
|
{
|
||||||
/// Проверка позиции
|
/// Проверка позиции
|
||||||
if (position < 0 || position >= _places.Count)
|
if (position < 0 || position > _maxCount || position >= Count)
|
||||||
return false;
|
throw new BomberNotFoundException(position);
|
||||||
/// Удаление объекта из массива, присвоив элементу массива значение null
|
/// Удаление объекта из массива, присвоив элементу массива значение null
|
||||||
_places[position] = null;
|
_places.RemoveAt(position);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -86,12 +86,16 @@ namespace ProjectBomber.Generics
|
|||||||
{
|
{
|
||||||
if (position < 0 || position > _maxCount)
|
if (position < 0 || position > _maxCount)
|
||||||
return null;
|
return null;
|
||||||
|
if (_places.Count <= position)
|
||||||
|
return null;
|
||||||
return _places[position];
|
return _places[position];
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (position < 0 || position > _maxCount)
|
if (position < 0 || position > _maxCount)
|
||||||
return;
|
return;
|
||||||
|
if (_places.Count <= position)
|
||||||
|
return;
|
||||||
_places[position] = value;
|
_places[position] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
AirBomber/StorageOverflowException.cs
Normal file
19
AirBomber/StorageOverflowException.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirBomber.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 contex) : base(info, contex) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
20
AirBomber/appsettings.json
Normal file
20
AirBomber/appsettings.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"Serilog": {
|
||||||
|
"Using": [ "Serilog.Sinks.File" ],
|
||||||
|
"MinimumLevel": "Information",
|
||||||
|
"WriteTo": [
|
||||||
|
{
|
||||||
|
"Name": "File",
|
||||||
|
"Args": {
|
||||||
|
"path": "Logs/log_.log",
|
||||||
|
"rollingInterval": "Day",
|
||||||
|
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
|
||||||
|
"Properties": {
|
||||||
|
"Application": "GasolineTanker"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user