public TCPIP(IPAddress IP, int porta, Insert_Ships form, bool isServer) { ip = IP; port = porta; if (isServer) { server = new SimpleTcpServer(ip.ToString() + ":" + port.ToString()); server.Events.ClientConnected += form.Events_ClientConnected; server.Start(); } else { client = new SimpleTcpClient(ip.ToString() + ":" + porta.ToString()); client.Events.Connected += form.Events_ServerConnected; } }
public void setPlayerField(Insert_Ships form, int number, int startVerticalPosition, int startHorizontalPosition) { btn = new Button(); btn.Height = heightField; btn.Width = widthFields; btn.Name = "btn_" + number.ToString(); btn.Location = new Point(startHorizontalPosition, startVerticalPosition); setImage(); btn.AllowDrop = true; btn.DragEnter += new DragEventHandler(form.dragEnter); btn.MouseDown += new MouseEventHandler(form.btn_MouseDown); btn.DragDrop += new DragEventHandler(form.dragDropMinefield); btn.DragOver += new DragEventHandler(form.dragOverMineField); btn.DragLeave += new EventHandler(form.dragLeaveMineField); form.getGroupBox_MyShips().Controls.Add(btn); }
public void setMineFields(Insert_Ships form) { mineFields = new MineField[rows, columns]; int startVerticalPosition = startPositionY; int startHorizontalPosition = startPositionX; int number = 1; for (int y = 0; y < rows; y++) { for (int x = 0; x < columns; x++) { mineFields[y, x] = new MineField(); mineFields[y, x].setPlayerField(form, number, startVerticalPosition, startHorizontalPosition); startHorizontalPosition += addWidth; number++; } startHorizontalPosition = startPositionX; startVerticalPosition += addHeight; } }