using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using DoubleDeckerbus.Drawing; using DoubleDeckerbus.Move_Strategy; namespace DoubleDeckerbus.Generic { internal class BusesGenericStorage { readonly Dictionary> _busStorages; public List Keys => _busStorages.Keys.ToList(); private readonly int _pictureWidth; private readonly int _pictureHeight; public BusesGenericStorage(int pictureWidth, int pictureHeight) { _busStorages = new Dictionary>(); _pictureWidth = pictureWidth; _pictureHeight = pictureHeight; } public void AddSet(string name) { foreach (string nameStorage in Keys) { if (nameStorage == name) { MessageBox.Show("Набор с заданным именем уже есть", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } _busStorages.Add(name, new BusGenericCollection(_pictureWidth, _pictureHeight)); } public void DelSet(string name) { if (_busStorages.ContainsKey(name)) { _busStorages.Remove(name); } } public BusGenericCollection? this[string ind] { get { if (_busStorages.ContainsKey(ind)) { return _busStorages[ind]; } return null; } } } }