protected override void OnSearchActivated(SearchActivatedEventArgs args) { base.OnSearchActivated(args); if (args != null && args.Kind == ActivationKind.Search) { var searchArgs = args as SearchActivatedEventArgs; string serializedCriteria = null; if (args.PreviousExecutionState == ApplicationExecutionState.Running) { var criteria = new PollsPageSearchNavigationCriteria { SearchQuery = searchArgs.QueryText }; serializedCriteria = Serializer.Serialize(criteria); NavigationService.NavigateToViewModel<PollsPageViewModel>(serializedCriteria); } else { var criteria = new LandingPageNavigationCriteria { }; serializedCriteria = Serializer.Serialize(criteria); DisplayRootView<LandingPage>(serializedCriteria); } } }
private async Task LoadIdentityAndGo(string profileId) { IUserIdentity identity = null; IsBusy = true; try { //identity = (this.objectFactory as IObjectFactory<IUserIdentity>).Fetch(profileId); identity = await this.ObjectFactory.FetchAsync(profileId); var principal = new CslaPrincipalCore(identity); Csla.ApplicationContext.User = principal; } catch (DataPortalException ex) { Console.WriteLine(ex.Message); identity = null; MessageBox.Show(this, ex.Message); } IsBusy = false; if (identity == null) { this.MessageBox.Show(this, "There was an error retrieving your profile.", "Error"); } else if (identity.IsAuthenticated) { // If there is a PollId, the user is coming in from a URI. // Navigate to the Polls page, which adds it to the back stack. // Then, navigate to the View Poll page. This allows the user to be able // to back out of the View Poll page and land on the Polls page, rather than // leaving the app. if (this.NavigationCriteria != null && this.NavigationCriteria.PollId.HasValue) { var criteria = new ViewPollPageNavigationCriteria { PollId = this.NavigationCriteria.PollId.Value }; //this.Navigation.NavigateToViewModel<PollsPageViewModel>(); //this.Navigation.NavigateToViewModel<ViewPollPageViewModel>(criteria); } else if (this.NavigationCriteria != null && !string.IsNullOrEmpty(this.NavigationCriteria.SearchQuery)) { var criteria = new PollsPageSearchNavigationCriteria { SearchQuery = this.NavigationCriteria.SearchQuery }; //this.Navigation.NavigateToViewModel<PollsPageViewModel>(); //this.Navigation.NavigateToViewModel<ViewPollPageViewModel>(criteria); } else { //this.Navigation.NavigateToViewModel<PollsPageViewModel>(); var polls = new Intent (this, typeof(PollsActivity)); StartActivity (polls); } } else { var criteria = new RegistrationPageNavigationCriteria { ProfileId = profileId }; if (this.NavigationCriteria != null) { criteria.PollId = this.NavigationCriteria.PollId; } var registration = new Intent (this, typeof(RegistrationActivity)); registration.PutExtra("NavigationCriteria_PollId", criteria.PollId ?? 0); registration.PutExtra ("NavigationCriteria_ProfileId", criteria.ProfileId); StartActivity (registration); //this.Navigation.NavigateToViewModel<RegistrationPageViewModel>(criteria); } }
private async Task LoadIdentityAndGo(string profileId) { IUserIdentity identity = null; IsBusy = true; try { identity = await this.objectFactory.FetchAsync(profileId); var principal = new CslaPrincipalCore(identity); Csla.ApplicationContext.User = principal; } catch (DataPortalException ex) { Debug.WriteLine(ex.Message); identity = null; } IsBusy = false; if (identity == null) { #if WINDOWS_PHONE this.messageBox.Show("There was an error retrieving your profile.", "Error"); #else await this.messageBox.ShowAsync("There was an error retrieving your profile.", "Error"); #endif // WINDOWS_PHONE } else if (identity.IsAuthenticated) { // If there is a PollId, the user is coming in from a URI. // Navigate to the Polls page, which adds it to the back stack. // Then, navigate to the View Poll page. This allows the user to be able // to back out of the View Poll page and land on the Polls page, rather than // leaving the app. if (this.NavigationCriteria != null && this.NavigationCriteria.PollId.HasValue) { var criteria = new ViewPollPageNavigationCriteria { PollId = this.NavigationCriteria.PollId.Value }; this.Navigation.NavigateToViewModel<PollsPageViewModel>(); this.Navigation.NavigateToViewModel<ViewPollPageViewModel>(criteria); } else if (this.NavigationCriteria != null && !string.IsNullOrEmpty(this.NavigationCriteria.SearchQuery)) { var criteria = new PollsPageSearchNavigationCriteria { SearchQuery = this.NavigationCriteria.SearchQuery }; this.Navigation.NavigateToViewModel<PollsPageViewModel>(); this.Navigation.NavigateToViewModel<ViewPollPageViewModel>(criteria); } else { this.Navigation.NavigateToViewModel<PollsPageViewModel>(); } } else { var criteria = new RegistrationPageNavigationCriteria { ProfileId = profileId }; if (this.NavigationCriteria != null) { criteria.PollId = this.NavigationCriteria.PollId; } this.Navigation.NavigateToViewModel<RegistrationPageViewModel>(criteria); } }