Пример #1
0
 private void Window_KeyDown(object sender, KeyEventArgs e)
 {//Sólo se pueden pulsar números
     if (selectedCell != null)
     {
         if (e.Key == Key.Escape)
         {
             Application.Current.Shutdown();
         }
         else if (e.Key == Key.Delete)
         {
             selectedCell.Reset();
         }
         else if (e.Key == Key.Enter)
         {
             Solve();
         }
         else if (!selectedCell.Fixed && !selectedCell.Solved)
         {
             int keyVal = (int)e.Key;
             int value  = -1;
             if (keyVal >= (int)Key.D0 && keyVal <= (int)Key.D9)
             {//Si pulsa un nº en el teclado superior, lo borra como posibilidad
                 value = (int)e.Key - (int)Key.D0;
                 selectedCell.Possible.Remove(value);
                 //Solve();
             }
             else if (keyVal >= (int)Key.NumPad0 && keyVal <= (int)Key.NumPad9)
             {//Si pulsa un nº en el teclado numérico, lo settea
                 value = (int)e.Key - (int)Key.NumPad0;
                 selectedCell.writeNum(value);
             }
         }
     }
 }
Пример #2
0
        internal void UpdateRow(byte col, byte row)
        {
            Cell cell          = GetCell(col, row);
            char UpdateContent = cell.Content;

            for (byte i = 0; i < 9; i++)
            {
                if (i != row)
                {
                    cell = GetCell(col, i);
                    cell.RemoveOpen(UpdateContent);
                    if (cell.Reset())
                    {
                        Updates.Add(cell);
                    }
                }
            }
        }
Пример #3
0
        internal void UpdateArea(byte col, byte row)
        {
            Cell cell          = GetCell(col, row);
            char UpdateContent = cell.Content;

            int AreaCol = (col / 3) * 3;
            int AreaRow = (row / 3) * 3;

            for (byte j = 0; j < 3; j++)
            {
                for (byte i = 0; i < 3; i++)
                {
                    if (AreaCol + i != col && AreaRow + j != row)
                    {
                        cell = GetCell((byte)(AreaCol + i), (byte)(AreaRow + j));
                        cell.RemoveOpen(UpdateContent);
                        if (cell.Reset())
                        {
                            Updates.Add(cell);
                        }
                    }
                }
            }
        }