Beispiel #1
0
        public void setSizeOfWindow(PlayWindow window, int squareSize)
        {
            int formula = squareSize + (9 * squareSize);

            window.Width  = formula + 185;
            window.Height = formula + 20;
        }
Beispiel #2
0
        private void easyButton_Click(object sender, EventArgs e)
        {
            // Seleccionamos el sudoku a mostrar
            Random     rnd        = new Random();
            int        puzzlePick = rnd.Next(1, numOfSolvedGrids() + 1);
            SudokuGrid sudokuGrid = new SudokuGrid(getPuzzle(puzzlePick));
            PlayWindow pw         = new PlayWindow(gameControl, sudokuGrid, 0);

            pw.FormClosed += (s, args) => Close();
            Hide();
            pw.Show();
        }
Beispiel #3
0
 public void setHighlightNumber(PlayWindow window, int number)
 {
     for (int i = 0; i < 9; i++)
     {
         for (int j = 0; j < 9; j++)
         {
             string    concatName = (i) + "" + (j);
             Control[] controls   = window.Controls.Find(concatName, true);
             if (controls.Length == 1)
             {
                 Button b = controls[0] as Button;
                 b.MouseEnter += new EventHandler((sender, e) => window.button_enterHighlight(sender, e, number));
             }
         }
     }
 }
Beispiel #4
0
 public void incrementPenaltyLabel(PlayWindow window)
 {
     Control[] controls = window.Controls.Find("penaltyLabel", true);
     if (controls.Length == 1)
     {
         Label lab = controls[0] as Label;
         if (lab.InvokeRequired)
         {
             WindowActionCallBack d = new WindowActionCallBack(incrementPenaltyLabel);
             Invoke(d, new object[] { window });
         }
         else
         {
             playerPenalty++;
             lab.Text = "Intentos: " + playerPenalty;
         }
     }
 }
Beispiel #5
0
        // Creates9 3x3 grids of buttons ("above" labels)
        public void createButtonGrid(PlayWindow window, int squareSize)
        {
            List <List <Button> > buttonGrid = new List <List <Button> >();
            int nextX = 0, nextY = 0;

            for (int i = 0; i < 9; i++)
            {
                nextX = 0;
                if (i % 3 == 0)
                {
                    nextY += 6;
                }

                List <Button> col = new List <Button>();
                for (int j = 0; j < 9; j++)
                {
                    Button newButton = new Button();
                    newButton.Size = new Size(squareSize, squareSize);
                    newButton.Text = "";
                    if (j % 3 == 0) // Start a new block horizontally
                    {
                        nextX += 6;
                    }
                    newButton.Location = new Point(nextX, nextY);
                    string concatName = (i) + "" + (j);
                    newButton.Name        = concatName;
                    newButton.Enabled     = true;
                    newButton.Font        = new Font("Microsoft Sans Serif", 12, FontStyle.Bold);
                    newButton.MouseLeave += new EventHandler(window.button_leaveHighlight);
                    newButton.MouseClick += new MouseEventHandler(window.button_click);
                    window.Controls.Add(newButton);
                    col.Add(newButton);
                    nextX += squareSize;
                }
                nextY += squareSize;
                buttonGrid.Add(col);
            }
            playerViewGrid = buttonGrid;
        }
Beispiel #6
0
        public void createToolbox(PlayWindow window, int squareSize)
        {
            Label newLabel = new Label();

            newLabel.Font     = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);
            newLabel.Location = new Point(397, 95);
            newLabel.Text     = "Selecione uno";
            newLabel.Size     = new Size(200, 25);
            window.Controls.Add(newLabel);
            int nextX = 0, nextY = 120;
            int incrementor = 1;

            for (int i = 0; i < 3; i++)
            {
                nextX = 400;
                for (int j = 0; j < 3; j++)
                {
                    Button newButton = new Button();
                    newButton.Size     = new Size(squareSize, squareSize);
                    newButton.Location = new Point(nextX, nextY);
                    newButton.Text     = incrementor.ToString();
                    newButton.Name     = "toolkit" + incrementor;
                    if (newButton.Name == "toolkit1")
                    {
                        newButton.Enabled = false;
                    }
                    newButton.Click += new EventHandler(window.toolkit_Click);
                    newButton.Font   = new Font("Microsoft Sans Serif", 12, FontStyle.Bold);
                    window.Controls.Add(newButton);
                    nextX += squareSize;
                    incrementor++;
                }
                nextY += squareSize;
            }

            // Also create bit below toolbox (penalty + time)
            Label timeLabel = new Label();

            timeLabel.Font     = new Font("Microsoft Sans Serif", 8);
            timeLabel.Location = new Point(420, 323);
            timeLabel.Text     = "Tiempo transcurrido: 0:00";
            timeLabel.Name     = "timeElapsedLabel";
            stopWatch          = new Stopwatch();
            window.Controls.Add(timeLabel);

            Label penLabel = new Label();

            penLabel.Font     = new Font("Microsoft Sans Serif", 8);
            penLabel.Location = new Point(420, 345);
            penLabel.Text     = "Intentos: 0";
            penLabel.Name     = "penaltyLabel";
            playerPenalty     = 0;
            window.Controls.Add(penLabel);

            // Set up number of instances to an empty 9-depth list
            numberInstances = new List <int>();
            for (int i = 0; i < 10; i++)
            {
                numberInstances.Add(0);
            }
        }