Exemplo n.º 1
0
        public UpdateViewModel(IEventAggregator eventAggregator)
        {
            _eventAggregator   = eventAggregator;
            UpdateModulesModel = new UpdateModules();

            RunTheUpdate();
        }
        public void DataUpdateEvent_Published_UpdatesDataUpdateModulesProperty()
        {
            UpdateModules update = new UpdateModules()
            {
                RacesPl = true,
                HCzFrom = 20
            };

            _dataUpdateEvent.Publish(update);

            Assert.True(_viewModel.DataUpdateModules.RacesPl);
            Assert.Equal(20, _viewModel.DataUpdateModules.HCzFrom);
            Assert.Equal(update, _viewModel.DataUpdateModules);
        }
Exemplo n.º 3
0
        public MainViewModel(IFileService dataServices,
                             IMessageService messageDialogServices,
                             IUpdateService updateDataService,
                             ISimulateService simulateDataService,
                             IEventAggregator eventAggregator,
                             IDictionariesService dictionaryService)
        {
            Horses            = new List <LoadedHorse>();
            Jockeys           = new List <LoadedJockey>();
            Races             = new List <RaceDetails>();
            HorseList         = new ObservableCollection <HorseDataWrapper>();
            LoadedHorses      = new List <string>();
            LoadedJockeys     = new List <string>();
            DateTimeNow       = DateTime.Now;
            DataUpdateModules = new UpdateModules();

            _eventAggregator      = eventAggregator;
            _dataServices         = dataServices;
            _updateDataService    = updateDataService;
            _simulateDataService  = simulateDataService;
            _messageDialogService = messageDialogServices;
            _dictionaryService    = dictionaryService;

            AllControlsEnabled    = true;
            VisibilityUpdatingBtn = true;
            VisibilityTestingBtn  = true;

            NewHorseCommand             = new DelegateCommand(OnNewHorseExecute);
            ClearDataCommand            = new DelegateCommand(OnClearDataExecute);
            UpdateCancellationCommand   = new DelegateCommand(OnUpdateCancellationExecute);
            SimulateCancellationCommand = new DelegateCommand(OnSimulateCancellationExecute);
            SimulateResultsCommand      = new AsyncCommand(async() => await OnSimulateResultsExecuteAsync());
            PickHorseDataCommand        = new DelegateCommand(OnPickHorseDataExecute);
            UpdateDataCommand           = new AsyncCommand(async() => await OnUpdateDataExecuteAsync());

            RaceModelProvider  = new RaceModel();
            CategoryFactorDict = _dictionaryService.GetRaceCategoryDictionary(RaceModelProvider);

            //delegates and commands
            ClearDataCommand.Execute(null);
            HorseList.CollectionChanged += OnHorseListCollectionChanged;
            _eventAggregator.GetEvent <DataUpdateEvent>().Subscribe(OnDataUpdate);       //watches for update view model properties update event
            _eventAggregator.GetEvent <ProgressBarEvent>().Subscribe(OnProgressBarTick); //watches for service layer progress bar data update event
            _eventAggregator.GetEvent <LoadDataEvent>().Subscribe(OnLoadAllDataAsync);   //watches for vm load data update event
            _eventAggregator.GetEvent <LoadDataEvent>().Publish();                       // publish vm load data update event
        }
Exemplo n.º 4
0
 /// <summary>
 /// event subscrition for update properties came from UpdateViewModel
 /// </summary>
 /// <param name="updateModules"></param>
 private void OnDataUpdate(UpdateModules updateModules)
 {
     DataUpdateModules = updateModules;
 }