private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (IMService.GetUsernameFromDb() == null) { Application.Current.Shutdown(); } }
public void Login() { if (IMService.GetUsernameFromDb() == null) { var signInWindow = new SignInWindow(); signInWindow.RaiseSignInEvent += SignInButton_RaiseSignInEvent; signInWindow.Show(); } }
//Constructor public MainWindow() { var username = IMService.GetUsernameFromDb(); if (username != null && IMService.GetUser(username) != null) { LoggedInUser = IMService.GetUser(username); InitProgram(); var timer = new System.Threading.Timer(state => CheckForNewMessagesAndContacts(), null, DefaultMessageRefreshTime, Timeout.Infinite); } else { Hide(); Login(); } }