public void InitializeComponents(int columns, int rows) { Columns = columns; Rows = rows; StadiumPanel = new FieldPanel(false); StadiumPanel.Size = new Size(Width, Height); StadiumPanel.BackColor = Color.Transparent; StadiumPanel.BackgroundImage = Properties.Resources.FieldSettingsBackground; int cellWidth = (Width - 60) / columns; int cellHeight = (Height - 60)/ rows; columns += 2; rows += 2; FieldGrid = new BufferedPanel(); FieldGrid.Size = new Size((columns) * cellWidth, (rows) * cellHeight); FieldGrid.BackColor = Color.Transparent; FieldGrid.Location = new Point(40, 30); FieldGrid.Paint += fieldGrid_Paint; FieldGrid.MouseMove += FieldGrid_MouseMove; FieldGrid.MouseUp += FieldGrid_MouseUp; fieldCell = new Rectangle[columns, rows]; for (int r = 0; r < rows; r++) { for (int c = 0; c < columns; c++) { Rectangle cell = new Rectangle(); cell.Size = new Size(cellWidth, cellHeight); cell.Location = new Point(c * cellWidth, r * cellHeight); fieldCell[c, r] = cell; } } StadiumPanel.Controls.Add(FieldGrid); StadiumPanel.UpdateSettings(fieldCell, CurrentSettings, FieldGrid.Location); Controls.Add(StadiumPanel); }
/// <summary> /// Initializes the components. /// </summary> /// <param name="columns"></param> /// <param name="rows"></param> private void InitializeComponents(GameSettings settings) { int columns = settings.Columns; int rows = settings.Rows; #region Statusstrip informationStatusStrip = new StatusStrip(); informationStatusStrip.Renderer = new CustomRenderer(new CustomColorTable()); Controls.Add(informationStatusStrip); #endregion #region Game Panels Panel rootPanel = new Panel(); rootPanel.Size = ClientSize; rootPanel.BackgroundImage = Properties.Resources.Stadium; rootPanel.Location = new Point(0, 20); rootPanel.BorderStyle = BorderStyle.FixedSingle; informationPanel = new InformationPanel(); informationPanel.Size = new Size(ClientSize.Width, 130); informationPanel.Location = new Point(10, 0); informationPanel.BackColor = Color.Transparent; //Initialize stadium panel stadiumPanel = new FieldPanel(true); stadiumPanel.Size = new Size(ClientSize.Width, ClientSize.Height); stadiumPanel.Location = new Point(0, 60); stadiumPanel.BackColor = Color.Transparent; int edgeLength = 20; columns += 2; rows += 2; directionLinesPanel = new Panel(); directionLinesPanel.Size = new Size((columns) * edgeLength, (rows) * edgeLength); directionLinesPanel.BackColor = Color.Transparent; directionLinesPanel.Paint += directionLinesPanel_Paint; directionLinesPanel.Location = new Point(70, 85); fieldGrid = new BufferedPanel(); fieldGrid.Size = directionLinesPanel.Size; fieldGrid.BackColor = Color.Transparent; fieldGrid.Location = new Point(0, 0); fieldGrid.Paint += fieldGrid_Paint; fieldGrid.MouseMove += fieldGrid_MouseMove; fieldGrid.MouseDown += fieldGrid_MouseDown; fieldGrid.MouseUp += fieldGrid_MouseUp; fieldCell = new Rectangle[columns, rows]; for (int r = 0; r < rows; r++) { for (int c = 0; c < columns; c++) { Rectangle cell = new Rectangle(); cell.Size = new Size(edgeLength, edgeLength); cell.Location = new Point(c * edgeLength, r * edgeLength); fieldCell[c, r] = cell; } } directionLinesPanel.Controls.Add(fieldGrid); stadiumPanel.Controls.Add(directionLinesPanel); stadiumPanel.UpdateSettings(fieldCell, settings, directionLinesPanel.Location); #endregion rootPanel.Controls.Add(informationPanel); rootPanel.Controls.Add(stadiumPanel); Controls.Add(rootPanel); }