55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
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<string, BusGenericCollection<DrawingBus, DrawingObjectBus>> _busStorages;
|
||
public List<string> Keys => _busStorages.Keys.ToList();
|
||
private readonly int _pictureWidth;
|
||
private readonly int _pictureHeight;
|
||
public BusesGenericStorage(int pictureWidth, int pictureHeight)
|
||
{
|
||
_busStorages = new Dictionary<string, BusGenericCollection<DrawingBus, DrawingObjectBus>>();
|
||
_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<DrawingBus, DrawingObjectBus>(_pictureWidth, _pictureHeight));
|
||
}
|
||
public void DelSet(string name)
|
||
{
|
||
if (_busStorages.ContainsKey(name))
|
||
{
|
||
_busStorages.Remove(name);
|
||
}
|
||
}
|
||
public BusGenericCollection<DrawingBus, DrawingObjectBus>? this[string ind]
|
||
{
|
||
get
|
||
{
|
||
if (_busStorages.ContainsKey(ind))
|
||
{
|
||
return _busStorages[ind];
|
||
}
|
||
return null;
|
||
}
|
||
}
|
||
}
|
||
}
|