public ChatRoom(ChatServiceClient client, string roomName, User user)
        {
            DontTouchList = false;
            CurrentChats = new List<Chat>();
            InitializeComponent();
            MyClient = client;
            this.Text = roomName;
            MyUser = user;
            RoomName = roomName;
            string[] userlist = null;
            try
            {
                userlist = MyClient.GetUserList(roomName);
            }
            catch (Exception)
            {
                MessageBox.Show("The service is probably offline");
                this.Close();
                return;
            }


            if (roomName == "The Man Cave")
            {
                this.BackColor = Color.Blue;
            }
            else if (roomName == "The Kitchen")
            {
                this.BackColor = Color.HotPink;
            }
            else
            {
                this.BackColor = Color.Green;
            }


            foreach (var roomUser in userlist)
            {
                if (roomUser == MyUser.Username)
                {
                    DialogResult dialogResult = MessageBox.Show("User with the same username\nalready exists in this room.", "Username Already Exists", MessageBoxButtons.OK);
                    this.Close();
                    return;
                }
            }
            try
            {
                MyClient.AddUserNameToList(MyUser.Username, roomName);
            }
            catch (FaultException ex)
            {
                MessageBox.Show(ex.Message);
            }


            // Create a task and supply a user delegate by using a lambda expression. 
            Task RefreshTask = new Task(() => CollectNewChatInformation());
            // Start the task.
            RefreshTask.Start();
        }
        public ChatRoomSelectionForm(User user)
        {
            InitializeComponent();
            CurrentUser = user;
            UsernameLabel.Text = user.Username;
            GenderLabel.Text = user.Gender;

            if (user.Gender == "Male")
                KitchenConnect.Enabled = false;
            else
                ManCaveConnect.Enabled = false;
        }
        private void LoginButton_Click(object sender, EventArgs e)
        {
            string gender = "";
            if (MaleCheckBox.Checked)
                gender = "Male";
            else
                gender = "Female";

            var user = new User(gender, UsernameTextbox.Text);

            var newForm = new ChatRoomSelectionForm(user);
            this.Hide();
            newForm.Closed += (s, args) => this.Close();
            newForm.Show();
        }