Esempio n. 1
0
        /// <summary>
        /// Zobrazí novou nabídku pro doplnění čísel po kliknutí na prázdné pole. Pokud má uživatel zaškrtnuto políčko DoNotHighlightDumbNumbersCheckBox, metoda vyřadí čísla, která zjevně nemá podbarvovat.
        /// </summary>
        /// <param name="ButtonName">Tlačítko, na které bylo kliknuto.</param>
        public void ShowNumberMenu(GridButton ButtonName)
        {
            MainMenu.AlreadyLoaded = false;
            foreach (Button button in Sudoku.ListOfNumbers)
            {
                MainMenu.Sudoku.Controls.Remove(button);
            }
            Sudoku.ListOfNumbers.Clear();
            //Graphics g = CreateGraphics();
            // SolidBrush ppap = new SolidBrush(Color.White);
            //g.FillRectangle(ppap, new Rectangle(400, 140, 160, 160));
            for (int i = 1; i < 10; i++)
            {
                if (ButtonName.ForeColor == Color.MidnightBlue)
                {
                    int Row;
                    if (i < 4)
                    {
                        Row = 1;
                    }
                    else if (i > 3 && i < 7)
                    {
                        Row = 2;
                    }
                    else
                    {
                        Row = 3;
                    }

                    int Column;
                    if (36 % i == 0 && i != 4 && i != 1 && i != 2)
                    {
                        Column = 3;
                    }
                    else if (40 % i == 0 && i != 4 && i != 1)
                    {
                        Column = 2;
                    }
                    else
                    {
                        Column = 1;
                    }

                    if (Sudoku.DoHighlightGoodNumbersCheckBox.Checked == true && Sudoku.CanBeFilledIn(i, ButtonName, ListOfGridButtons))
                    {
                        Sudoku.CreateNewButton(i.ToString(), 360 + Column * 50, 100 + Row * 50, Color.LightGreen);
                    }
                    else
                    {
                        Sudoku.CreateNewButton(i.ToString(), 360 + Column * 50, 100 + Row * 50, Color.LightSlateGray);
                    }

                    Sudoku.CreateNewButton("Vymaž", 420, 300, Color.LightSlateGray);
                    Sudoku.CreateNewButton("Napověz", 420, 350, Color.LimeGreen);
                }
            }

            foreach (Button button in Sudoku.ListOfNumbers)
            {
                MainMenu.Sudoku.Controls.Add(button);
            }

            //ppap.Dispose();
            //g.Dispose();
        }
Esempio n. 2
0
        /// <summary>
        /// Konstruktor formuláře Solver1. Inicializuje tlačítka.
        /// </summary>
        public Solver1()
        {
            ListOfGridButtonsSolver.Clear();
            InitializeComponent();
            this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Solver1_KeyPress);
            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    int jd = 0, id = 0;
                    if (i >= 4)
                    {
                        id = 4;
                    }
                    if (i >= 7)
                    {
                        id = 8;
                    }
                    if (j >= 4)
                    {
                        jd = 4;
                    }
                    if (j >= 7)
                    {
                        jd = 8;
                    }
                    string     NameOfButtonstring = (i).ToString() + (j).ToString();
                    GridButton NewGridButton = Sudoku.CreateGridButton(NameOfButtonstring, i, j, 35, j * 35 + jd, i * 35 + id, " ");
                    SolverGrid[i - 1, j - 1]           = NewGridButton;
                    SolverGrid[i - 1, j - 1].Text      = " ";
                    SolverGrid[i - 1, j - 1].ForeColor = Color.DarkGray;
                    SolverGrid[i - 1, j - 1].Solved    = false;
                    Controls.Add(NewGridButton);
                    SolverGrid[i - 1, j - 1].Show();


                    ListOfGridButtonsSolver.Add(SolverGrid[i - 1, j - 1]);
                }
            }
            KeyPreview             = true;
            ListOfNotSolvedButtons = new List <GridButton>(ListOfGridButtonsSolver);

            /* SolverGrid[0, 0].Text = " ";
             * SolverGrid[0, 1].Text = " ";
             * SolverGrid[0, 2].Text = " ";
             * SolverGrid[0, 3].Text = " ";
             * SolverGrid[0, 4].Text = "4";
             * SolverGrid[0, 5].Text = " ";
             * SolverGrid[0, 6].Text = " ";
             * SolverGrid[0, 7].Text = " ";
             * SolverGrid[0, 8].Text = "9";
             * SolverGrid[1, 0].Text = " ";
             * SolverGrid[1, 1].Text = " ";
             * SolverGrid[1, 2].Text = "2";
             * SolverGrid[1, 3].Text = " ";
             * SolverGrid[1, 4].Text = "1";
             * SolverGrid[1, 5].Text = " ";
             * SolverGrid[1, 6].Text = " ";
             * SolverGrid[1, 7].Text = " ";
             * SolverGrid[1, 8].Text = " ";
             * SolverGrid[2, 0].Text = "5";
             * SolverGrid[2, 1].Text = " ";
             * SolverGrid[2, 2].Text = " ";
             * SolverGrid[2, 3].Text = " ";
             * SolverGrid[2, 4].Text = " ";
             * SolverGrid[2, 5].Text = " ";
             * SolverGrid[2, 6].Text = " ";
             * SolverGrid[2, 7].Text = "7";
             * SolverGrid[2, 8].Text = "3";
             * SolverGrid[3, 0].Text = " ";
             * SolverGrid[3, 1].Text = "9";
             * SolverGrid[3, 2].Text = " ";
             * SolverGrid[3, 3].Text = " ";
             * SolverGrid[3, 4].Text = " ";
             * SolverGrid[3, 5].Text = " ";
             * SolverGrid[3, 6].Text = " ";
             * SolverGrid[3, 7].Text = " ";
             * SolverGrid[3, 8].Text = " ";
             * SolverGrid[4, 0].Text = " ";
             * SolverGrid[4, 1].Text = " ";
             * SolverGrid[4, 2].Text = "4";
             * SolverGrid[4, 3].Text = " ";
             * SolverGrid[4, 4].Text = " ";
             * SolverGrid[4, 5].Text = " ";
             * SolverGrid[4, 6].Text = "1";
             * SolverGrid[4, 7].Text = " ";
             * SolverGrid[4, 8].Text = " ";
             * SolverGrid[5, 0].Text = " ";
             *
             * SolverGrid[5, 1].Text = " ";
             * SolverGrid[5, 2].Text = " ";
             * SolverGrid[5, 3].Text = "5";
             * SolverGrid[5, 4].Text = " ";
             * SolverGrid[5, 5].Text = "7";
             * SolverGrid[5, 6].Text = " ";
             * SolverGrid[5, 7].Text = " ";
             * SolverGrid[5, 8].Text = " ";
             * SolverGrid[6, 0].Text = " ";
             * SolverGrid[6, 1].Text = " ";
             * SolverGrid[6, 2].Text = "1";
             * SolverGrid[6, 3].Text = " ";
             * SolverGrid[6, 4].Text = "2";
             * SolverGrid[6, 5].Text = " ";
             * SolverGrid[6, 6].Text = " ";
             * SolverGrid[6, 7].Text = " ";
             * SolverGrid[6, 8].Text = " ";
             * SolverGrid[7, 0].Text = " ";
             * SolverGrid[7, 1].Text = " ";
             * SolverGrid[7, 2].Text = " ";
             * SolverGrid[7, 3].Text = " ";
             * SolverGrid[7, 4].Text = " ";
             * SolverGrid[7, 5].Text = "3";
             * SolverGrid[7, 6].Text = " ";
             * SolverGrid[7, 7].Text = "8";
             * SolverGrid[7, 8].Text = "5";
             * SolverGrid[8, 0].Text = " ";
             * SolverGrid[8, 1].Text = " ";
             * SolverGrid[8, 2].Text = " ";
             * SolverGrid[8, 3].Text = " ";
             * SolverGrid[8, 4].Text = " ";
             * SolverGrid[8, 5].Text = " ";
             * SolverGrid[8, 6].Text = " ";
             * SolverGrid[8, 7].Text = " ";
             * SolverGrid[8, 8].Text = " ";
             * Sudoku.FilledInFields++;
             * .Solved = true;
             * ListOfNotSolvedButtons.Remove();
             */
        }