84 lines
2.6 KiB
C#
84 lines
2.6 KiB
C#
using ProjectElectricLocomotive.DrawingObjects;
|
|
using ProjectElectricLocomotive.Generics;
|
|
using ProjectElectricLocomotive.MovementStrategy;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ProjectElectricLocomotive
|
|
{
|
|
internal class LocomotivesGenericStorage
|
|
{
|
|
/// <summary>
|
|
/// Словарь (хранилище)
|
|
/// </summary>
|
|
readonly Dictionary<string, LocomotivesGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>> _locomotivesStorage;
|
|
|
|
/// <summary>
|
|
/// Возвращение списка названий наборов
|
|
/// </summary>
|
|
public List<string> Keys => _locomotivesStorage.Keys.ToList();
|
|
|
|
|
|
private readonly int _pictureWidth;
|
|
|
|
private readonly int _pictureHeight;
|
|
|
|
/// <summary>
|
|
/// Конструктор
|
|
/// </summary>
|
|
/// <param name="pictureWidth"></param>
|
|
/// <param name="pictureHeight"></param>
|
|
public LocomotivesGenericStorage(int pictureWidth, int pictureHeight)
|
|
{
|
|
_locomotivesStorage = new Dictionary<string, LocomotivesGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>>();
|
|
_pictureWidth = pictureWidth;
|
|
_pictureHeight = pictureHeight;
|
|
}
|
|
/// <summary>
|
|
/// Добавление набора
|
|
/// </summary>
|
|
/// <param name="name">Название набора</param>
|
|
public void AddSet(string name)
|
|
{
|
|
if (!_locomotivesStorage.ContainsKey(name))
|
|
{
|
|
_locomotivesStorage.Add(name, new LocomotivesGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>(_pictureWidth, _pictureHeight));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Удаление набора
|
|
/// </summary>
|
|
/// <param name="name">Название набора</param>
|
|
public void DelSet(string name)
|
|
{
|
|
if (_locomotivesStorage.ContainsKey(name))
|
|
{
|
|
_locomotivesStorage.Remove(name);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Доступ к набору
|
|
/// </summary>
|
|
/// <param name="ind"></param>
|
|
/// <returns></returns>
|
|
public LocomotivesGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>?
|
|
this[string ind]
|
|
{
|
|
get
|
|
{
|
|
if (_locomotivesStorage.ContainsKey(ind))
|
|
{
|
|
return _locomotivesStorage[ind];
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|