Exemplo n.º 1
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            Minesweeper p = new Minesweeper(10, 9, 9);

            p.Show();
            Close();
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            Minesweeper p = new Minesweeper(99, 30, 16);

            p.Show();
            Close();
        }
Exemplo n.º 3
0
        private void btnCustom_Click(object sender, RoutedEventArgs e)
        {
            int mines;
            int width;
            int height;

            bool mineParsed;
            bool widthParsed;
            bool heightParsed;
            bool parsed;

            mineParsed   = int.TryParse(txtMines.Text, out mines);
            widthParsed  = int.TryParse(txtWidth.Text, out width);
            heightParsed = int.TryParse(txtHeight.Text, out height);
            parsed       = mineParsed && widthParsed && heightParsed;

            string errors = "Errors: \n";

            if (!mineParsed)
            {
                errors += "Invalid mines \n";
                txtMines.Clear();
            }
            if (!widthParsed)
            {
                errors += "Invalid width \n";
                txtWidth.Clear();
            }
            if (!heightParsed)
            {
                errors += "Invalid height \n";
                txtHeight.Clear();
            }

            if (parsed)
            {
                if (mines < height * width && mines > 0)
                {
                    if (height >= 9 && height <= 30 && width >= 9 && width <= 50)
                    {
                        Minesweeper p = new Minesweeper(mines, width, height);
                        p.Show();
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("The valid width and height are specified in parenthesis.");
                    }
                }
                else
                {
                    MessageBox.Show("Number of mines must be between 1 and " + (width * height - 1).ToString() + " given the width and height described.");
                }
            }
            else
            {
                MessageBox.Show(errors);
            }
        }
Exemplo n.º 4
0
        public MainWindow()
        {
            InitializeComponent();
            grid = new List <List <Cell> >();
            Minesweeper minesweeper = new Minesweeper(30, 20, 25);

            minesweeper.Show();
            Close();
        }