private Server StringToServer(string str) { try { Server s = new Server(); string[] split = str.Split('('); s.Nickname = split[0].Trim(); s.IP = split[1].Substring(0, split[1].Length - 1); return s; } catch { return null; } }
private void txtServer_TextChanged(object sender, EventArgs e) { if (txtServer.Enabled && txtNickname.Enabled) { Server s = new Server(txtServer.Text, txtNickname.Text); string serverData = ServerToString(s); lstServers.SelectedItem = serverData; if (txtServer.Text != "" && txtNickname.Text != "") { btnSave.Enabled = true; btnRemove.Enabled = true; } else { // btnSave.Enabled = false; // btnRemove.Enabled = false; } } else { // btnSave.Enabled = false; // btnRemove.Enabled = false; } }
private string ServerToString(Server server) { return server.Nickname + " (" + server.IP + ")"; }