protected override void OnNavigatedTo(NavigationEventArgs args)
        {
            if (args.Parameter as GridDefinition == null)
            {
                throw new ArgumentException("Expected a GameDefinition Parameter on Page Navigate");
                //Throw exception- expect the minersweper obejct
                //Navigate to page using Frame.Navigate(sourcePageType, minesweeperObject);
            }

            GridDefinition grid = args.Parameter as GridDefinition;

            game = new Minesweeper(grid);


            responder.Notifier      = game.Notifier;
            game.Notifier.Responder = responder;

            double wRatio = grid.width / DEFAULT_LENGTH;
            double hRatio = grid.height / DEFAULT_LENGTH;

            double wAdd = wRatio - 1;
            double hAdd = hRatio - 1;

            WIDTH  += WIDTH * wAdd * 0.2;
            HEIGHT += HEIGHT * hAdd * 0.2;
            canvas.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { canvas.Width = WIDTH; canvas.Height = HEIGHT; });


            Rect gameBoard = GetBoardRegion(WIDTH, HEIGHT);

            gameBoardConfig = new GameBoardConfig(gameBoard, grid.width, grid.height, 5, 5);
        }
Пример #2
0
        public void Restart()
        {
            Minesweeper.Restart();

            RecreateSettingsImage();

            _timer.Text = "00:00";

            HasGameStarted = false;

            Pause();
        }
Пример #3
0
        public MainPage()
        {
            InitializeComponent();

            Minesweeper              = new Minesweeper(Settings.GetSettings());
            Minesweeper.GameOver    += Stop;
            Minesweeper.CellClicked += Start;
            Minesweeper.CellHolded  += CellHold;

            RecreateSettingsImage();

            Minesweeper.CreateArea();

            Minesweeper.CreateCells();

            BindingContext = Minesweeper;

            _mines.SetBinding(Label.TextProperty, new Binding("MinesLeft"));

            _area.Content = Minesweeper;
        }
 public NotifierImp(Minesweeper game)
 {
     this.game = game;
 }