Dispose of discarded slots when adding new

This commit is contained in:
Kurt 2022-06-11 09:37:44 -07:00
parent cc8cbeb749
commit b01ec96ac8

View File

@ -17,8 +17,8 @@ public PokeGrid()
public readonly List<PictureBox> Entries = new();
public int Slots { get; private set; }
private int sizeW = 40;
private int sizeH = 30;
private int sizeW = 68;
private int sizeH = 56;
public bool InitializeGrid(int width, int height, SpriteBuilder info)
{
@ -44,6 +44,8 @@ private void Generate(int width, int height)
{
SuspendLayout();
Controls.Clear();
foreach (var c in Entries)
c.Dispose();
Entries.Clear();
int colWidth = sizeW;
@ -77,8 +79,8 @@ public static PictureBox GetControl(int width, int height) => new()
AutoSize = false,
SizeMode = PictureBoxSizeMode.CenterImage,
BackColor = SlotUtil.GoodDataColor,
Width = width + (2 * 1),
Height = height + (2 * 1),
Width = width + (2 * border),
Height = height + (2 * border),
Padding = Padding.Empty,
Margin = Padding.Empty,
BorderStyle = BorderStyle.FixedSingle,