private static bool _userClose = true; // Defines if the program was user closed or closed internally. /// <summary> /// Initiates the GUI components according to the current components state. /// </summary> /// <param name="chatRoomStatusMessage">A message sent from the initiation of the chat romm logical layer</param> public static void Initiate(string chatRoomStatusMessage) { ChatRoomWindow chatRoom = new ChatRoomWindow(chatRoomStatusMessage); if (chatRoom.IsVisible) { chatRoom.Close(); } if (chatRoomStatusMessage == System.String.Empty) { _currntRegisteredUsersAmount = "No registered users currently."; } else { _currntRegisteredUsersAmount = ChatRoom._registeredUsers.Count + " registered users currently.\r\n\r\n"; } User dummy = ChatRoom._loggedInUser; if (dummy == null || dummy.logged == false) { LoginWindow login = new LoginWindow(chatRoomStatusMessage); login.Show(); } else { chatRoom = new ChatRoomWindow(chatRoomStatusMessage); chatRoom.ChatMessages_Block.ScrollToEnd(); chatRoom.Show(); } }
public Options(ChatRoomWindow cr, List <string> groups, ObservableObject obs) { chatRoom = cr; this.obs = obs; DataContext = obs; InitializeComponent(); isChanged = false; isLegalData = true; users = new List <string>(); this.groups = groups; ok = false; //initialize with ascending sort, none filter and sort by timestamp obs.AscendingIsChecked = true; obs.F_NoneIsChecked = true; obs.S_TimeIsChecked = true; //initiate final option choice filterChoice = "none"; sortChoice = "time"; orderChoice = "ascending"; //initiate option change tFilterChoice = filterChoice; tSortChoice = sortChoice; tOrderChoice = orderChoice; prevFilter = filterChoice; prevSort = sortChoice; prevOrder = orderChoice; }
/// <summary> /// Opens a new chat room window and shows it. /// </summary> /// <param name="statusMessage">A message indicating login\register status to the chat room window.</param> private void OpenChatWindow(string statusMessage) { try { GUI._soundStatus = true; _openChatRoomWindow = new ChatRoomWindow(statusMessage); _openChatRoomWindow.Show(); } catch (Exception e) { ChatRoom._logger.log(5, "Faild to load chat room main window."); } }
private String _groupID; // Current group ID entered in the groupID text box //Constructor public LoginWindow(String chatRoomStatusMessage) { InitializeComponent(); loginRegisterDetails.DataContext = this; _openChatRoomWindow = null; if (chatRoomStatusMessage == System.String.Empty) { UserCountText.Text = "No users are registered currently"; } else { UserCountText.Inlines.Add(new Run(ChatRoom._registeredUsers.Count + "") { Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF00B75B")) }); UserCountText.Inlines.Add(new Run(" registered users currently.")); } ChatRoom._logger.log(1, "Login window graphical user interface loaded successfully."); }
/// <summary> /// check validity of the login, if not- let the user option to regiester /// </summary> private void BtnLogin_Click(object sender, RoutedEventArgs e) { int number; // A validity check of the NickName if (obs.NicknameContent[0] == ' ' || (obs.NicknameContent.Length > 8)) // if the user presses space { Log.Instance.warn("Invalid input - Invalid nickname"); //log string message = "Nickname cannot start with spaces or be longer than 8 digits!"; string caption = "Invalid name"; if ((MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Error) == MessageBoxResult.OK)) { this.obs.GroupIdContent = ""; this.obs.NicknameContent = ""; } } // A validity check of the group id else if (int.TryParse(obs.GroupIdContent, out number) == false || (obs.GroupIdContent.Length > 2)) { Log.Instance.warn("Invalid input - Invalid group number");//log string message = "You sould only enter numbers between 1 to 99!"; string caption = "Invalid group ID"; if ((MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Error) == MessageBoxResult.OK)) { this.obs.GroupIdContent = ""; this.obs.NicknameContent = ""; } } // A validity check of the password else if (!correctPass) { if (MessageBox.Show("Password mast contain 4 to 16 letters", "Invalid message", MessageBoxButton.OK, MessageBoxImage.Error) == MessageBoxResult.OK) { this.obs.GroupIdContent = ""; this.obs.NicknameContent = ""; } Log.Instance.warn("Invalid input - Invalid Password");//log } // A validity check of the password and the BL // checks if the user is already registered or not else if (correctPass & this.chatRoom.login(obs.NicknameContent, obs.GroupIdContent, this.HashedPassword) == false) { Log.Instance.error("Log-in fail - User not registered");//log string message = "please register first and then try to login again"; string caption = "You are not registered"; if ((MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Error) == MessageBoxResult.OK)) { this.obs.GroupIdContent = ""; this.obs.NicknameContent = ""; } this.obs.GroupIdContent = ""; this.obs.NicknameContent = ""; //if the user is not registered give him an option to register obs.LblAddRegVisibility = "Visible"; obs.LblAddRegContent = "Try to register :"; obs.BtnRegisterVisibility = "Visible"; } // if the inputs are correct else { Log.Instance.info("New log-in - User: "******""; this.obs.NicknameContent = ""; HashedPassword = ""; obs.LblAddRegVisibility = "Visible"; this.Close(); ChatRoomWindow chatRoomWin = new ChatRoomWindow(this.mainWindow, this.chatRoom, obs); chatRoomWin.Show(); } }