Esempio n. 1
0
 public GamePage()
 {
     this.InitializeComponent();
     _settingsViewModel = (Application.Current as App).SettingsViewModel;
     gameViewModel = new GameViewModel(_settingsViewModel);
     this.DataContext = gameViewModel;
 }
Esempio n. 2
0
        private void UserControl_Loaded_1(object sender, RoutedEventArgs e)
        {
            gameViewModel = DataContext as GameViewModel;
            var rows = Enumerable.Range(0, RowCount).ToArray();
            var columns = Enumerable.Range(0, ColumnCount).ToArray();
            foreach (var row in rows) BoardGrid.RowDefinitions.Add(new RowDefinition());
            foreach (var column in columns) BoardGrid.ColumnDefinitions.Add(new ColumnDefinition());
            foreach (var row in rows)
            {
                foreach (var column in columns)
                {
                    var boardViewBox = new Viewbox();
                    var boardSpace = new BoardSpace();
                    boardSpace.row = row;
                    boardSpace.column = column;
                    boardSpace.gameViewModel = gameViewModel;
                    boardViewBox.Child = boardSpace;
                    boardViewBox.Stretch = Stretch.Fill;
                    Grid.SetRow(boardViewBox, row);
                    Grid.SetColumn(boardViewBox, column);
                    BoardGrid.Children.Add(boardViewBox);
                    boardSpace.DataContext = gameViewModel.game.m_pMines[row][column];

                }
            }
        }