public void InitializeColorPanels(List <Color> colors) { int numRows = GlobalBounds.Height / PanelHeight; int numCols = GlobalBounds.Width / PanelWidth; Layout = new GridLayout(GUI, this, GlobalBounds.Height / PanelHeight, GlobalBounds.Width / PanelWidth); int rc = Math.Max((int)(Math.Sqrt(colors.Count)), 2); for (int i = 0; i < colors.Count; i++) { ColorPanel panel = new ColorPanel(GUI, Layout) { CurrentColor = colors[i] }; int row = i / numCols; int col = i % numCols; panel.OnClicked += () => panel_OnClicked(panel.CurrentColor); Layout.SetComponentPosition(panel, col, row, 1, 1); } }
public void InitializeColorPanels(List<Color> colors) { int numRows = GlobalBounds.Height/PanelHeight; int numCols = GlobalBounds.Width/PanelWidth; Layout = new GridLayout(GUI, this, GlobalBounds.Height / PanelHeight, GlobalBounds.Width / PanelWidth); int rc = Math.Max((int)(Math.Sqrt(colors.Count)), 2); for (int i = 0; i < colors.Count; i++) { ColorPanel panel = new ColorPanel(GUI, Layout) { CurrentColor = colors[i] }; int row = i / numCols; int col = i % numCols; panel.OnClicked += () => panel_OnClicked(panel.CurrentColor); Layout.SetComponentPosition(panel, col, row, 1, 1); } }