Esempio n. 1
0
        private void App_Startup(object sender, StartupEventArgs e)
        {
            _model = new RohamModel();


            _viewModel           = new RohamViewModel(_model);
            _viewModel.ExitGame += new EventHandler(ViewModel_ExitGame);


            _view             = new MainWindow();
            _view.DataContext = _viewModel;
            _view.Show();
        }
Esempio n. 2
0
        private void App_Startup(object sender, StartupEventArgs e)
        {
            _model           = new RohamModel();
            _model.GameOver += _model_GameOver;
            _model.NewGame(8);

            _viewModel          = new RohamViewModel(_model);
            _viewModel.NewGame += _viewModel_NewGame;


            _view             = new MainWindow();
            _view.DataContext = _viewModel;
            _view.Closing    += _view_Closing;
            _view.Show();
        }
Esempio n. 3
0
        public RohamViewModel(RohamModel model)
        {
            _model = model;
            _model.GameAdvanced += _model_GameAdvanced;
            _model.GameOver     += _model_GameOver;
            _model.GameCreated  += _model_GameCreated;
            GridSize             = 8;
            skipCount            = 0;
            NewGameCommand       = new DelegateCommand(param => OnNewGame(GridSize));

            Elore  = new DelegateCommand(param => OnElore());
            Hatra  = new DelegateCommand(param => OnHatra());
            Jobbra = new DelegateCommand(param => OnJobbra());
            Balra  = new DelegateCommand(param => OnBalra());
            Skipp  = new DelegateCommand(param => OnSkipp());

            NewGame4 = new DelegateCommand(param => OnNewGame(4));
            NewGame6 = new DelegateCommand(param => OnNewGame(6));
            NewGame8 = new DelegateCommand(param => OnNewGame(8));

            Fields = new ObservableCollection <RohamField>();
            for (Int32 i = 0; i < _model.Table.Size; i++)  // inicializáljuk a mezőket
            {
                for (Int32 j = 0; j < _model.Table.Size; j++)
                {
                    Fields.Add(new RohamField
                    {
                        Text        = String.Empty,
                        X           = i,
                        Y           = j,
                        Number      = i * _model.Table.Size + j,
                        StepCommand = new DelegateCommand(param => StepGame(Convert.ToInt32(param)))
                    });
                }
            }
            RefreshTable();
        }