private void mniEnter_Click(object sender, EventArgs e) { if (mniEnter.Text == "Login") { var dlg = new frmLogin(IPAddress.Parse("192.168.0.105"), 8001); dlg.ShowDialog(); _client = dlg.Client; if (_client.Connected) { _client.CommandReceived += client_CommandReceived; _client.SendCommand(new Command(CommandType.FreeCommand, IPAddress.Broadcast, _client.Ip + ":" + _client.NetworkName)); _client.SendCommand(new Command(CommandType.SendClientList, _client.ServerIp)); AddToList(_client.Ip.ToString(), _client.NetworkName); mniEnter.Text = "Log Off"; } } else { mniEnter.Text = "Login"; _privateWindowsList.Clear(); _client.Disconnect(); lstViwUsers.Items.Clear(); txtNewMessage.Clear(); txtNewMessage.Focus(); } }
private void mniEnter_Click(object sender, EventArgs e) { if (mniEnter.Text == "Вход") { if (!string.IsNullOrEmpty(_serverIp)) { Messages.Text = secondMessage; var dlg = new frmLogin(IPAddress.Parse(_serverIp), 8001); dlg.ShowDialog(); _client = dlg.Client; Messages.Text = thirdMessage; if (_client.Connected) { _client.CommandReceived += client_CommandReceived; _client.SendCommand(new Command(CommandType.FreeCommand, IPAddress.Broadcast, _client.Ip + ":" + _client.NetworkName)); _client.SendCommand(new Command(CommandType.SendClientList, _client.ServerIp)); AddToList(_client.Ip.ToString(), _client.NetworkName); mniEnter.Text = "Выход"; mniEnter.Enabled = splitContainer.Enabled = false; Messages.Text = fourthMessage; } } } else { mniEnter.Text = "Вход"; _privateWindowsList.Clear(); _client.Disconnect(); lstViwUsers.Items.Clear(); mniEnter.Enabled = splitContainer.Enabled = true; } }