public override Task OnNavigatedToAsync(INavigationParameters parameters) { var mode = parameters.GetNavigationMode(); if (mode == NavigationMode.New) { SearchOption = new TagSearchPagePayloadContent() { Keyword = System.Net.WebUtility.UrlDecode(parameters.GetValue <string>("keyword")) }; } SelectedSearchTarget.Value = SearchTarget.Tag; SelectedSearchSort.Value = VideoSearchOptionListItems.First(x => x.Sort == SearchOption.Sort && x.Order == SearchOption.Order); Database.SearchHistoryDb.Searched(SearchOption.Keyword, SearchOption.SearchTarget); TagSearchBookmark = Database.BookmarkDb.Get(Database.BookmarkType.SearchWithTag, SearchOption.Keyword) ?? new Database.Bookmark() { BookmarkType = Database.BookmarkType.SearchWithTag, Label = SearchOption.Keyword, Content = SearchOption.Keyword }; FollowButtonService.SetFollowTarget(this); RaisePropertyChanged(nameof(TagSearchBookmark)); PageManager.PageTitle = $"\"{SearchOption.Keyword}\""; return(base.OnNavigatedToAsync(parameters)); }
public override Task OnNavigatedToAsync(INavigationParameters parameters) { var mode = parameters.GetNavigationMode(); if (mode == NavigationMode.New) { Keyword = System.Net.WebUtility.UrlDecode(parameters.GetValue <string>("keyword")); SearchOption = new KeywordSearchPagePayloadContent() { Keyword = Keyword }; } SelectedSearchTarget.Value = SearchTarget.Keyword; SelectedSearchSort.Value = VideoSearchOptionListItems.First(x => x.Sort == SearchOption.Sort && x.Order == SearchOption.Order); KeywordSearchBookmark = Database.BookmarkDb.Get(Database.BookmarkType.SearchWithKeyword, SearchOption.Keyword) ?? new Database.Bookmark() { BookmarkType = Database.BookmarkType.SearchWithKeyword, Label = SearchOption.Keyword, Content = SearchOption.Keyword }; RaisePropertyChanged(nameof(KeywordSearchBookmark)); Database.SearchHistoryDb.Searched(SearchOption.Keyword, SearchOption.SearchTarget); return(base.OnNavigatedToAsync(parameters)); }
public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState) { if (e.Parameter is string) { SearchOption = PagePayloadBase.FromParameterString <KeywordSearchPagePayloadContent>(e.Parameter as string); } SelectedSearchTarget.Value = SearchOption?.SearchTarget ?? SearchTarget.Keyword; if (SearchOption == null) { throw new Exception(""); } SelectedSearchSort.Value = VideoSearchOptionListItems.First(x => x.Sort == SearchOption.Sort && x.Order == SearchOption.Order); KeywordSearchBookmark = Database.BookmarkDb.Get(Database.BookmarkType.SearchWithKeyword, SearchOption.Keyword) ?? new Database.Bookmark() { BookmarkType = Database.BookmarkType.SearchWithKeyword, Label = SearchOption.Keyword, Content = SearchOption.Keyword }; RaisePropertyChanged(nameof(KeywordSearchBookmark)); SearchOptionText = Helpers.SortHelper.ToCulturizedText(SearchOption.Sort, SearchOption.Order); Database.SearchHistoryDb.Searched(SearchOption.Keyword, SearchOption.SearchTarget); base.OnNavigatedTo(e, viewModelState); }
public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState) { if (e.Parameter is string && e.NavigationMode == NavigationMode.New) { SearchOption = PagePayloadBase.FromParameterString <TagSearchPagePayloadContent>(e.Parameter as string); } SelectedSearchTarget.Value = SearchOption?.SearchTarget ?? SearchTarget.Tag; SelectedSearchSort.Value = VideoSearchOptionListItems.First(x => x.Sort == SearchOption.Sort && x.Order == SearchOption.Order); Database.SearchHistoryDb.Searched(SearchOption.Keyword, SearchOption.SearchTarget); TagSearchBookmark = Database.BookmarkDb.Get(Database.BookmarkType.SearchWithTag, SearchOption.Keyword) ?? new Database.Bookmark() { BookmarkType = Database.BookmarkType.SearchWithTag, Label = SearchOption.Keyword, Content = SearchOption.Keyword }; FollowButtonService.SetFollowTarget(this); RaisePropertyChanged(nameof(TagSearchBookmark)); base.OnNavigatedTo(e, viewModelState); }
public SearchResultTagPageViewModel( ApplicationLayoutManager applicationLayoutManager, NGSettings ngSettings, Models.NiconicoSession niconicoSession, SearchProvider searchProvider, SubscriptionManager subscriptionManager, HohoemaPlaylist hohoemaPlaylist, Services.PageManager pageManager, Services.DialogService dialogService, Commands.Subscriptions.CreateSubscriptionGroupCommand createSubscriptionGroupCommand, NiconicoFollowToggleButtonService followButtonService ) { SearchProvider = searchProvider; SubscriptionManager = subscriptionManager; HohoemaPlaylist = hohoemaPlaylist; PageManager = pageManager; ApplicationLayoutManager = applicationLayoutManager; NgSettings = ngSettings; NiconicoSession = niconicoSession; HohoemaDialogService = dialogService; CreateSubscriptionGroupCommand = createSubscriptionGroupCommand; FollowButtonService = followButtonService; FailLoading = new ReactiveProperty <bool>(false) .AddTo(_CompositeDisposable); LoadedPage = new ReactiveProperty <int>(1) .AddTo(_CompositeDisposable); SelectedSearchSort = new ReactiveProperty <SearchSortOptionListItem>( VideoSearchOptionListItems.First(), mode: ReactivePropertyMode.DistinctUntilChanged ); SelectedSearchSort .Subscribe(async _ => { var selected = SelectedSearchSort.Value; if (SearchOption.Order == selected.Order && SearchOption.Sort == selected.Sort ) { return; } SearchOption.Order = selected.Order; SearchOption.Sort = selected.Sort; await ResetList(); }) .AddTo(_CompositeDisposable); SelectedSearchTarget = new ReactiveProperty <SearchTarget>(); }
public SearchResultKeywordPageViewModel( ApplicationLayoutManager applicationLayoutManager, NGSettings ngSettings, SearchProvider searchProvider, SubscriptionManager subscriptionManager, HohoemaPlaylist hohoemaPlaylist, Services.PageManager pageManager, Commands.Subscriptions.CreateSubscriptionGroupCommand createSubscriptionGroupCommand ) { FailLoading = new ReactiveProperty <bool>(false) .AddTo(_CompositeDisposable); LoadedPage = new ReactiveProperty <int>(1) .AddTo(_CompositeDisposable); SelectedSearchSort = new ReactiveProperty <SearchSortOptionListItem>( VideoSearchOptionListItems.First(), mode: ReactivePropertyMode.DistinctUntilChanged ); SelectedSearchTarget = new ReactiveProperty <SearchTarget>(); SelectedSearchSort .Subscribe(async _ => { var selected = SelectedSearchSort.Value; if (SearchOption.Order == selected.Order && SearchOption.Sort == selected.Sort ) { // return; } SearchOption.Sort = SelectedSearchSort.Value.Sort; SearchOption.Order = SelectedSearchSort.Value.Order; await ResetList(); }) .AddTo(_CompositeDisposable); ApplicationLayoutManager = applicationLayoutManager; NgSettings = ngSettings; SearchProvider = searchProvider; HohoemaPlaylist = hohoemaPlaylist; PageManager = pageManager; SubscriptionManager = subscriptionManager; CreateSubscriptionGroupCommand = createSubscriptionGroupCommand; }
public SearchResultKeywordPageViewModel( HohoemaApp hohoemaApp, PageManager pageManager ) : base(hohoemaApp, pageManager, useDefaultPageTitle: false) { _ContentFinder = HohoemaApp.ContentProvider; FailLoading = new ReactiveProperty <bool>(false) .AddTo(_CompositeDisposable); LoadedPage = new ReactiveProperty <int>(1) .AddTo(_CompositeDisposable); SelectedSearchSort = new ReactiveProperty <SearchSortOptionListItem>( VideoSearchOptionListItems.First(), mode: ReactivePropertyMode.DistinctUntilChanged ); SelectedSearchTarget = new ReactiveProperty <SearchTarget>(); SelectedSearchSort .Subscribe(async _ => { var selected = SelectedSearchSort.Value; if (SearchOption.Order == selected.Order && SearchOption.Sort == selected.Sort ) { return; } SearchOption.Sort = SelectedSearchSort.Value.Sort; SearchOption.Order = SelectedSearchSort.Value.Order; pageManager.Search(SearchOption, forgetLastSearch: true); }) .AddTo(_CompositeDisposable); }
public SearchResultTagPageViewModel( HohoemaApp hohoemaApp, PageManager pageManager, Services.HohoemaDialogService dialogService ) : base(hohoemaApp, pageManager, useDefaultPageTitle: false) { _ContentFinder = HohoemaApp.ContentProvider; _HohoemaDialogService = dialogService; FailLoading = new ReactiveProperty <bool>(false) .AddTo(_CompositeDisposable); LoadedPage = new ReactiveProperty <int>(1) .AddTo(_CompositeDisposable); IsFavoriteTag = new ReactiveProperty <bool>(mode: ReactivePropertyMode.DistinctUntilChanged) .AddTo(_CompositeDisposable); CanChangeFavoriteTagState = new ReactiveProperty <bool>() .AddTo(_CompositeDisposable); AddFavoriteTagCommand = CanChangeFavoriteTagState .ToReactiveCommand() .AddTo(_CompositeDisposable); RemoveFavoriteTagCommand = IsFavoriteTag .ToReactiveCommand() .AddTo(_CompositeDisposable); IsFavoriteTag.Subscribe(async x => { if (_NowProcessFavorite) { return; } _NowProcessFavorite = true; CanChangeFavoriteTagState.Value = false; if (x) { if (await FavoriteTag()) { Debug.WriteLine(SearchOption.Keyword + "のタグをお気に入り登録しました."); } else { // お気に入り登録に失敗した場合は状態を差し戻し Debug.WriteLine(SearchOption.Keyword + "のタグをお気に入り登録に失敗"); IsFavoriteTag.Value = false; } } else { if (await UnfavoriteTag()) { Debug.WriteLine(SearchOption.Keyword + "のタグをお気に入り解除しました."); } else { // お気に入り解除に失敗した場合は状態を差し戻し Debug.WriteLine(SearchOption.Keyword + "のタグをお気に入り解除に失敗"); IsFavoriteTag.Value = true; } } CanChangeFavoriteTagState.Value = IsFavoriteTag.Value == true || HohoemaApp.FollowManager.CanMoreAddFollow(FollowItemType.Tag); _NowProcessFavorite = false; }) .AddTo(_CompositeDisposable); SelectedSearchSort = new ReactiveProperty <SearchSortOptionListItem>( VideoSearchOptionListItems.First(), mode: ReactivePropertyMode.DistinctUntilChanged ); SelectedSearchSort .Subscribe(_ => { var selected = SelectedSearchSort.Value; if (SearchOption.Order == selected.Order && SearchOption.Sort == selected.Sort ) { return; } SearchOption.Sort = SelectedSearchSort.Value.Sort; SearchOption.Order = SelectedSearchSort.Value.Order; pageManager.Search(SearchOption, forgetLastSearch: true); }) .AddTo(_CompositeDisposable); SelectedSearchTarget = new ReactiveProperty <SearchTarget>(); }