Ejemplo n.º 1
0
        /// <summary>
        /// Switch from Login Page to Main Page after checking for valid login credentials
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoginToMainButton_Click(object sender, RoutedEventArgs e)
        {
            bool inputFieldsEmpty = false;


            //check both login input fields non-empty
            if (string.IsNullOrEmpty(UsernameInput.Text) || string.IsNullOrEmpty(LoginPasswordBox.Password))
            {
                inputFieldsEmpty = true;
            }

            if (!inputFieldsEmpty)
            {
                //username, password case sensitive
                String loginUsername = UsernameInput.Text.ToLower();
                String loginPassword = LoginPasswordBox.Password;



                //check if login info matches with any entry in existing user list
                foreach (Profile user in MainWindow.UserList)
                {
                    Dictionary <String, String> userLogins = user.getUsernamePassword();
                    String actualUsername = userLogins.Keys.ElementAt(0);
                    String actualPassword = "";

                    //check if username and password is valid login pair
                    if (actualUsername.ToLower().Equals(loginUsername) &&
                        userLogins.TryGetValue(actualUsername, out actualPassword) &&
                        String.Equals(actualPassword, loginPassword))
                    {
                        userListIndex = MainWindow.UserList.IndexOf(user);
                        ValidLogin    = true;
                        break;
                    }
                }
            }


            //switch to main page if login is valid
            if (ValidLogin)
            {
                PageSwitcher.Switch(new MainPage(userListIndex));
            }
            //show empty input prompt if missing username or password
            else if (inputFieldsEmpty)
            {
                InvalidLoginPrompt("Please enter input for all fields!");
            }
            //otherwise show incorrect login text on a timer
            else
            {
                InvalidLoginPrompt("Incorrect Username/Password combination!");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Role, Hero, and Game Mode must be selected for new Profile before adding to MainWindow UserList
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SignupProfileSettingsDone_button_Click(object sender, RoutedEventArgs e)
        {
            //check if any of the dropdown menus have a null entry
            if ((SignupRoleComboBox.SelectedIndex == -1) ||
                (SignupHeroComboBox.SelectedIndex == -1) ||
                (SignupGameModeComboBox.SelectedIndex == -1))
            {
            }
            else
            {
                //set role, hero, game mode for new profile
                newProfile.Role     = (String)SignupRoleComboBox.SelectedItem;
                newProfile.Hero     = (String)SignupHeroComboBox.SelectedItem;
                newProfile.GameMode = (String)SignupGameModeComboBox.SelectedItem;

                //add new Profile to list of users
                MainWindow.UserList.Add(newProfile);
                PageSwitcher.Switch(new LoginPage());
                Close();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Switch from Login Page to Sign-up Page on click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void LoginToSignupButton_Click(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new SignupPage());
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Logs out user and switches back to login page
 /// Changed profile settings should still be preserved if log back in
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void LogoutButton_Click(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new LoginPage());
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Initialize WPF MainWindow components on start
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            //List<Profile> defaultTeam = new List<Profile>();



            //Default User Profile List
            Profile defaultProfile = new Profile("*****@*****.**", "ItsRainingJustice", "cawcaw", "dronestrikes#2016");

            String[] defaultProfileInfo = new String[] { "Offense", "Pharah", "Ranked", "FIRE ZE MISSILES!", "/Images/JUSTICE.png" };
            setDefaultProfileInfo(defaultProfile, defaultProfileInfo);
            UserList.Add(defaultProfile);

            defaultProfile.makeNewTeam("DefaultTeam", "Quickplay");

            Team defaultTeam = defaultProfile.getTeam();

            //Team defaultTeam = new Team("Default Team", defaultProfile, "Quickplay");


            defaultProfile     = new Profile("*****@*****.**", "FireinDaHome", "cheekynandos", "burningman#1969");
            defaultProfileInfo = new String[] { "Defense", "Junkrat", "Quickplay", "u wot m8?", "/Images/ARSON.png" };
            setDefaultProfileInfo(defaultProfile, defaultProfileInfo);
            UserList.Add(defaultProfile);

            defaultTeam.getMembersList().Add(defaultProfile);

            //defaultTeam.getMembersList().Add(defaultProfile);

            defaultProfile     = new Profile("*****@*****.**", "xX_GurlGamer_Xx", "geegee", "winkyfayce#2014");
            defaultProfileInfo = new String[] { "Defense", "D.Va", "Quickplay", "Nerf this!", "/Images/MLG_KPOP_GREMLIN.png" };
            setDefaultProfileInfo(defaultProfile, defaultProfileInfo);

            UserList.Add(defaultProfile);

            defaultProfile.makeNewTeam("TotallyNotSmurfs", "Ranked");

            Team defaultTeam2 = defaultProfile.getTeam();


            //Team defaultTeam2 = new Team("TotallyNotSmurfs", defaultProfile, "Ranked");


            defaultProfile     = new Profile("*****@*****.**", "GenjiGod", "naruto", "dattebayo#2003");
            defaultProfileInfo = new String[] { "Offense", "Genji", "Ranked", "I Need Healing!", "/Images/PRO_GENJI.png" };
            setDefaultProfileInfo(defaultProfile, defaultProfileInfo);
            UserList.Add(defaultProfile);
            //defaultTeam.Add(defaultProfile);
            defaultTeam2.getMembersList().Add(defaultProfile);



            //default teams in app's "database"
            List <Profile> defaultMembers = defaultTeam.getMembersList();

            foreach (Profile member in defaultMembers)
            {
                member.setDefaultTeam(defaultTeam);
                member.hasTeam = true;
            }
            MainWindow.TeamsList.Add(defaultTeam);


            defaultMembers = defaultTeam2.getMembersList();
            foreach (Profile member in defaultMembers)
            {
                member.setDefaultTeam(defaultTeam2);
                member.hasTeam = true;
            }
            MainWindow.TeamsList.Add(defaultTeam2);



            //initialize MainWindow to Login page by default
            PageSwitcher.pageSwitchWindow = this;
            PageSwitcher.Switch(new LoginPage());
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Add new Profile in MainWindow UserList based on signup info
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SignupToMainButton_Click(object sender, RoutedEventArgs e)
        {
            bool inputFieldsEmpty;

            // lists for signup input fields
            var textBoxes     = new TextBox[] { EmailInput, SignupUsernameInput, BattetagInput };
            var passwordBoxes = new PasswordBox[] { SignupPasswordBox, SignupConfirmPasswordBox };

            //if any input fields on signup page empty, set boolean
            if (textBoxes.Any(tb => string.IsNullOrEmpty(tb.Text)) || passwordBoxes.Any(pb => string.IsNullOrEmpty(pb.Password)))
            {
                inputFieldsEmpty = true;
            }
            else
            {
                inputFieldsEmpty = false;
            }


            //check inputs before completing sign-up
            if (inputFieldsEmpty)
            {
                InvalidSignupPrompt("Please enter input for all fields!");
                ValidSignup = false;
            }
            else if (!String.Equals(SignupPasswordBox.Password, SignupConfirmPasswordBox.Password))
            {
                InvalidSignupPrompt("Password fields don't match!");
                ValidSignup = false;
            }
            else if (SignupUsernameInput.Text.Length > 20)
            {
                InvalidSignupPrompt("Maximum Username length is 20 characters");
                ValidSignup = false;
            }
            else
            {
                String newEmail     = EmailInput.Text;
                String newUsername  = SignupUsernameInput.Text;
                String newPassword  = SignupPasswordBox.Password; //password is case sensitive
                String newBattleTag = BattetagInput.Text;

                //set boolean for valid sign-up after checking for conflicts with existing users
                foreach (Profile user in MainWindow.UserList)
                {
                    String existingEmail     = user.Email;
                    String existingBattleTag = user.BattleTag;
                    Dictionary <String, String> existingLogins = user.getUsernamePassword();

                    //check if signup info conflicts with existing user's info
                    if (String.Equals(newEmail, existingEmail))
                    {
                        InvalidSignupPrompt("This Email is already registered!");
                        ValidSignup = false;
                        break;
                    }
                    else if (String.Equals(newBattleTag, existingBattleTag))
                    {
                        InvalidSignupPrompt("This BattleTag is already registered!");
                        ValidSignup = false;
                        break;
                    }
                    else if (existingLogins.ContainsKey(newUsername))
                    {
                        InvalidSignupPrompt("This Username is already registered!");
                        ValidSignup = false;
                        break;
                    }

                    else
                    {
                        InvalidSignupText.Visibility = Visibility.Hidden;
                        ValidSignup = true;
                    }
                }
            }

            if (ValidSignup)
            {
                String newEmail     = EmailInput.Text;
                String newUsername  = SignupUsernameInput.Text;   //username case sensitive
                String newPassword  = SignupPasswordBox.Password; //password is case sensitive
                String newBattleTag = BattetagInput.Text;

                //hide previous signup elements
                EmailText.Visibility    = UsernameText.Visibility = Visibility.Hidden;
                PasswordText.Visibility = ConfirmPasswordText.Visibility = BattetagText.Visibility = Visibility.Hidden;

                EmailInput.Visibility        = SignupUsernameInput.Visibility = Visibility.Hidden;
                SignupPasswordBox.Visibility = SignupConfirmPasswordBox.Visibility = BattetagInput.Visibility = Visibility.Hidden;

                //show next signup elements
                SignupRoleText.Visibility     = SignupHeroText.Visibility = SignupGameModeText.Visibility = Visibility.Visible;
                SignupRoleComboBox.Visibility = SignupHeroComboBox.Visibility = SignupGameModeComboBox.Visibility = Visibility.Visible;
                SignupBackButton.Visibility   = Visibility.Visible;
                SignupToMainButton.ToolTip    = "Finish Sign-up input and proceed to confirmation";
                SignupToMainButton.Content    = "FINISH";

                //check if any of the dropdown menus have a null entry
                if (!secondClick)
                {
                    secondClick = true;
                }
                else if ((SignupRoleComboBox.SelectedIndex == -1) && secondClick)
                {
                    InvalidSignupPrompt("Please make a selection for your preferred Role!");
                }
                else if ((SignupHeroComboBox.SelectedIndex == -1) && secondClick)
                {
                    InvalidSignupPrompt("Please make a selection for your preferred Hero!");
                }
                else if ((SignupGameModeComboBox.SelectedIndex == -1) && secondClick)
                {
                    InvalidSignupPrompt("Please make a selection for your preferred Game Mode!");
                }
                else
                {
                    //hide next signup elements
                    SignupRoleText.Visibility     = SignupHeroText.Visibility = SignupGameModeText.Visibility = Visibility.Hidden;
                    SignupRoleComboBox.Visibility = SignupHeroComboBox.Visibility = SignupGameModeComboBox.Visibility = Visibility.Hidden;
                    SignupBackButton.Visibility   = Visibility.Hidden;

                    //show user input for them to review before confirmation
                    ReviewEmailText.Visibility = ReviewUsernameText.Visibility = ReviewPasswordText.Visibility = ReviewBattletagText.Visibility = Visibility.Visible;
                    ReviewRoleText.Visibility  = ReviewHeroText.Visibility = ReviewGameModeText.Visibility = Visibility.Visible;

                    ReviewEmailText.Text     = "Email: " + newEmail;
                    ReviewUsernameText.Text  = "Username: "******"Password: "******"BattleTag: " + newBattleTag;
                    ReviewRoleText.Text      = "Role: " + (String)SignupRoleComboBox.SelectedItem;
                    ReviewHeroText.Text      = "Hero: " + (String)SignupHeroComboBox.SelectedItem;
                    ReviewGameModeText.Text  = "Game Mode: " + (String)SignupGameModeComboBox.SelectedItem;

                    SignupBackButton.Visibility = Visibility.Visible;
                    SignupToMainButton.ToolTip  = "Confirm Sign-up and return to Login";
                    SignupToMainButton.Content  = "CONFIRM";

                    if (SignupToMainButton.Content.Equals("CONFIRM") && thirdClick)
                    {
                        //instantiate new user profile
                        Profile newUser = new Profile(newEmail, newUsername, newPassword, newBattleTag);

                        //set role, hero, game mode for new profile
                        newUser.Role     = (String)SignupRoleComboBox.SelectedItem;
                        newUser.Hero     = (String)SignupHeroComboBox.SelectedItem;
                        newUser.GameMode = (String)SignupGameModeComboBox.SelectedItem;

                        //add new profile to list of users
                        MainWindow.UserList.Add(newUser);
                        PageSwitcher.Switch(new LoginPage());
                    }
                    else
                    {
                        thirdClick = true;
                    }
                }
            }
        }