PIbd-22_Kashin_M.I_Gasoline.../GasolineTanker/GasolineTanker/MapsCollection.cs
2022-10-15 22:41:24 +04:00

46 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GasolineTanker
{
internal class MapsCollection
{
readonly Dictionary<string, MapWithSetGasolienTankerGeneric<DrawingObjectGasolineTanker, AbstractMap>> _mapStorages;
public List<string> Keys => _mapStorages.Keys.ToList();
private readonly int _pictureWidth;
private readonly int _pictureHeight;
public MapsCollection(int pictureWidth, int pictureHeight)
{
_mapStorages = new Dictionary<string, MapWithSetGasolienTankerGeneric<DrawingObjectGasolineTanker, AbstractMap>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
public void AddMap(string name, AbstractMap map)
{
if (!_mapStorages.ContainsKey(name)) _mapStorages.Add(name, new MapWithSetGasolienTankerGeneric<DrawingObjectGasolineTanker, AbstractMap>(_pictureWidth, _pictureHeight, map));
}
public void DelMap(string name)
{
_mapStorages.Remove(name);
}
public MapWithSetGasolienTankerGeneric<DrawingObjectGasolineTanker, AbstractMap> this[string ind]
{
get
{
if (_mapStorages.TryGetValue(ind, out var map)) return map;
return null;
}
}
}
}