public override void Draw() { int size = _mode.SquareSize, x = 0, y = 0; var p = _properties; // draw information bar InformationBar.Draw(_stopWatch.GetTime(), (_mode.Board as MinesweeperBoard).Flag); // draw each squares on the board foreach (string representativeChar in _mode.Board.DrawableBoard) { // draw the whole square Bitmap image = BitmapList.GetBitmap(representativeChar); // x and y must all be substracted with its respective offsets SplashKit.DrawBitmapOnWindow( SplashKit.CurrentWindow(), image, p.MarginLeft + x * size - p.SquareOffsetX, p.MarginTop + y * size - p.SquareOffsetY, p.SquareOptions ); // advances to another row if (x++ == _mode.Board.Width - 1) { x = 0; y++; } } }
/// <summary> /// Modularization for drawing simplified board /// </summary> /// <param name="board">Stringified minesweeper board</param> /// <param name="rotate90Deg">Rotates the board 90 degrees (but the squares aren't)</param> private void DrawBoard(string[] board, bool rotate90Deg = false) { int x = 0, y = 0; var props = rotate90Deg ? _opponentProps : _playerProps; // draw each squares on the board foreach (string representativeChar in board) { // draw the whole square Bitmap image = BitmapList.GetBitmap(representativeChar); // x and y must all be substracted with its respective offsets SplashKit.DrawBitmapOnWindow( SplashKit.CurrentWindow(), image, props.MarginLeft + x * props.SquareSize - props.SquareOffsetX, props.MarginTop + y * props.SquareSize - props.SquareOffsetY, props.SquareOptions ); // advances to another row // player if (!rotate90Deg) { x++; if (x == _settings.BoardWidth) { x = 0; y++; } continue; } // opponent y++; if (y == _settings.BoardWidth) { y = 0; x++; } } }