Пример #1
0
        private async void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (await GameState.Login(TxtUsername.Text, PswdPassword.Password))
            {
                TxtUsername.Clear();
                PswdPassword.Clear();
                TxtUsername.Focus();

                GameState.Navigate(new GameOptionsPage());
            }
        }
Пример #2
0
 private void BtnReset_Click(object sender, RoutedEventArgs e)
 {
     DisableMinusButtons();
     TogglePlusButtons(true);
     _createUser = new User(_defaultUser);
     DataContext = _createUser;
     TxtUsername.Clear();
     PswdPassword.Clear();
     PswdConfirm.Clear();
     TxtUsername.Focus();
 }
Пример #3
0
        /// <summary>Clears all the fields on the form.</summary>
        private void Clear()
        {
            _blnNewUser = false;
            LstUsers.UnselectAll();

            // character
            TxtName.Clear();
            TxtLevel.Clear();
            TxtExperience.Clear();
            TxtSkillPoints.Clear();
            ChkAlive.IsChecked       = false;
            CmbLocation.SelectedItem = "Streets";
            TxtCurrentEndurance.Clear();
            TxtMaximumEndurance.Clear();
            TxtHunger.Clear();
            TxtThirst.Clear();

            // inventory
            CmbCurrentWeapon.SelectedIndex = 0;
            CmbLightWeapon.SelectedIndex   = 0;
            CmbHeavyWeapon.SelectedIndex   = 0;
            CmbTwoHWeapon.SelectedIndex    = 0;
            CmbArmor.SelectedIndex         = 0;
            CmbPotion.SelectedIndex        = 0;
            TxtLockpicks.Clear();
            TxtGoldOnHand.Clear();
            TxtGoldInBank.Clear();
            TxtGoldOnLoan.Clear();
            ChkShovel.IsChecked  = false;
            ChkLantern.IsChecked = false;
            ChkAmulet.IsChecked  = false;

            // stats
            TxtLightWeaponSkill.Clear();
            TxtHeavyWeaponSkill.Clear();
            TxtTwoHWeaponSkill.Clear();
            TxtBlockingSkill.Clear();
            TxtSlippingSkill.Clear();
            TxtStealthSkill.Clear();

            // henchmen
            TxtHenchmenLevel1.Clear();
            TxtHenchmenLevel2.Clear();
            TxtHenchmenLevel3.Clear();
            TxtHenchmenLevel4.Clear();
            TxtHenchmenLevel5.Clear();

            // password change fields
            PswdPassword.Clear();
            PswdConfirm.Clear();

            ToggleControls(false);
        }
Пример #4
0
 /// <summary>Clears all text from the labels and resets the Page to default.</summary>
 private void Clear()
 {
     _selectedClass = new HeroClass();
     _compareClass  = new HeroClass();
     LstClasses.UnselectAll();
     TxtHeroName.Clear();
     TxtHeroName.GrabFocus();
     PswdPassword.Clear();
     PswdConfirm.Clear();
     ChkHardcore.Pressed = false;
     LblError.Text       = "";
     CheckSkillPoints();
     DisableMinus();
     TogglePlus(false);
 }
Пример #5
0
        private async void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (await AppState.AttemptLogin(TxtUsername.Text, PswdPassword.Password))
            {
                AppState.CurrentUser = await AppState.LoadUser(TxtUsername.Text);

                AppState.SetUserDatabaseInformation();
                AppState.Navigate(new TrackerPage());
                TxtUsername.Clear();
                PswdPassword.Clear();
                TxtUsername.Focus();
            }
            else
            {
                AppState.DisplayNotification("Invalid credentials. Please try again.", "Personal Tracker");
            }
        }
Пример #6
0
        private void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            User checkUser = AppState.AllUsers.Find(user => user.Username == TxtUserID.Text.Trim());

            if (checkUser != null && checkUser != new User() && PBKDF2.ValidatePassword(PswdPassword.Password.Trim(), checkUser.Password))
            {
                AppState.CurrentUser = checkUser;
                TxtUserID.Clear();
                PswdPassword.Clear();
                TxtUserID.Focus();
                AppState.Navigate(new TimeClockPage());
                AppState.MainWindow.MnuAdmin.IsEnabled = false;
            }
            else
            {
                AppState.DisplayNotification("Invalid login.", "Time Clock");
            }
        }
Пример #7
0
 /// <summary>Saves a new <see cref="User"/> to the database.</summary>
 private async void SaveNewUser()
 {
     if (PswdPassword.Password.Trim().Length > 0 && PswdConfirm.Password.Trim().Length > 0)
     {
         if (PswdPassword.Password.Trim() == PswdConfirm.Password.Trim())
         {
             if (!GameState.AllUsers.Exists(user => user.Name == TxtName.Text.Trim()))
             {
                 if (!string.Equals(_selectedUser.Name, "Computer", StringComparison.OrdinalIgnoreCase) && !string.Equals(_selectedUser.Name, "Rathskeller", StringComparison.OrdinalIgnoreCase) && !string.Equals(_selectedUser.Name, "The Master", StringComparison.OrdinalIgnoreCase))
                 {
                     AssignSelectedUser(true);
                     if (await GameState.NewUser(_selectedUser))
                     {
                         GameState.DisplayNotification("New user successfully created.", "Assassin");
                         Clear();
                         RefreshItemsSource();
                     }
                 }
                 else
                 {
                     GameState.DisplayNotification("That username is reserved and cannot be chosen.", "Assassin");
                 }
             }
             else
             {
                 GameState.DisplayNotification("The username you have chosen is already in use.", "Assassin");
                 TxtName.Clear();
                 TxtName.Focus();
             }
         }
         else
         {
             GameState.DisplayNotification("Your passwords don't match.", "Assassin");
             PswdPassword.Clear();
             PswdConfirm.Clear();
             PswdPassword.Focus();
         }
     }
     else
     {
         GameState.DisplayNotification("Please enter a password and confirm it.", "Assassin");
     }
 }
Пример #8
0
 private async void BtnCreate_Click(object sender, RoutedEventArgs e)
 {
     if (TxtUsername.Text.Length > 0)
     {
         if (PswdPassword.Password.Length >= 4 && PswdConfirmPassword.Password.Length >= 4)
         {
             if (PswdPassword.Password == PswdConfirmPassword.Password)
             {
                 User newUser = new User(TxtUsername.Text, PBKDF2.HashPassword(PswdPassword.Password));
                 if (!await AppState.CreateUser(newUser))
                 {
                     TxtUsername.Focus();
                 }
                 else
                 {
                     AppState.GoBack();
                 }
             }
             else
             {
                 AppState.DisplayNotification("Please ensure that your passwords match.", "Personal Tracker");
                 PswdPassword.Focus();
             }
         }
         else
         {
             AppState.DisplayNotification("Please ensure that your passwords are at least 4 characters in length.", "Personal Tracker");
             PswdPassword.Focus();
         }
     }
     else
     {
         AppState.DisplayNotification("Please ensure that your username is filled out.", "Personal Tracker");
         TxtUsername.Focus();
     }
 }
Пример #9
0
        /// <summary>Modifies an existing <see cref="User"/> and saves it to the database.</summary>
        private async void ModifyExistingUser()
        {
            // if changing password
            bool blnChangePass = false;

            if (PswdPassword.Password.Trim().Length > 0 && PswdConfirm.Password.Trim().Length > 0 && PswdPassword.Password.Trim() == PswdConfirm.Password.Trim())
            {
                blnChangePass = true;
            }
            else if (PswdPassword.Password.Trim() != PswdConfirm.Password.Trim())
            {
                GameState.DisplayNotification("Your passwords don't match.", "Assassin");
                PswdPassword.Clear();
                PswdConfirm.Clear();
                PswdPassword.Focus();
                return;
            }

            // if changing user name
            bool blnChangeName = false;

            if (TxtName.Text.Trim() != GameState.CurrentUser.Name)
            {
                if (!GameState.AllUsers.Exists(user => user.Name == TxtName.Text.Trim()) &&
                    !GameState.ReservedNames.Any(name => name.Equals(TxtName.Text.Trim(), StringComparison.OrdinalIgnoreCase)))
                {
                    blnChangeName = true;
                }
                else
                {
                    if (GameState.ReservedNames.Any(name => name.Equals(TxtName.Text.Trim(), StringComparison.OrdinalIgnoreCase)))
                    {
                        GameState.DisplayNotification("That username is reserved and cannot be chosen.", "Assassin");
                    }
                    else
                    {
                        GameState.DisplayNotification("The new username you have chosen is already in use.", "Assassin");
                    }
                    TxtName.Clear();
                    TxtName.Focus();
                    return;
                }
            }

            AssignSelectedUser(blnChangePass);

            if (blnChangeName && await GameState.DatabaseInteraction.SaveUser(_selectedUser, TxtName.Text.Trim()))
            {
                foreach (Guild guild in GameState.AllGuilds)
                {
                    if (guild.HasMember(GameState.CurrentUser))
                    {
                        await GameState.MemberLeavesGuild(GameState.CurrentUser, guild);

                        await GameState.MemberJoinsGuild(_selectedUser, guild);
                    }
                    if (await GameState.DatabaseInteraction.HasAppliedToGuild(GameState.CurrentUser, guild))
                    {
                        await GameState.DatabaseInteraction.DenyGuildApplication(GameState.CurrentUser, guild);

                        await GameState.DatabaseInteraction.ApplyToGuild(_selectedUser, guild);
                    }

                    if (guild.Master == GameState.CurrentUser.Name)
                    {
                        guild.Master = _selectedUser.Name;
                    }
                }
            }
            else if (!blnChangeName)
            {
                await GameState.DatabaseInteraction.SaveUser(_selectedUser);
            }

            GameState.AllUsers.Replace(GameState.CurrentUser, _selectedUser);

            if (GameState.CurrentUser.CurrentLocation == SleepLocation.Jail && _selectedUser.CurrentLocation != SleepLocation.Jail)
            {
                CheckJail();
            }

            Clear();
            RefreshItemsSource();
        }
Пример #10
0
 private void _on_Password_focus_exited() => PswdPassword.Deselect();
Пример #11
0
 private void _on_Password_focus_entered() => PswdPassword.SelectAll();
Пример #12
0
 private void PswdPassword_GotFocus(object sender, RoutedEventArgs e) => PswdPassword.SelectAll();