Этап 2 - maps collection

This commit is contained in:
Arklightning 2022-10-28 16:38:54 +04:00
parent 1fce4712de
commit ce71636c0d
2 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Trolleybus
{
internal class MapsCollection
{
/// Словарь (хранилище) с картами
readonly Dictionary<string, MapWithSetTrolleybusGeneric<DrawningObjectTrolleybus,
AbstractMap>> _mapStorages;
/// Возвращение списка названий карт
public List<string> Keys => _mapStorages.Keys.ToList();
/// Ширина окна отрисовки
private readonly int _pictureWidth;
/// Высота окна отрисовки
private readonly int _pictureHeight;
/// Конструктор
/// <param name="pictureWidth"></param>
/// <param name="pictureHeight"></param>
public MapsCollection(int pictureWidth, int pictureHeight)
{
_mapStorages = new Dictionary<string,
MapWithSetTrolleybusGeneric<DrawningObjectTrolleybus, AbstractMap>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
/// Добавление карты
/// <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));
}
/// Удаление карты
/// <param name="name">Название карты</param>
public void DelMap(string name)
{
_mapStorages.Remove(name);
}
/// Доступ к депо
/// <param name="ind"></param>
/// <returns></returns>
public MapWithSetTrolleybusGeneric<DrawningObjectTrolleybus, AbstractMap> this[string ind]
{
get
{
_mapStorages.TryGetValue(ind, out var mapWithSetTractorsGeneric);
return mapWithSetTractorsGeneric;
}
}
}
}

View File

@ -75,6 +75,7 @@
</Compile>
<Compile Include="AutoStopMap.cs" />
<Compile Include="IDrawingObject.cs" />
<Compile Include="MapsCollection.cs" />
<Compile Include="MapWithSetTrolleybusGeneric.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />