private void LoginActive(object sender, RoutedEventArgs e) { var th = new Thread(new ThreadStart(delegate { var login = new MLogin(); var session = login.TryAutoLogin(); if (session.Result == MLoginResult.Success) { Application.Current.Dispatcher.Invoke((Action) delegate { { MainWindowNew mw = new MainWindowNew(session); mw.Show(); this.Close(); } }); } else { Dispatcher.BeginInvoke(new Action(delegate { LoginCover.Visibility = Visibility.Hidden; LoginCover.IsEnabled = false; })); } })); th.Start(); }
private void SignIn(object sender, RoutedEventArgs e) { Progress.Value = 0; Progress.Opacity = 100; var th = new Thread(new ThreadStart(delegate { var login = new MLogin(); string email = ""; string password = ""; this.Dispatcher.Invoke(() => { email = Email.Text; password = userPassword.Password; }); var result = login.Authenticate(email, password); if (result.Result == MLoginResult.Success) { Session = result; Dispatcher.BeginInvoke(new Action(delegate { LoginStatus.Foreground = Brushes.LightGreen; LoginStatus.Text = "Successful login! Transfering you to the main window..."; this.Hide(); MainWindowNew mw = new MainWindowNew(Session); mw.Show(); })); } else { Dispatcher.BeginInvoke(new Action(delegate { LoginStatus.Foreground = Brushes.Red; LoginStatus.Text = "Please check your email/password"; Progress.Opacity = 0; })); } })); if (ifOffline.IsChecked != false) { Regex r = new Regex("^[a-zA-Z0-9_]+$"); if (r.IsMatch(Email.Text)) { MainWindowNew.ifOfflineMode = (bool)ifOffline.IsChecked; MainWindowNew mw = new MainWindowNew(MSession.GetOfflineSession(Email.Text)); mw.Show(); this.Close(); } else { LoginStatus.Text = "Invalid characters in your username"; Progress.Opacity = 0; } } else { th.Start(); } }
private void tryautologin() { var login = new MLogin(); var session = login.TryAutoLogin(); if (session.Result == MLoginResult.Success) { MainWindowNew mw = new MainWindowNew(session); this.Close(); mw.Show(); } else { LoginCover.Visibility = Visibility.Hidden; LoginCover.IsEnabled = false; } }