This commit is contained in:
Alkin Ivan 2024-05-21 03:28:00 +04:00
parent 5e46d4770d
commit 6ead7f2b69
5 changed files with 317 additions and 311 deletions

View File

@ -40,7 +40,7 @@ public abstract class AbstractCompany
/// <summary> /// <summary>
/// Вычисление максимального количества элементов, который можно разместить в окне /// Вычисление максимального количества элементов, который можно разместить в окне
/// </summary> /// </summary>
private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight); private int GetMaxCount => (_pictureWidth / _placeSizeWidth) * (_pictureHeight / _placeSizeHeight);
/// <summary> /// <summary>
/// Конструктор /// Конструктор
@ -62,9 +62,9 @@ public abstract class AbstractCompany
/// <param name="company">Компания</param> /// <param name="company">Компания</param>
/// <param name="boat">Добавляемый объект</param> /// <param name="boat">Добавляемый объект</param>
/// <returns></returns> /// <returns></returns>
public static int operator +(AbstractCompany company, DrawningAirPlane boat) public static int operator +(AbstractCompany company, DrawningAirPlane airPlane)
{ {
return company._collection?.Insert(boat) ?? -1; return company._collection?.Insert(airPlane) ?? -1;
} }
/// <summary> /// <summary>
@ -100,10 +100,15 @@ public abstract class AbstractCompany
SetObjectsPosition(); SetObjectsPosition();
for (int i = 0; i < (_collection?.Count ?? 0); ++i) for (int i = 0; i < (_collection?.Count ?? 0); ++i)
{
try
{ {
DrawningAirPlane? obj = _collection?.Get(i); DrawningAirPlane? obj = _collection?.Get(i);
obj?.DrawTransport(graphics); obj?.DrawTransport(graphics);
} }
catch (Exception) { }
}
return bitmap; return bitmap;
} }

View File

@ -61,6 +61,7 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
throw new CollectionOverflowException(Count); throw new CollectionOverflowException(Count);
_collection.Insert(position, obj); _collection.Insert(position, obj);
return position; return position;
} }
public T Remove(int position) public T Remove(int position)

View File

@ -201,7 +201,6 @@ public class StorageCollection<T>
} }
} }
} }
_storages.Add(record[0], collection); _storages.Add(record[0], collection);
} }
} }

View File

@ -12,8 +12,8 @@ using System.Windows.Forms;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using AirBomber.Exceptions; using AirBomber.Exceptions;
namespace AirBomber namespace AirBomber;
{
public partial class FormAirPlaneCollection : Form public partial class FormAirPlaneCollection : Form
{ {
/// <summary> /// <summary>
@ -24,7 +24,7 @@ namespace AirBomber
/// <summary> /// <summary>
/// Компания /// Компания
/// </summary> /// </summary>
private AbstractCompany? _company; private AbstractCompany? _company = null;
private readonly ILogger _logger; private readonly ILogger _logger;
@ -35,6 +35,8 @@ namespace AirBomber
{ {
InitializeComponent(); InitializeComponent();
_storageCollection = new(); _storageCollection = new();
_logger = logger;
_logger.LogInformation("Форма загрузилась");
} }
/// <summary> /// <summary>
@ -345,4 +347,3 @@ namespace AirBomber
} }
} }
} }
}