public void setMineFields(PartidaForm form, bool opponentBoard) { mineFields = new MineField[rows, columns]; int startVerticalPosition = startPositionY; int startHorizontalPosition = startPositionX; int number = 1; string boardBtn = "board2_"; if (opponentBoard) { boardBtn = "board1_"; } for (int y = 0; y < rows; y++) { for (int x = 0; x < columns; x++) { mineFields[y, x] = new MineField(); mineFields[y, x].createButton(boardBtn, number, form, opponentBoard, startVerticalPosition, startHorizontalPosition); startHorizontalPosition += addWidth; number++; } startHorizontalPosition = startPositionX; startVerticalPosition += addHeight; } }
public void createButton(string board, int number, PartidaForm form, bool opponentBoard, int startVerticalPosition, int startHorizontalPosition) { btn = new Button(); btn.Height = heightField; btn.Width = widthFields; btn.Name = board + "btn" + number.ToString(); btn.Location = new Point(startHorizontalPosition, startVerticalPosition); setImage(); if (opponentBoard) { btn.Click += new EventHandler(form.btn_Mina_Click); } if (opponentBoard) { form.getGroupBox_OponnentShips().Controls.Add(btn); } else { form.getGroupBox_YourShips().Controls.Add(btn); } }
public void setEventsForm2(PartidaForm form) { if (server != null) { server.Events.ClientDisconnected += form.Events_ClientDisconnected; server.Events.DataReceived += form.Events_ClientDataReceived; } else { client.Events.Disconnected += form.Events_Disconnected; client.Events.DataReceived += form.Events_ServerDataReceived; } }