protected override async void OnNavigatedTo(NavigationEventArgs e) { TagSuggestionService.IncreaseStateCode(asb); Navigator.GetForCurrentView().Handlers.Add(this); base.OnNavigatedTo(e); ViewModel = FavoritesVM.GetVM(e.Parameter?.ToString()); ViewModel.SetQueryWithSearchResult(); ViewModel.Search.Executed += Search_Executed; await Dispatcher.YieldIdle(); if (e.NavigationMode == NavigationMode.New) { if (e.Parameter != null) { ViewModel.SearchResult.Reset(); } cbCategory.Focus(FocusState.Programmatic); } else if (e.NavigationMode == NavigationMode.Back) { if (!await ViewHelper.ScrollAndFocus(lv, ViewModel.SelectedGallery)) { cbCategory.Focus(FocusState.Programmatic); } } }
private static IAsyncAction handle(Uri uri) { return(AsyncInfo.Run(async token => { try { var r = await UriLauncher.HandleAsync(uri); switch (r) { case GalleryLaunchResult g: { var page = RootControl.RootController.Frame.Content; var vm = await GalleryVM.GetVMAsync(g.GalleryInfo); if (!(page is GalleryPage gPage && gPage.ViewModel.Gallery.ID == g.GalleryInfo.ID)) { await RootControl.RootController.Navigator.NavigateAsync(typeof(GalleryPage), g.GalleryInfo.ID); await Task.Delay(500); } switch (g.Status) { case GalleryLaunchStatus.Image: vm.View.MoveCurrentToPosition(g.CurrentIndex); await RootControl.RootController.Navigator.NavigateAsync(typeof(ImagePage), g.GalleryInfo.ID); break; case GalleryLaunchStatus.Torrent: (RootControl.RootController.Frame.Content as GalleryPage)?.ChangePivotSelection(2); break; default: (RootControl.RootController.Frame.Content as GalleryPage)?.ChangePivotSelection(0); break; } return; } case SearchLaunchResult sr: switch (sr.Data) { case CategorySearchResult ksr: var vm = SearchVM.GetVM(ksr); await RootControl.RootController.Navigator.NavigateAsync(typeof(SearchPage), vm.SearchQuery); return; case FavoritesSearchResult fsr: var fvm = FavoritesVM.GetVM(fsr); await RootControl.RootController.Navigator.NavigateAsync(typeof(FavoritesPage), fvm.SearchQuery); return; } throw new InvalidOperationException(); } } catch (Exception e) { RootControl.RootController.SendToast(e, null); } })); }