/// <summary> /// Cleares all user detailes entered in the user details text boxes. /// </summary> /// <param name="clearGroupTextBox">Determines if the group ID text box should be cleared.</param> private void Clear_LoginRegister_TextBoxes(bool clearGroupTextBox) { UsernameInputTextBox.Clear(); UserPasswordInputTextBox.Clear(); if (clearGroupTextBox) { GroupInputTextBox.Clear(); } }
/// <summary> /// Tries to perform a user register by calling chat room register method with the entered user details. /// </summary> /// <param name="statusMessage">A passed message of the current registared users state.</param> /// <returns>True if registration was successful false otherwise.</returns> private bool Register(string statusMessage) { if (((groupID != String.Empty) && groupID != null) && GUI.IsNumeric(groupID)) { int g_id = int.Parse(groupID); if (g_id >= 1 && g_id <= 100) { bool output = false; string registerMessage = ChatRoom.Register(_currentUsername, _currentPassword, groupID); if (registerMessage == null) { statusMessage = "SUCCESSFULLY registered, please remember your username and password.\r\nHELLO new user " + ChatRoom._loggedInUser.username + "."; _currentUsername = null; _currentPassword = null; OpenChatWindow(statusMessage); _openChatRoomWindow.UpdateUserCounter(); GUI.WindowClose(this); output = true; } else { MessageBox.Show(registerMessage, "Chat-Room Registration error", MessageBoxButton.OK, MessageBoxImage.Asterisk, MessageBoxResult.OK); } return(output); } else { MessageBox.Show("A legal group ID must be a number between 1-100", "Error Registering", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); GroupInputTextBox.Clear(); return(false); } } else { MessageBox.Show("You have to fill the Group ID field with a legal numeric value in order to register.", "Error Registering", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); GroupInputTextBox.Clear(); return(false); } }
/// <summary> /// An event that is fired when the group id text box gets focus. /// Cleares the group id text box content. /// </summary> private void GroupInputTextBox_GotFocus(object sender, RoutedEventArgs e) { GroupInputTextBox.Clear(); GroupInputTextBox.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF000000")); }