private void Button1_Click(object sender, EventArgs e) { this.Hide(); ClientForm clientForm = new ClientForm(nameTextBox.Text, Int32.Parse(portTextBox.Text)); clientForm.Show(); }
private void InitMain() { Controls.Clear(); ClientSize = new Size(400, 200); Text = "Dice Game. Main"; Button StartClient = new Button() { Parent = this, Location = new Point((ClientRectangle.Width / 2) - 150, (ClientRectangle.Height / 2) - 50), Size = new Size(300, 40), Text = "Запустить клиент" }; Button StartServer = new Button() { Parent = this, Location = new Point((ClientRectangle.Width / 2) - 150, (ClientRectangle.Height / 2) + 10), Size = new Size(300, 40), Text = "Запустить сервер" }; StartClient.Click += (object sender, EventArgs e) => { if (!(Client is null)) { Client.Close(); } Client = new ClientForm(GroupAdress, ClientReceive, ServerReceive) { Size = new Size(800, 600), Text = "Client" }; Client.Show(); Client.FormClosing += (object esender, FormClosingEventArgs ee) => { StartClient.Enabled = true; }; StartClient.Enabled = false; }; StartServer.Click += (object sender, EventArgs e) => { if (!(Server is null)) { Server.Close(); } Server = new ServerForm(GroupAdress, ServerReceive, ClientReceive) { Size = new Size(400, 600), Text = "Sever" }; Server.SetConsole(); Server.FormClosing += (object esender, FormClosingEventArgs ee) => { StartServer.Enabled = true; }; StartServer.Enabled = false; }; }