This commit is contained in:
10Г Егор Романов 2022-12-25 13:32:19 +04:00
parent c444b307c1
commit fe2b37f882

View File

@ -1,82 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HoistingCrane
{
internal class MapsCollection
{
/// <summary>
/// Словарь (хранилище) с картами
readonly Dictionary<string, MapWithSetHoistingCraneGeneric<DrawingObjectHoistingCrane, AbstractMap>> _mapStorages;
/// </summary>
readonly Dictionary<string, MapWithSetHoistingCraneGeneric<IDrawingObject, AbstractMap>> _mapStorages;
/// <summary>
/// Возвращение списка названий карт
/// </summary>
public List<string> Keys => _mapStorages.Keys.ToList();
/// <summary>
/// Ширина окна отрисовки
/// </summary>
private readonly int _pictureWidth;
/// <summary>
/// Высота окна отрисовки
/// </summary>
private readonly int _pictureHeight;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="pictureWidth"></param>
/// <param name="pictureHeight"></param>
public MapsCollection(int pictureWidth, int pictureHeight)
{
_mapStorages = new Dictionary<string, MapWithSetHoistingCraneGeneric<DrawingObjectHoistingCrane, AbstractMap>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
/// <summary>
/// Добавление карты
/// </summary>
/// <param name="name">Название карты</param>
/// <param name="map">Карта</param>
public void AddMap(string name, AbstractMap map)
{
if (Keys.Contains(name)) return;
_mapStorages.Add(name, new(_pictureWidth, _pictureHeight, map));
}
/// <summary>
/// Удаление карты
/// </summary>
/// <param name="name">Название карты</param>
public void DelMap(string name)
{
if (_mapStorages.ContainsKey(name))
{
_mapStorages.Remove(name);
}
}
/// <summary>
/// Доступ к парковке
/// </summary>
/// <param name="ind"></param>
/// <returns></returns>
public MapWithSetHoistingCraneGeneric<DrawingObjectHoistingCrane, AbstractMap> this[string ind]
{
get
{
if (ind != String.Empty)
{
MapWithSetHoistingCraneGeneric<DrawingObjectHoistingCrane, AbstractMap> value;
if (_mapStorages.TryGetValue(ind, out value))
{
return value;
}
}
return null;
}
}
}
}