示例#1
0
        private void button3_Click(object sender, EventArgs e)
        {
            Scores sc = new Scores();

            sc.Activate();
            sc.Show();

            this.Hide();
        }
示例#2
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (start == true)
            {
                PictureBox picBox = (PictureBox)sender;

                //elegxos wste na leitourgei me mono 1 click to event
                if (!fireOnlyOnce.ContainsKey(picBox))
                {
                    fireOnlyOnce.Add(picBox, true);
                }
                //afou allaxoume tin piswpleura tis kartas tote to click event den xanadouleuei
                if (picBox.ImageLocation != "yugi.jpg")
                {
                    fireOnlyOnce[picBox] = false;
                }
                if (fireOnlyOnce[picBox] == true)
                {
                    //to prwto picBox p allazw tha bainei se mia lista
                    //an to 2o picBox exei idio imageLocation me auto p einai sti lista tote katharizw ti lista kai sunexizw
                    //an den exei katharizw tin lista kai oi eikones xanaginontai pantou idies (flipBackside)
                    //episis katharizw to fireonlyonce Dictionary

                    picBox.ImageLocation = pictureBoxFullPaths[storePicBoxNumber[picBox]];


                    if (similarPicBoxes.Count == 0)
                    {
                        similarPicBoxes.Add(picBox);
                    }
                    else
                    {
                        if (similarPicBoxes[0].ImageLocation == picBox.ImageLocation)
                        {
                            //ta afairw apo to list wste na parameinoun anoixta
                            CopyOfpictureBoxes.Remove(similarPicBoxes[0]);
                            CopyOfpictureBoxes.Remove(picBox);
                            similarPicBoxes.Clear();
                            correctCounter += 2;
                        }
                        else
                        {
                            MessageBox.Show("Wrong picture.Try again!");
                            fireOnlyOnce.Clear();
                            similarPicBoxes.Clear();
                            Helper.flipBackSide(CopyOfpictureBoxes, "yugi.jpg");
                        }
                    }
                }
                if (correctCounter == 16)
                {
                    timer1.Stop();
                    player.seconds = seconds;
                    seconds        = 0;
                    MessageBox.Show("You win!");
                    StreamWriter write = new StreamWriter("scores\\" + player.username + ".txt", append: true);
                    //   write.WriteLine("\n");
                    write.WriteLine(player.username + " " + player.seconds);
                    write.Close();
                    correctCounter = 0;
                    Scores sc = new Scores(player.seconds, player.username);
                    sc.Activate();
                    sc.Show();
                    this.Hide();
                }
            }
        }