public ConnectDialog(WiFiService wifiService) { Text = "Get connect"; this.wifiService = wifiService; this.FormClosing += delegate(Object o, FormClosingEventArgs e) { dialogAlive = false; }; FormBorderStyle = FormBorderStyle.FixedDialog; ControlBox = false; MaximizeBox = false; MinimizeBox = false; ShowInTaskbar = false; BackgroundImage = global::Battleships.Properties.Resources.background_small; BackgroundImageLayout = ImageLayout.Center; ClientSize = new System.Drawing.Size(300, 120); label = new Label(); this.Controls.Add(label); label.Size = this.ClientSize; label.BackColor = Color.Transparent; label.ForeColor = Color.LightGray; label.Font = new Font("Arial", 12, FontStyle.Bold); btn = new ImageButton(ImageButton.SCALE.SCALE_MID, "Start"); btn.Location = new Point(ClientSize.Width / 2 - btn.Width / 2, ClientSize.Height - btn.Height - 5); this.Controls.Add(btn); partialIPAdress = WiFiService.getLocalIP(); if (Global.GameMode == GAME_MODE.HOST) { label.TextAlign = ContentAlignment.MiddleCenter; label.Text = "Your IP number is " + partialIPAdress + Environment.NewLine + "Waiting for client to connect..."; btn.Text = "Cancel"; label.Height = ClientSize.Height - btn.Height - 5; btn.Click += button_onCancel; Connecting(); } else { label.TextAlign = ContentAlignment.TopCenter; label.Text = "Type here IP of host device:"; label.TextAlign = ContentAlignment.MiddleCenter; input = new TextBox(); partialIPAdress = partialIPAdress.Substring(0, partialIPAdress.LastIndexOf('.') + 1); input.Text = partialIPAdress; input.Width = 200; input.Font = new Font("Arial", 10, FontStyle.Bold); input.ForeColor = Color.Black; input.Location = new Point(ClientSize.Width / 2 - input.Width / 2, ClientSize.Height - btn.Height - 10 - input.Height); this.Controls.Add(input); label.Height = ClientSize.Height - btn.Height - 10 - input.Height; btn.Click += button_onStart; } }