public RefreshViewModel(IMainModel mainModel, IJogosSantaCasaService jogosSantaCasaService, INavigationService navigationService, ISystemTrayService systemTrayService, IShellTileService shellTileService)
        {
            _mainModel             = mainModel;
            _jogosSantaCasaService = jogosSantaCasaService;
            _navigationService     = navigationService;
            _systemTrayService     = systemTrayService;
            _shellTileService      = shellTileService;

            RefreshCommand = new RelayCommand(() =>
            {
                IsBusy = true;

                StatusText = "A actualizar os resultados...";

                _jogosSantaCasaService.GetResults(result =>
                {
                    if (result.Error != null)
                    {
                        StatusText = "Ocorreu um erro ao actualizar os resultados!";

                        IsBusy = false;

                        return;
                    }
                    else if (result.StatusCode != System.Net.HttpStatusCode.NotModified)
                    {
                        _mainModel.Results = result.Data;
                        _mainModel.ETag    = result.ETag;
                    }

                    _systemTrayService.HideProgressIndicator();

                    if (_navigationService.CanGoBack)
                    {
                        _navigationService.RemoveBackEntry();
                    }
                    _navigationService.NavigateTo(new Uri("/View/ResultsPage.xaml", UriKind.Relative));
                }, _mainModel.ETag, null);
            }, () => !IsBusy);

#if !WP8
            DispatcherHelper.RunAsync(UpdateTiles);
#endif
        }
 public ApplicationTileService(IApplicationSettings applicationSettings, IShellTileService shellTileService)
 {
     this.applicationSettings = applicationSettings;
     this.shellTileService = shellTileService;
 }
Пример #3
0
        public MainViewModel(IMainModel mainModel, INavigationService navigationService, IMessageBoxService messageBoxService, IApplicationSettingsService applicationSettingsService, IShellTileService shellTileService)
        {
            _mainModel = mainModel;
            _navigationService = navigationService;
            _messageBoxService = messageBoxService;
            _applicationSettingsService = applicationSettingsService;
            _shellTileService = shellTileService;

            NewAccountCommand = new RelayCommand(() =>
            {
                _navigationService.NavigateTo("/View/AuthorizationPage.xaml");
            });

            RemoveAccountCommand = new RelayCommand<AccountViewModel>(account =>
            {
                _mainModel.AvailableAccounts.Remove(account.Model);
                _mainModel.Save();

                RefreshAccountsList();
            });

            OpenAccountCommand = new RelayCommand<AccountViewModel>(account =>
            {
                _mainModel.CurrentAccount = account.Model;
                _mainModel.ExecuteInitialLoad = true;

                _navigationService.NavigateTo("/View/ExplorerPage.xaml");
            });

            ShowAboutCommand = new RelayCommand(() =>
            {
                _navigationService.NavigateTo("/View/AboutPage.xaml");
            });

            PageLoadedCommand = new RelayCommand(() =>
            {
                _mainModel.CurrentAccount = null;

                if (!_applicationSettingsService.Get<bool>("AcceptedDisclaimer", false))
                {
                    _applicationSettingsService.Set("AcceptedDisclaimer", true);
                    _applicationSettingsService.Save();

                    _messageBoxService.Show("You are advised to read the GDrive disclaimer before you continue.\n\nWould you like to read it now?\n\nYou can always find it later in the About page.", "Welcome to GDrive", new[] { "now", "later" }, buttonIndex =>
                    {
                        if (buttonIndex == 0)
                        {
                            _navigationService.NavigateTo("/View/AboutPage.xaml?disclaimer=true");
                        }
                    });
                }
            });

            MessengerInstance.Register<AvailableAccountsChangedMessage>(this, message =>
            {
                RefreshAccountsList();
            });

#if !WP8
            DispatcherHelper.RunAsync(UpdateTiles);
#endif
        }