Exemple #1
0
        private void buttonsInTable_Click(object sender, MouseEventArgs e)
        {
            menuStrip1.Focus();
            Button thisbtn = (Button)sender;
            Console.WriteLine(e.Button);
            if (e.Button == MouseButtons.Right)
            {
                if (thisbtn.Image != null && thisbtn.Image.Tag.Equals("flag"))
                {
                    thisbtn.Image = null;
                    flags--;
                }
                else {
                    thisbtn.Image = Image.FromFile(@"..\..\images\flag.png");
                    thisbtn.Image.Tag = "flag";
                    flags++;
                }
                toolStripLabel2.Text = (mines - flags).ToString();
            }
            else {
                string[] tmp = thisbtn.Name.Split(',');
                int x = int.Parse(tmp[0]);
                int y = int.Parse(tmp[1]);


                timer1.Start();
                _UncovereItem(x, y);

                if (thisbtn.Image != null)
                {
                    if (thisbtn.Image.Tag.Equals("X"))
                    {
                        //endgame DEFETED

                        thisbtn.Image = Image.FromFile(@"..\..\images\mineX.png");


                        table.ForEach(row => row.ForEach(item => { if (item.Key.Enabled) _UncovereItem(item); }));

                        timer1.Stop();
                        MessageBox.Show("Vesztettél", ":(", MessageBoxButtons.OK);
                    }
                    else {
                        thisbtn.Image = null;

                    }

                }


                // endgame VICTORY
                if (uncoveredFields + mines == Y * X)
                {

                    table.ForEach(row => row.ForEach(item => { if (item.Key.Enabled) _UncovereItem(item); }));

                    timer1.Stop();
                    MessageBox.Show("Nyertél! Az időd:" + time.ToString() + " másodperc", ":)", MessageBoxButtons.OK);

                    if (highScore.Count != 0 && highScore.Last().Time > time)
                    {
                        this.Enabled = false;
                        HighScoreWindow hsw = new HighScoreWindow(highScore, time);
                        hsw.FormClosing += new FormClosingEventHandler(highScoreFormClosing);
                    }

                }

            }

        }
Exemple #2
0
 private void highScoreToolStripMenuItem_Click(object sender, EventArgs e)
 {
     HighScoreWindow hsw = new HighScoreWindow(highScore);
     hsw.FormClosing += new FormClosingEventHandler(highScoreFormClosing);
     this.Enabled = false;
     hsw.Show();
 }
 public AddHighScoreDialogWindow(HighScoreWindow newhsw)
 {
     this.hsw = newhsw;
     InitializeComponent();
 }