示例#1
0
        /// <summary>
        /// WinForms GUI for Sudoku game
        /// </summary>
        public UserInterface()
        {
            InitializeComponent();

            game  = PuzzleFactory.GetSudoku();          // Instantiate puzzle
            trans = new Transform(game.SideLength,      // Scaled and translated utility methods to match current dimensions
                                  new Size(pnlPuzzle.Width, pnlPuzzle.Height));
            gameHistory = new Stack <Game>();           // Prepare for undo history
            launch      = DateTime.Now;

            // Configure shared calculated values used for scaling and translating
            sqrtGameSize     = (int)Math.Round(Math.Sqrt(game.SideLength), 0);
            logicalCellSize  = sqrtGameSize + 1;
            logicalUnitCount = 1 + game.SideLength * logicalCellSize;

            //SetStyle(ControlStyles.ResizeRedraw, true); // Redraw form when resized
            stringFormat.Alignment     = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;
        }
示例#2
0
        public void PuzzleFactory_GetSudoku_Valid()
        {
            var puzzle = PuzzleFactory.GetSudoku();

            Assert.IsInstanceOfType(puzzle, typeof(Game));
        }