Exemplo n.º 1
0
        private void Sudoku_UpdateValue(object sender, KeyEventArgs e)
        {
            if (bBaseValue == true)
            {
                return;
            }
            SudokuBtn btn = sender as SudokuBtn;
            int       num = -1;

            if (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9)
            {
                num = e.KeyCode - Keys.D0;
            }

            if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9)
            {
                num = e.KeyCode - Keys.NumPad0;
            }

            if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete)
            {
                num = 0;
            }

            if (num != -1)
            {
                SetValue(num, false);
            }
        }
Exemplo n.º 2
0
 public GameForm()
 {
     InitializeComponent();
     buttons = new SudokuBtn[9][];
     for (int i = 0; i < 9; i++)
     {
         buttons[i] = new SudokuBtn[9];
     }
     time = new Stopwatch();
 }
Exemplo n.º 3
0
 public GameForm(MainWindowForm parent)
 {
     _mainForm      = parent;
     this.MdiParent = parent;
     InitializeComponent();
     buttons = new SudokuBtn[9][];
     for (int i = 0; i < 9; i++)
     {
         buttons[i] = new SudokuBtn[9];
     }
     time = new Stopwatch();
 }
Exemplo n.º 4
0
        public void PrepareLevel(Level lvl)
        {
            int y = 5;
            int x = 5;

            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    // Remove all buttons for previous level choice
                    if (buttons[i][j] != null)
                    {
                        buttons[i][j].Dispose();
                    }
                    SudokuBtn btn = new SudokuBtn(this);
                    btn.Parent    = this;
                    btn.BackColor = System.Drawing.Color.Transparent;
                    btn.UseVisualStyleBackColor = false;
                    btn.FlatStyle = FlatStyle.Standard;
                    //btn.FlatAppearance.BorderColor = Color.Transparent;
                    btn.Font     = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    btn.Location = new System.Drawing.Point(x, y);
                    btn.Size     = new System.Drawing.Size(35, 35);
                    btn.TabIndex = 0;
                    btn.UseVisualStyleBackColor = false;
                    btn.SetValue(lvl.board[i][j], true);

                    panel1.Controls.Add(btn);
                    //btn.Show();
                    buttons[i][j] = btn;

                    if ((j + 1) % 3 == 0)
                    {
                        x += 5;
                    }
                    x += 37;
                }
                x = 5;
                if ((i + 1) % 3 == 0)
                {
                    y += 5;
                }
                y += 37;
            }
            time.Reset();
            time.Start();
            timer1.Start();
            panel1.SendToBack();
        }