Example #1
0
        public void ReloadGrid()
        {
            foreach (PictureBox button in buttons.Values)
            {
                Controls.Remove(button);
            }

            buttons.Clear();

            int currentX = 280;
            int currentY = 50;
            int incrementX = (75 * 8) / layout.GetMaxY();
            int incrementY = (75 * 8) / layout.GetMaxX();

            for (int i = 0; i < layout.GetMaxX(); i++)
            {
                for (int j = 0; j < layout.GetMaxY(); j++)
                {
                    PictureBox button = new PictureBox();
                    button.MinimumSize = new Size(i, j);
                    button.Name = "grid-" + i + "-" + j;
                    button.Size = new Size(incrementX, incrementY);
                    button.Location = new Point(currentX, currentY);
                    button.BackgroundImageLayout = ImageLayout.Stretch;
                    button.Click += Button_Click;
                    Controls.Add(button);
                    buttons[new Point(i, j)] = button;
                    currentX += incrementX;
                }

                currentX = 280;
                currentY += incrementY;
            }

            ReloadPictures();
        }