PIbd-22_Bondarenko_M.S._War.../WarmlyShip/WarmlyShip/MapsCollection.cs
Макс Бондаренко 63cec93b5d Готовая лаба
2022-11-02 10:32:24 +04:00

50 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WarmlyShip
{
internal class MapsCollection
{
readonly Dictionary<string, MapWithSetShipGeneric<DrawningObjectShip, 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, MapWithSetShipGeneric<DrawningObjectShip, AbstractMap>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
public void AddMap(string name, AbstractMap map)
{
if (_mapStorages.ContainsKey(name)) return;
_mapStorages.Add(name, new MapWithSetShipGeneric<DrawningObjectShip, AbstractMap>(_pictureWidth, _pictureHeight, map));
}
public void DelMap(string name)
{
if (!_mapStorages.ContainsKey(name)) return;
_mapStorages.Remove(name);
}
public MapWithSetShipGeneric<DrawningObjectShip, AbstractMap> this[string ind]
{
get
{
if(_mapStorages.ContainsKey(ind)) return _mapStorages[ind];
return null;
}
}
}
}