PIbd22_Kamcharova_K.A._Doub.../DoubleDeckerBus/Generic/BusesGenericStorage.cs

57 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}
}
}
}