PIbd-23_Vrazhkin_S_A_Electr.../lab1/Generics/LocosGenericStorage.cs
2023-10-31 13:25:13 +04:00

41 lines
1.2 KiB
C#

namespace ElectricLocomotive;
public class LocosGenericStorage
{
readonly Dictionary<string, LocosGenericCollection<DrawingLocomotiv, DrawingObjectLocomotiv>> _electricLocoStorages;
public List<string> Keys => _electricLocoStorages.Keys.ToList();
private readonly int _pictureWidth;
private readonly int _pictureHeight;
public LocosGenericStorage(int pictureWidth, int pictureHeight)
{
_electricLocoStorages = new Dictionary<string,
LocosGenericCollection<DrawingLocomotiv, DrawingObjectLocomotiv>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
public void AddSet(string name)
{
_electricLocoStorages.Add(name, new LocosGenericCollection<DrawingLocomotiv, DrawingObjectLocomotiv> (_pictureWidth, _pictureHeight));
}
public void DelSet(string name)
{
if (!_electricLocoStorages.ContainsKey(name))
return;
_electricLocoStorages.Remove(name);
}
public LocosGenericCollection<DrawingLocomotiv, DrawingObjectLocomotiv>? this[string ind]
{
get
{
if (_electricLocoStorages.ContainsKey(ind))
return _electricLocoStorages[ind];
return null;
}
}
}