private void btn_save_Click(object sender, EventArgs e)
        {
            if (txtbox_typename.Text != "")
            {
                if (txtbox_typename.Text.Contains(' '))
                {
                    MessageBox.Show("Type your name without spaces!", "Attention");
                    frm_Record r = new frm_Record();
                    r.ShowDialog();
                }
                else
                {
                    Game_Control.name = txtbox_typename.Text;
                }
            }

            else
            {
                Game_Control.name = "";
            }

            this.Close();
        }
Exemplo n.º 2
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            Graphics g = CreateGraphics();

            timer1.Start();
            int x = e.X / SizeofCell;
            int y = (e.Y - 25) / SizeofCell;

            if (e.Button == MouseButtons.Left)
            {
                if (matrix[x, y].Opened == false && matrix[x, y].Flagged == false)
                {
                    matrix.Open_Cell(x, y);
                    RedrawCell(g, x, y);
                }

                //Invalidate();

                if (matrix.Finish == true)
                {
                    timer1.Stop();
                    this.Enabled = false;
                    if (MessageBox.Show("You Win", "Result") == DialogResult.OK)
                    {
                        frm_Record rc = new frm_Record();
                        rc.ShowDialog();

                        if (name != "")
                        {
                            frm_Main._score[Mark].count++;
                            Array.Resize(ref frm_Main._score[Mark].name, frm_Main._score[Mark].count);
                            Array.Resize(ref frm_Main._score[Mark].time, frm_Main._score[Mark].count);
                            frm_Main._score[Mark].name[frm_Main._score[Mark].count - 1] = name;
                            frm_Main._score[Mark].time[frm_Main._score[Mark].count - 1] = count;
                        }

                        rc.Dispose();
                    }
                    timer1.Dispose();
                }

                if (matrix.Lose == true)
                {
                    timer1.Stop();
                    panel1.Enabled = false;
                    MessageBox.Show("You Lose", "Result");
                    timer1.Dispose();
                }
            }

            if (e.Button == MouseButtons.Right)
            {
                matrix.Set_Flag(x, y);
                g.DrawImage(matrix[x, y].Image, x * SizeofCell, y * SizeofCell + 25);
                if (matrix.Numofflag >= 10)
                {
                    lbl_flagCounter.Text = "0" + matrix.Numofflag.ToString();
                }
                else
                {
                    lbl_flagCounter.Text = "00" + matrix.Numofflag.ToString();
                }
                //Invalidate();
            }
        }