47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Sailboat
|
|||
|
{
|
|||
|
internal class MapsCollection
|
|||
|
{
|
|||
|
readonly Dictionary<string, MapWithSetBoatsGeneric<DrawingObjectBoat, 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, MapWithSetBoatsGeneric<DrawingObjectBoat, AbstractMap>>();
|
|||
|
_pictureWidth = pictureWidth;
|
|||
|
_pictureHeight = pictureHeight;
|
|||
|
}
|
|||
|
|
|||
|
public void AddMap(string name, AbstractMap map)
|
|||
|
{
|
|||
|
if (Keys.Contains(name)) return;
|
|||
|
_mapStorages.Add(name, new MapWithSetBoatsGeneric<DrawingObjectBoat, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
|||
|
}
|
|||
|
|
|||
|
public void DelMap(string name)
|
|||
|
{
|
|||
|
_mapStorages.Remove(name);
|
|||
|
}
|
|||
|
|
|||
|
public MapWithSetBoatsGeneric<DrawingObjectBoat, AbstractMap> this[string ind]
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
_mapStorages.TryGetValue(ind, out var result);
|
|||
|
return result;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|