Beispiel #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string[] usernames = System.IO.File.ReadAllLines(@".../.../Text Files/usernames.txt");
            string[] Passwords = System.IO.File.ReadAllLines(@".../.../Text Files/Passwords.txt");
            playerDetails.quizLevel      = cboQuizLevel.Text;
            playerDetails.playerName     = txtUsername.Text;
            playerDetails.playerPassword = txtPassword.Text;
            playerDetails.quizdate       = DateTime.Now;
            bool loggedOn = false;


            if (cboQuizLevel.Text != "Beginner" || cboQuizLevel.Text != "Intermediate" || cboQuizLevel.Text != "Advanced")
            {
                loggedOn = false;
            }

            for (int i = 0; i < usernames.Length; i++)
            {
                if (txtUsername.Text == usernames[i])
                {
                    if (txtPassword.Text == Passwords[i])
                    {
                        loggedOn = true;
                    }
                    else
                    {
                        loggedOn = false;
                    }
                }
                else
                {
                    loggedOn = false;
                }
            }


            if (loggedOn == true)
            {
                this.Hide();
                if (playerDetails.quizLevel == "Beginner")
                {
                    frmBeginner1 mynextscreen = new frmBeginner1();
                    mynextscreen.ShowDialog();
                }
                else if (playerDetails.quizLevel == "Intermediate")
                {
                    frmIntermediate1 mynextscreen = new frmIntermediate1();
                    mynextscreen.ShowDialog();
                }
                else if (playerDetails.quizLevel == "Advanced")
                {
                    frmAdvanced1 mynextscreen = new frmAdvanced1();
                    mynextscreen.ShowDialog();
                }
            }
            else if (loggedOn == false)
            {
                errorMessage();
            }
        }
Beispiel #2
0
 private void RestartLevel_Click(object sender, EventArgs e)
 {
     //sets the score back to 0
     GlobalQuizValues.playerScoreDuringQuiz = 0;
     //if the beginner level is selected it opens that level
     if (cboRestartLevels.Text == "Beginner")
     {
         frmBeginner1 beginner = new frmBeginner1();
         this.Hide();
         beginner.ShowDialog();
         GlobalQuizValues.playerScoreDuringQuiz = 0;
     }
     //if the Intermediate level is selected it opens that level
     else if (cboRestartLevels.Text == "Intermediate")
     {
         frmIntermediate1 intermediate = new frmIntermediate1();
         this.Hide();
         intermediate.ShowDialog();
         GlobalQuizValues.playerScoreDuringQuiz = 0;
     }
     //if the Advanced level is selected it opens that level
     else if (cboRestartLevels.Text == "Advanced")
     {
         frmAdvanced1 advanced = new frmAdvanced1();
         this.Hide();
         advanced.ShowDialog();
         GlobalQuizValues.playerScoreDuringQuiz = 0;
     }
     //If No Level is selected it just displays a Message box
     else if (cboRestartLevels.Text == "")
     {
         MessageBox.Show("Please select a Level");
     }
 }
        private void mnuRestart_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            DialogResult Restart = MessageBox.Show("Are you sure you want to restart?");

            if (Restart == DialogResult.OK)
            {
                frmIntermediate1 RestartScreen = new frmIntermediate1();
                this.Hide();
                RestartScreen.ShowDialog();
            }
        }
Beispiel #4
0
        private void btnNextScreenRules_Click(object sender, EventArgs e)
        {
            //these lines of code set the Player Details Class
            playerDetails.playerName     = txtPlayerName.Text;
            playerDetails.quizLevel      = cboQuizLevel.Text;
            playerDetails.quizdate       = DateTime.Now;
            playerDetails.playerPassword = txtPlayerPassword.Text;

            writetofile();

            //TextWriter usernametw = new StreamWriter(@"C:\usernames.txt",true);
            //usernametw.WriteLine(txtPlayerName);


            playerDetails.playericon = arrPlayerIcons;

            if (txtPlayerPassword.Text.Contains(" "))
            {
                MessageBox.Show("No Spaces are allowed in the Password! Try Again");
            }
            else
            {
                if (playerDetails.quizLevel == "Beginner")
                {
                    this.Hide();
                    frmBeginner1 mynextscreen = new frmBeginner1();
                    mynextscreen.ShowDialog();
                }
                else if (playerDetails.quizLevel == "Intermediate")
                {
                    this.Hide();
                    frmIntermediate1 mynextscreen = new frmIntermediate1();
                    mynextscreen.ShowDialog();
                }
                else if (playerDetails.quizLevel == "Advanced")
                {
                    this.Hide();
                    frmAdvanced1 mynextscreen = new frmAdvanced1();
                    mynextscreen.ShowDialog();
                }
                playerDetails.playerPassword = txtPlayerPassword.Text;
            }
        }
        private void btnNextScreenRules_Click(object sender, EventArgs e)
        {
            //these lines of code set the Player Details Class
            playerDetails.playerName     = txtPlayerName.Text;
            playerDetails.quizLevel      = cboQuizLevel.Text;
            playerDetails.quizdate       = DateTime.Now;
            playerDetails.playerPassword = txtPlayerPassword.Text;

            writetofile();
            string[] currentUsers = File.ReadAllLines("./text Files/usernames.txt");
            string   username     = txtPlayerName.Text;

            playerDetails.playericon = arrPlayerIcons;

            //Shows a message box if there is a space in the password
            if (txtPlayerPassword.Text.Contains(" "))
            {
                MessageBox.Show("No Spaces are allowed in the Password! Try Again");
            }
            else if (txtPlayerPassword.TextLength < 8)
            {
                MessageBox.Show("There must be atleast 8 characters in the password");
            }
            else if (currentUsers.Contains(username))
            {
                MessageBox.Show("This Username is already Taken");
            }

            else
            {
                //Checks Which Lever is selected
                if (playerDetails.quizLevel == "Beginner")
                {
                    //Hides the form
                    this.Hide();
                    //Opens the Form mentioned
                    frmBeginner1 mynextscreen = new frmBeginner1();
                    mynextscreen.ShowDialog();
                }
                //Checks Which Lever is selected
                else if (playerDetails.quizLevel == "Intermediate")
                {
                    //Hides the form
                    this.Hide();
                    //Opens the Form mentioned
                    frmIntermediate1 mynextscreen = new frmIntermediate1();
                    mynextscreen.ShowDialog();
                }
                //Checks Which Lever is selected
                else if (playerDetails.quizLevel == "Advanced")
                {
                    //Hides the form
                    this.Hide();
                    //Opens the Form mentioned
                    frmAdvanced1 mynextscreen = new frmAdvanced1();
                    mynextscreen.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Please Select A Level");
                }
                //sets the playerDetails class with the text in the textbox
                playerDetails.playerPassword = txtPlayerPassword.Text;
            }
        }
Beispiel #6
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            //Creates A String Array to hold all the Usernames in the text file
            string[] usernames = System.IO.File.ReadAllLines(@"./Text Files/usernames.txt");
            //Creates A String Array to hold all the Passwords in the text file
            string[] Passwords = System.IO.File.ReadAllLines(@"./Text Files/Passwords.txt");
            //Creates a boolean value to call code when the value = true
            bool loggedOn = false;

            //if the combobox doesnt contain a level it will return a false reading on the boolean
            if (cboQuizLevel.Text != "Beginner" || cboQuizLevel.Text != "Intermediate" || cboQuizLevel.Text != "Advanced")
            {
                loggedOn = false;
            }

            //Creates a for loop to check usernames and passwords
            for (int i = 0; i < usernames.Length; i++)
            {
                //Checks if the username is in the string array
                if (txtUsername.Text == usernames[i])
                {
                    //Checks if the Password is in the string array
                    if (txtPassword.Text == Passwords[i])
                    {
                        loggedOn = true;
                    }
                    //if its not in the array it sets the boolean value to false
                    else
                    {
                        loggedOn = false;
                    }
                }
                //if its not in the array it sets the boolean value to false
                else
                {
                    loggedOn = false;
                }
            }

            //Only Starts if the boolean value has been set to true
            if (loggedOn == true)
            {
                //Sets all the inputted values to the playerDetails Class
                playerDetails.quizLevel      = cboQuizLevel.Text;
                playerDetails.playerName     = txtUsername.Text;
                playerDetails.playerPassword = txtPassword.Text;
                playerDetails.quizdate       = DateTime.Now;
                this.Hide();
                if (playerDetails.quizLevel == "Beginner")
                {
                    //If the Beginner level is selected it opens the first Beginner Question
                    frmBeginner1 mynextscreen = new frmBeginner1();
                    mynextscreen.ShowDialog();
                }
                else if (playerDetails.quizLevel == "Intermediate")
                {
                    //If the Intermediate level is selected it opens the first Intermediate Question
                    frmIntermediate1 mynextscreen = new frmIntermediate1();
                    mynextscreen.ShowDialog();
                }
                else if (playerDetails.quizLevel == "Advanced")
                {
                    //If the advanced level is selected it opens the first Advanced Question
                    frmAdvanced1 mynextscreen = new frmAdvanced1();
                    mynextscreen.ShowDialog();
                }
            }
            else if (loggedOn == false)
            {
                //Calls the errormessage Method
                errorMessage();
            }
        }