private void joinNetworkButton_Click(object sender, EventArgs e) { if (!this.isConnect) { if (settings.IsValid()) { transport = new Transport(this); transport.Connect(settings.IncomingPortName, settings.OutgoingPortName); transport.InitGettingListClients(); this.isConnect = true; ((Button)sender).Text = "Отключиться"; } else { MessageBox.Show("Настройки неверны"); } } else { connectionStatusNetwork.Text = "Не в сети"; messageFormButton.Enabled = false; this.isConnect = false; ((Button)sender).Text = "Подключиться"; transport.Disconnect(); } }