Exemplo n.º 1
0
 private void RemoveBackEntries(AppCommandMessage appCommandMessage)
 {
     if (appCommandMessage.Reason == AppCommandMessageReason.RemoveBackEntries)
     {
         while ((Application.Current.RootVisual as PhoneApplicationFrame).BackStack.Any())
         {
             (Application.Current.RootVisual as PhoneApplicationFrame).RemoveBackEntry();
         }
     }
 }
Exemplo n.º 2
0
        public WhereToViewModel(IAggregateService aggregateService, IBumbleApiService BumbleApiService, IUberService uberService)
            : base(ApplicationPage.WhereTo, aggregateService)
        {
            this.user             = UnitOfWork.UserRepository.GetUser();
            this.BumbleApiService = BumbleApiService;
            this.uberService      = uberService;

            AppCommandMessage.Send(Messages.Enums.AppCommandMessageReason.RemoveBackEntries);

            Messenger.Default.Register <RecentTripMessage>(this, (action) => SetRecentTrip(action));
            Messenger.Default.Register <FavouriteMessage>(this, (action) => SetFavourite(action));
            Messenger.Default.Register <WhereToMessage>(this, (action) => SetWhereTo(action));

            this.LocationSearchBoxModel    = new SearchBoxModel(UnitOfWork, InMemoryApplicationSettingModel, this, SearchType.Location, BumbleApiService, user, NavigationService);
            this.DestinationSearchBoxModel = new SearchBoxModel(UnitOfWork, InMemoryApplicationSettingModel, this, SearchType.Destination, BumbleApiService, user, NavigationService);

            this.LocationSearchBoxModel.Changed    += LocationSearchBoxModel_Changed;
            this.DestinationSearchBoxModel.Changed += LocationSearchBoxModel_Changed;

            this.LocationSearchBoxModel.SetAutoPopulateState();
        }
        private void SetPageState(SplashScreenMessage splashScreenMessage)
        {
            switch (splashScreenMessage.Reason)
            {
            case Messages.Enums.SplashScreenMessageReason.CountrySelected:
                CountrySelection = selectedCountryPersist.Name;

                NavigationService.GoBack();

                DownloadCountryData();
                break;

            case Messages.Enums.SplashScreenMessageReason.FacebookLogin:
            case Messages.Enums.SplashScreenMessageReason.BumbleLogin:
            case Messages.Enums.SplashScreenMessageReason.TwitterLogin:
                base.user = UnitOfWork.UserRepository.GetUser();
                selectedCountryPersist = user.Country;

                DownloadCountryData();
                break;

            case Messages.Enums.SplashScreenMessageReason.ChangeCountry:
                AppCommandMessage.Send(Messages.Enums.AppCommandMessageReason.RemoveBackEntries);

                base.user         = UnitOfWork.UserRepository.GetUser();
                base.user.Country = null;
                UnitOfWork.UserRepository.Update(base.user);
                UnitOfWork.Save();
                resourcesLoaded = false;
                break;

            case Messages.Enums.SplashScreenMessageReason.ResetApp:
                AppCommandMessage.Send(Messages.Enums.AppCommandMessageReason.RemoveBackEntries);

                DatabaseSetup.Seed(UnitOfWork, true);

                resourcesLoaded = false;
                break;
            }
        }
        private void TryNavigateToStartPage()
        {
            // Navigation service can be null on viewmodel load as it hasn't been populated yet.
            if (NavigationService != null)
            {
                Action navigate = () =>
                {
                    user.AppUsageCount += 1;
                    UnitOfWork.UserRepository.Update(user);
                    UnitOfWork.Save();

                    NavigationService.NavigateTo("/Views/WhereTo.xaml?userId=" + user.Token.ToString());

                    AppCommandMessage.Send(Messages.Enums.AppCommandMessageReason.RemoveBackEntries);
                };

                //Keep trying to navgiate every half a second:
                TaskEx.Delay(500).ContinueWith(t =>
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(navigate);
                });
            }
            else
            {
                Action navigate = () =>
                {
                    TryNavigateToStartPage();
                };

                //Keep trying to navgiate every half a second:
                TaskEx.Delay(500).ContinueWith(t =>
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(navigate);
                });
            }
        }
Exemplo n.º 5
0
 private static void RemoveBackEntries(AppCommandMessage appCommandMessage)
 {
     if (appCommandMessage.Reason == AppCommandMessageReason.RemoveBackEntries)
     {
         while ((Application.Current.RootVisual as PhoneApplicationFrame).BackStack.Any())
             (Application.Current.RootVisual as PhoneApplicationFrame).RemoveBackEntry();
     }
 }