Beispiel #1
0
        public void ShowLogOn()
        {
            var logon = new LogOn();

            logon.Attempts = _attempts;
            bool?res = logon.ShowDialog();

            if (!res ?? true)
            {
                Shutdown(1);
            }
            else
            {
                NaoCoopObjects.Classes.User user = Helpers.DataAccessHelper.Instance.UsersManager.ValidateUsernameAndPassword(logon.UserName, logon.Password);
                if (user != null)
                {
                    StartUp(user);
                }
                else
                {
                    if (logon.Attempts > 2)
                    {
                        MessageBox.Show("Application is exiting due to invalid credentials", "Application Exit", MessageBoxButton.OK, MessageBoxImage.Error);
                        Shutdown(1);
                    }
                    else
                    {
                        _attempts += 1;
                        ShowLogOn();
                    }
                }
            }
        }
Beispiel #2
0
        public void StartUp(NaoCoopObjects.Classes.User user)
        {
            Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
            CurrentUser          = user;
            _appWindow           = new ApplicationWindow();
            ApplicationViewModel context = new ApplicationViewModel();

            _appWindow.DataContext = context;
            _appWindow.InitializeMenu();
            _appWindow.Show();
        }
Beispiel #3
0
        public void LogOut()
        {
            //Disable shutdown when the dialog closes
            Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;

            CurrentUser = null;
            if (_appWindow != null)
            {
                _appWindow.Close();
            }

            ShowLogOn();
        }