PIbd-22_Fedorenko_G.Y._Hydr.../Hydroplane/PlanesGenericStorage.cs

45 lines
1.5 KiB
C#
Raw Normal View History

2023-10-25 10:59:54 +04:00
using Hydroplane.DrawningObjects;
using Hydroplane.MovementStrategy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hydroplane.Generics
{
internal class PlanesGenericStorage
{
readonly Dictionary<string, PlanesGenericCollection<DrawningPlane, DrawningObjectPlane>> _planeStorages;
public List<string> Keys => _planeStorages.Keys.ToList();
private readonly int _pictureWidth;
private readonly int _pictureHeight;
public PlanesGenericStorage(int pictureWidth, int pictureHeight)
{
_planeStorages = new Dictionary<string, PlanesGenericCollection<DrawningPlane, DrawningObjectPlane>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
public void AddSet(string name)
{
if (_planeStorages.ContainsKey(name)) return;
_planeStorages[name] = new PlanesGenericCollection<DrawningPlane, DrawningObjectPlane>(_pictureWidth, _pictureHeight);
}
public void DelSet(string name)
{
if (!_planeStorages.ContainsKey(name)) return;
_planeStorages.Remove(name);
}
public PlanesGenericCollection<DrawningPlane, DrawningObjectPlane>?
this[string ind]
{
get
{
if (_planeStorages.ContainsKey(ind)) return _planeStorages[ind];
return null;
}
}
}
}