Exemple #1
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     label1.Text = duration.ToString();
     if (duration == 0)
     {
         timer1.Stop();
         Users_options uo = new Users_options(return_back);
         this.Hide();
         uo.Show();
     }
     duration--;
 }
        private void Bt_Player2_continue_Click(object sender, EventArgs e) /* login player 2 */
        {
            if (Program.Test_Insert_Text(TB_user_name2.Text) == false || Program.Test_Insert_Text(TB_password2.Text) == false)
            {
                MessageBox.Show("Only English Characters And Numbers Allowed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (TB_user_name2.Text == Program.user1)
            {
                MessageBox.Show(Program.user1 + " Is allready conected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (GameBox.Program.User_Check(TB_user_name2.Text) == false || GameBox.Program.Password_Check(TB_password2.Text) == false) /* check if name and password a valid */
            {
                MessageBox.Show("Invalid Input", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (COB_user2.Text == "Sign In")                                               /* if combo box is on login */
            {
                if (GameBox.Program.Check_NAME_exsist(TB_user_name2.Text, "Players") == 0) /* check if name exisist in database */
                {
                    MessageBox.Show("Invalid User Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (GameBox.Program.Check_Password_Is_correct(TB_user_name2.Text, TB_password2.Text, "Players") == false) /* check if password is correct */
                {
                    MessageBox.Show("Invalid Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else if (COB_user2.Text == "Sign Up")                                                        /* if conbo box is on sign up */
            {
                if (GameBox.Program.Insert_User_PLayers(TB_user_name2.Text, TB_password2.Text) == false) /* insurt user to players database */
                {
                    MessageBox.Show("User Name alreay exsist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                GameBox.Program.Insert_User__Scores(TB_user_name2.Text);  /*insurt user to score database */
                MessageBox.Show("User Created!", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            GameBox.Program.user2       = TB_user_name2.Text;          /* save users name */
            GameBox.Program.cnt_players = 2;                           /* count players update */
            GameBox.Program.InsertLogin(TB_user_name2.Text, "Player"); /* insert login time to login database*/
            Users_options uo = new Users_options(this);

            TB_password2.Text  = "";
            TB_user_name2.Text = "";
            this.Hide(); /* open nex screen */
            uo.Show();   /* hide this screen */
        }
Exemple #3
0
 public static void Update_music_bt() /* update Bt mussic on/off for all screens before opening */
 {
     foreach (Form f in Application.OpenForms)
     {
         if (f.GetType() == typeof(MainForm))
         {
             MainForm Newform = (GameBox.MainForm)f;
             if (music_OnOff == false)
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Mute;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
             else
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Music;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
         }
         else if (f.GetType() == typeof(GameChoice))
         {
             GameChoice Newform = (GameBox.GameChoice)f;
             if (music_OnOff == false)
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Mute;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
             else
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Music;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
         }
         else if (f.GetType() == typeof(Guest_wait))
         {
             Guest_wait Newform = (GameBox.Guest_wait)f;
             if (music_OnOff == false)
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Mute;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
             else
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Music;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
         }
         else if (f.GetType() == typeof(login_form))
         {
             login_form Newform = (GameBox.login_form)f;
             if (music_OnOff == false)
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Mute;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
             else
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Music;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
         }
         else if (f.GetType() == typeof(Managers_option))
         {
             Managers_option Newform = (GameBox.Managers_option)f;
             if (music_OnOff == false)
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Mute;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
             else
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Music;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
         }
         else if (f.GetType() == typeof(Manager_Managment))
         {
             Manager_Managment Newform = (GameBox.Manager_Managment)f;
             if (music_OnOff == false)
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Mute;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
             else
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Music;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
         }
         else if (f.GetType() == typeof(Reports))
         {
             Reports Newform = (GameBox.Reports)f;
             if (music_OnOff == false)
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Mute;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
             else
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Music;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
         }
         else if (f.GetType() == typeof(User_Managment))
         {
             User_Managment Newform = (GameBox.User_Managment)f;
             if (music_OnOff == false)
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Mute;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
             else
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Music;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
         }
         else if (f.GetType() == typeof(Users_options))
         {
             Users_options Newform = (GameBox.Users_options)f;
             if (music_OnOff == false)
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Mute;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
             else
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Music;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
         }
         else if (f.GetType() == typeof(Change_details))
         {
             Change_details Newform = (GameBox.Change_details)f;
             if (music_OnOff == false)
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Mute;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
             else
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Music;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
         }
         else if (f.GetType() == typeof(Feedback_form))
         {
             Feedback_form Newform = (GameBox.Feedback_form)f;
             if (music_OnOff == false)
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Mute;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
             else
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Music;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
         }
         else if (f.GetType() == typeof(Reversi))
         {
             Reversi Newform = (GameBox.Reversi)f;
             if (music_OnOff == false)
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Green_mute;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
             else
             {
                 Newform.CB_music.BackgroundImage       = Properties.Resources.Green_music;
                 Newform.CB_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
         }
         else if (f.GetType() == typeof(Snake_and_ladders))
         {
             Snake_and_ladders Newform = (GameBox.Snake_and_ladders)f;
             if (music_OnOff == false)
             {
                 Newform.bt_music.BackgroundImage       = Properties.Resources.Mute_red;
                 Newform.bt_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
             else
             {
                 Newform.bt_music.BackgroundImage       = Properties.Resources.Music_red;
                 Newform.bt_music.BackgroundImageLayout = ImageLayout.Stretch;
             }
         }
     }
 }
Exemple #4
0
 private void Bt_User_login_Click(object sender, EventArgs e) /* Player login */
 {
     if (Program.Test_Insert_Text(Tb_user_name.Text) == false)
     {
         MessageBox.Show("Only english characters and numbers allowed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (Program.Test_Insert_Text(Tb_user_password.Text) == false)
     {
         MessageBox.Show("Only english characters and numbers allowed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (GameBox.Program.User_Check(Tb_user_name.Text) == false)/* check if name and password a valid */
     {
         MessageBox.Show("Invalid User Name - Wrong Input", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (GameBox.Program.Password_Check(Tb_user_password.Text) == false)
     {
         MessageBox.Show("Invalid Password - Wrong Input", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (comboBox1.Text == "Sign in")                                              /* if combo box is on login */
     {
         if (GameBox.Program.Check_NAME_exsist(Tb_user_name.Text, "Players") == 0) /* check if name exisist in database */
         {
             MessageBox.Show("User Name Does not Exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (GameBox.Program.Check_Password_Is_correct(Tb_user_name.Text, Tb_user_password.Text, "Players") == false) /* check if password is correct */
         {
             MessageBox.Show("Invalid Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
     else if (comboBox1.Text == "Sign up")                                                           /* if combo box is on sign up */
     {
         if (GameBox.Program.Insert_User_PLayers(Tb_user_name.Text, Tb_user_password.Text) == false) /* insurt user to players database */
         {
             MessageBox.Show("User Name alreay exsist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         GameBox.Program.Insert_User__Scores(Tb_user_name.Text); /*insurt user to score database */
         MessageBox.Show("User Created!", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     GameBox.Program.user1    = Tb_user_name.Text;             /* save users name */
     GameBox.Program.TypeUser = true;
     GameBox.Program.InsertLogin(Tb_user_name.Text, "Player"); /* insert login time to login database*/
     Tb_user_name.Text     = "";
     Tb_user_password.Text = "";
     if (cob_players.SelectedIndex == 0)
     {
         Program.cnt_players = 1; /* count players update */
         Users_options us = new Users_options(this);
         us.Show();               /* open nex screen */
         this.Hide();             /* hide this screen */
     }
     else
     {
         Program.cnt_players = 2;
         login_form log = new login_form(this);
         log.Show();
         this.Hide();
     }
 }