public NicoRepoPageViewModel(

            Services.HohoemaPlaylist hohoemaPlaylist,
            Services.PageManager pageManager,
            ActivityFeedSettings activityFeedSettings,
            Models.Provider.LoginUserNicoRepoProvider loginUserNicoRepoProvider,
            Models.Subscription.SubscriptionManager subscriptionManager
            )
            : base(pageManager, useDefaultPageTitle: true)
        {
            HohoemaPlaylist           = hohoemaPlaylist;
            ActivityFeedSettings      = activityFeedSettings;
            LoginUserNicoRepoProvider = loginUserNicoRepoProvider;
            SubscriptionManager       = subscriptionManager;
            DisplayNicoRepoItemTopics = ActivityFeedSettings.DisplayNicoRepoItemTopics.ToList();

            /*
             * DisplayNicoRepoItemTopics.CollectionChangedAsObservable()
             *  .Throttle(TimeSpan.FromSeconds(1))
             *  .Subscribe(async _ =>
             *  {
             *      await HohoemaApp.UIDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
             *      {
             *          await ResetList();
             *      });
             *  });
             */
        }
Exemple #2
0
        public NicoRepoPageViewModel(
            IScheduler scheduler,
            ApplicationLayoutManager applicationLayoutManager,
            HohoemaPlaylist hohoemaPlaylist,
            Services.PageManager pageManager,
            ActivityFeedSettings activityFeedSettings,
            Models.Provider.LoginUserNicoRepoProvider loginUserNicoRepoProvider,
            Models.Subscription.SubscriptionManager subscriptionManager,
            OpenLiveContentCommand openLiveContentCommand
            )
        {
            _scheduler = scheduler;
            ApplicationLayoutManager  = applicationLayoutManager;
            HohoemaPlaylist           = hohoemaPlaylist;
            ActivityFeedSettings      = activityFeedSettings;
            LoginUserNicoRepoProvider = loginUserNicoRepoProvider;
            SubscriptionManager       = subscriptionManager;
            _openLiveContentCommand   = openLiveContentCommand;
            DisplayNicoRepoItemTopics = new ObservableCollection <NicoRepoItemTopic>(ActivityFeedSettings.DisplayNicoRepoItemTopics);

            DisplayNicoRepoItemTopics.CollectionChangedAsObservable()
            .Subscribe(_ =>
            {
                _NicoRepoItemTopicsChanged = true;
            })
            .AddTo(_CompositeDisposable);
        }
        public SubscriptionPageViewModel(
            SubscriptionManager subscriptionManager,
            Services.PageManager pageManager,
            Services.WatchItLater watchItLater
            )
            : base(pageManager)
        {
            SubscriptionManager = subscriptionManager;
            WatchItLater        = watchItLater;

            SelectedSubscription = new ReactiveProperty <Subscription>()
                                   .AddTo(_CompositeDisposable);

            SubscriptionManager.Subscriptions.ObserveAddChanged()
            .Subscribe(item =>
            {
                if (_prevRemovedSubscriptionId == item.Id)
                {
                    return;
                }

                SelectedSubscription.Value = item;
            })
            .AddTo(_CompositeDisposable);

            SubscriptionManager.Subscriptions.ObserveRemoveChanged()
            .Subscribe(item =>
            {
                SelectedSubscription.Value = SelectedSubscription.Value == item ? null : SelectedSubscription.Value;

                _prevRemovedSubscriptionId = item.Id;
            })
            .AddTo(_CompositeDisposable);
        }
Exemple #4
0
        static public async Task <CommunityNewsViewModel> Create(
            string communityId,
            string title,
            string authorName,
            DateTime postAt,
            string contentHtml,
            Services.PageManager pageManager,
            AppearanceSettings appearanceSettings
            )
        {
            ApplicationTheme appTheme;

            if (appearanceSettings.Theme == ElementTheme.Dark)
            {
                appTheme = ApplicationTheme.Dark;
            }
            else if (appearanceSettings.Theme == ElementTheme.Light)
            {
                appTheme = ApplicationTheme.Light;
            }
            else
            {
                appTheme = Views.Helpers.SystemThemeHelper.GetSystemTheme();
            }

            var id  = $"{communityId}_{postAt.ToString("yy-MM-dd-H-mm")}";
            var uri = await Models.Helpers.HtmlFileHelper.PartHtmlOutputToCompletlyHtml(id, contentHtml, appTheme);

            return(new CommunityNewsViewModel(communityId, title, authorName, postAt, uri, pageManager));
        }
        public HohoemaListingPageViewModelBase(
            Services.PageManager pageManager,
            bool useDefaultPageTitle = true
            )
            : base(pageManager)
        {
            NowLoading = new ReactiveProperty <bool>(true)
                         .AddTo(_CompositeDisposable);

            HasItem = new ReactiveProperty <bool>(true);

            HasError = new ReactiveProperty <bool>(false);

            MaxItemsCount = new ReactiveProperty <int>(0)
                            .AddTo(_CompositeDisposable);
            LoadedItemsCount = new ReactiveProperty <int>(0)
                               .AddTo(_CompositeDisposable);

            NowRefreshable = new ReactiveProperty <bool>(false);

            ScrollPosition = new ReactiveProperty <double>();

            // 読み込み厨または選択中はソートを変更できない
            CanChangeSort = Observable.CombineLatest(
                NowLoading
                )
                            .Select(x => !x.Any(y => y))
                            .ToReactiveProperty()
                            .AddTo(_CompositeDisposable);
        }
Exemple #6
0
 public SplashPageViewModel(
     INavigationService ns,
     Services.PageManager pageManager
     )
 {
     PageManager       = pageManager;
     NavigationService = ns;
 }
        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 CommunityVideoPageViewModel(
     ApplicationLayoutManager applicationLayoutManager,
     CommunityProvider communityProvider,
     Services.PageManager pageManager
     )
 {
     ApplicationLayoutManager = applicationLayoutManager;
     CommunityProvider        = communityProvider;
     PageManager = pageManager;
 }
 public CommunityVideoPageViewModel(
     CommunityProvider communityProvider,
     Services.PageManager pageManager,
     Services.HohoemaPlaylist hohoemaPlaylist
     )
     : base(pageManager)
 {
     CommunityProvider = communityProvider;
     HohoemaPlaylist   = hohoemaPlaylist;
 }
Exemple #10
0
 public SearchResultMylistPageViewModel(
     SearchProvider searchProvider,
     Services.PageManager pageManager
     )
     : base(pageManager, useDefaultPageTitle: false)
 {
     SelectedSearchSort   = new ReactivePropertySlim <SearchSortOptionListItem>();
     SelectedSearchTarget = new ReactiveProperty <SearchTarget>();
     SearchProvider       = searchProvider;
 }
Exemple #11
0
 public SearchResultMylistPageViewModel(
     ApplicationLayoutManager applicationLayoutManager,
     SearchProvider searchProvider,
     Services.PageManager pageManager
     )
 {
     SelectedSearchSort       = new ReactivePropertySlim <SearchSortOptionListItem>();
     SelectedSearchTarget     = new ReactiveProperty <SearchTarget>();
     ApplicationLayoutManager = applicationLayoutManager;
     SearchProvider           = searchProvider;
     PageManager = pageManager;
 }
Exemple #12
0
 public RecommendPageViewModel(
     NGSettings ngSettings,
     LoginUserRecommendProvider loginUserRecommendProvider,
     Services.HohoemaPlaylist hohoemaPlaylist,
     Services.PageManager pageManager
     )
     : base(pageManager)
 {
     NgSettings = ngSettings;
     LoginUserRecommendProvider = loginUserRecommendProvider;
     HohoemaPlaylist            = hohoemaPlaylist;
 }
Exemple #13
0
        public SearchResultLivePageViewModel(
            ApplicationLayoutManager applicationLayoutManager,
            Models.NiconicoSession niconicoSession,
            SearchProvider searchProvider,
            Services.PageManager pageManager,
            HohoemaPlaylist hohoemaPlaylist,
            OpenLiveContentCommand openLiveContentCommand
            )
        {
            SelectedSearchSort = new ReactiveProperty <LiveSearchSortOptionListItem>(LiveSearchSortOptionListItems[0], mode: ReactivePropertyMode.DistinctUntilChanged);
            SelectedSearchMode = new ReactiveProperty <LiveSearchModeOptionListItem>(LiveSearchModeOptionListItems[0], mode: ReactivePropertyMode.DistinctUntilChanged);
            SelectedProvider   = new ReactiveProperty <LiveSearchProviderOptionListItem>(LiveSearchProviderOptionListItems[0], mode: ReactivePropertyMode.DistinctUntilChanged);

            SelectedSearchTarget = new ReactiveProperty <SearchTarget>();

            Observable.Merge(
                SelectedSearchSort.ToUnit(),
                SelectedSearchMode.ToUnit(),
                SelectedProvider.ToUnit()
                )
            .Subscribe(async _ =>
            {
                if (_NowNavigatingTo)
                {
                    return;
                }

                var selected = SelectedSearchSort.Value;
                if (SearchOption.Order == selected.Order &&
                    SearchOption.Sort == selected.Sort &&
                    SearchOption.Mode == SelectedSearchMode.Value?.Mode &&
                    SearchOption.Provider == SelectedProvider.Value?.Provider
                    )
                {
                    return;
                }

                SearchOption.Mode     = SelectedSearchMode.Value.Mode;
                SearchOption.Provider = SelectedProvider.Value.Provider;
                SearchOption.Sort     = SelectedSearchSort.Value.Sort;
                SearchOption.Order    = SelectedSearchSort.Value.Order;

                await ResetList();
            })
            .AddTo(_CompositeDisposable);
            ApplicationLayoutManager = applicationLayoutManager;
            NiconicoSession          = niconicoSession;
            SearchProvider           = searchProvider;
            PageManager            = pageManager;
            HohoemaPlaylist        = hohoemaPlaylist;
            OpenLiveContentCommand = openLiveContentCommand;
        }
        static public async Task <CommunityNewsViewModel> Create(
            string communityId,
            string title,
            string authorName,
            DateTime postAt,
            string contentHtml,
            Services.PageManager pageManager
            )
        {
            var id  = $"{communityId}_{postAt.ToString("yy-MM-dd-H-mm")}";
            var uri = await Models.Helpers.HtmlFileHelper.PartHtmlOutputToCompletlyHtml(id, contentHtml);

            return(new CommunityNewsViewModel(communityId, title, authorName, postAt, uri, pageManager));
        }
Exemple #15
0
 public UserVideoPageViewModel(
     UserProvider userProvider,
     Models.Subscription.SubscriptionManager subscriptionManager,
     Services.HohoemaPlaylist hohoemaPlaylist,
     Services.PageManager pageManager,
     Commands.Subscriptions.CreateSubscriptionGroupCommand createSubscriptionGroupCommand
     )
 {
     SubscriptionManager            = subscriptionManager;
     UserProvider                   = userProvider;
     HohoemaPlaylist                = hohoemaPlaylist;
     PageManager                    = pageManager;
     CreateSubscriptionGroupCommand = createSubscriptionGroupCommand;
 }
 public CommunityPageViewModel(Services.PageManager pageManager,
                               NiconicoSession niconicoSession,
                               CommunityFollowProvider followProvider,
                               CommunityProvider communityProvider,
                               FollowManager followManager,
                               NiconicoFollowToggleButtonService followToggleButtonService
                               )
     : base(pageManager)
 {
     NiconicoSession           = niconicoSession;
     FollowProvider            = followProvider;
     CommunityProvider         = communityProvider;
     FollowToggleButtonService = followToggleButtonService;
 }
Exemple #17
0
 public RecommendPageViewModel(
     ApplicationLayoutManager applicationLayoutManager,
     NGSettings ngSettings,
     LoginUserRecommendProvider loginUserRecommendProvider,
     HohoemaPlaylist hohoemaPlaylist,
     Services.PageManager pageManager
     )
 {
     ApplicationLayoutManager = applicationLayoutManager;
     NgSettings = ngSettings;
     LoginUserRecommendProvider = loginUserRecommendProvider;
     HohoemaPlaylist            = hohoemaPlaylist;
     PageManager = pageManager;
 }
 public TimeshiftPageViewModel(
     LoginUserLiveReservationProvider loginUserLiveReservationProvider,
     NicoLiveProvider nicoLiveProvider,
     Services.HohoemaPlaylist hohoemaPlaylist,
     Services.PageManager pageManager,
     Services.DialogService dialogService
     )
     : base(pageManager, useDefaultPageTitle: true)
 {
     LoginUserLiveReservationProvider = loginUserLiveReservationProvider;
     NicoLiveProvider = nicoLiveProvider;
     HohoemaPlaylist  = hohoemaPlaylist;
     DialogService    = dialogService;
 }
Exemple #19
0
        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;
        }
Exemple #20
0
 private CommunityNewsViewModel(
     string communityId,
     string title,
     string authorName,
     DateTime postAt,
     Uri htmlUri,
     Services.PageManager pageManager
     )
 {
     CommunityId        = communityId;
     Title              = title;
     AuthorName         = authorName;
     PostAt             = postAt;
     ContentHtmlFileUri = htmlUri;
     PageManager        = pageManager;
 }
Exemple #21
0
 public ChannelVideoPageViewModel(
     NiconicoSession niconicoSession,
     Models.Provider.ChannelProvider channelProvider,
     Services.PageManager pageManager,
     Services.HohoemaPlaylist hohoemaPlaylist,
     Services.ExternalAccessService externalAccessService,
     Services.NiconicoFollowToggleButtonService followToggleButtonService
     )
 {
     NiconicoSession           = niconicoSession;
     ChannelProvider           = channelProvider;
     PageManager               = pageManager;
     HohoemaPlaylist           = hohoemaPlaylist;
     ExternalAccessService     = externalAccessService;
     FollowToggleButtonService = followToggleButtonService;
 }
Exemple #22
0
 public WatchHistoryPageViewModel(
     ApplicationLayoutManager applicationLayoutManager,
     NiconicoSession niconicoSession,
     WatchHistoryManager watchHistoryManager,
     HohoemaPlaylist hohoemaPlaylist,
     Services.PageManager pageManager,
     WatchHistoryRemoveAllCommand watchHistoryRemoveAllCommand
     )
 {
     ApplicationLayoutManager = applicationLayoutManager;
     _niconicoSession         = niconicoSession;
     _watchHistoryManager     = watchHistoryManager;
     HohoemaPlaylist          = hohoemaPlaylist;
     PageManager = pageManager;
     WatchHistoryRemoveAllCommand = watchHistoryRemoveAllCommand;
     Histories = new ObservableCollection <HistoryVideoInfoControlViewModel>();
 }
        public WatchHistoryPageViewModel(
            LoginUserHistoryProvider loginUserHistoryProvider,
            Services.HohoemaPlaylist hohoemaPlaylist,
            Services.PageManager pageManager
            )
        {
            LoginUserHistoryProvider = loginUserHistoryProvider;
            HohoemaPlaylist          = hohoemaPlaylist;
            PageManager = pageManager;
            Histories   = new ObservableCollection <HistoryVideoInfoControlViewModel>();

            Histories.ObserveElementPropertyChanged()
            .Where(x => x.EventArgs.PropertyName == nameof(HistoryVideoInfoControlViewModel.IsRemoved))
            .Where(x => x.Sender.IsRemoved)
            .Subscribe(x => Histories.Remove(x.Sender))
            .AddTo(_CompositeDisposable);
        }
Exemple #24
0
 public CommunityPageViewModel(
     ApplicationLayoutManager applicationLayoutManager,
     AppearanceSettings appearanceSettings,
     Services.PageManager pageManager,
     NiconicoSession niconicoSession,
     CommunityFollowProvider followProvider,
     CommunityProvider communityProvider,
     FollowManager followManager,
     NiconicoFollowToggleButtonService followToggleButtonService
     )
 {
     ApplicationLayoutManager = applicationLayoutManager;
     _appearanceSettings      = appearanceSettings;
     PageManager               = pageManager;
     NiconicoSession           = niconicoSession;
     FollowProvider            = followProvider;
     CommunityProvider         = communityProvider;
     FollowToggleButtonService = followToggleButtonService;
 }
 public VideoInfomationPageViewModel(
     ApplicationLayoutManager applicationLayoutManager,
     AppearanceSettings appearanceSettings,
     NGSettings ngSettings,
     Models.NiconicoSession niconicoSession,
     UserMylistManager userMylistManager,
     HohoemaPlaylist hohoemaPlaylist,
     NicoVideoProvider nicoVideoProvider,
     LoginUserMylistProvider loginUserMylistProvider,
     VideoCacheManager videoCacheManager,
     SubscriptionManager subscriptionManager,
     Models.NicoVideoSessionProvider nicoVideo,
     Services.PageManager pageManager,
     Services.NotificationService notificationService,
     Services.DialogService dialogService,
     Services.ExternalAccessService externalAccessService,
     AddMylistCommand addMylistCommand,
     Commands.Subscriptions.CreateSubscriptionGroupCommand createSubscriptionGroupCommand
     )
 {
     ApplicationLayoutManager = applicationLayoutManager;
     _appearanceSettings      = appearanceSettings;
     NgSettings              = ngSettings;
     NiconicoSession         = niconicoSession;
     UserMylistManager       = userMylistManager;
     HohoemaPlaylist         = hohoemaPlaylist;
     NicoVideoProvider       = nicoVideoProvider;
     LoginUserMylistProvider = loginUserMylistProvider;
     VideoCacheManager       = videoCacheManager;
     SubscriptionManager     = subscriptionManager;
     NicoVideo                      = nicoVideo;
     PageManager                    = pageManager;
     NotificationService            = notificationService;
     DialogService                  = dialogService;
     ExternalAccessService          = externalAccessService;
     AddMylistCommand               = addMylistCommand;
     CreateSubscriptionGroupCommand = createSubscriptionGroupCommand;
     NowLoading                     = new ReactiveProperty <bool>(false);
     IsLoadFailed                   = new ReactiveProperty <bool>(false);
 }
Exemple #26
0
 public VideoInfomationPageViewModel(
     NGSettings ngSettings,
     Models.NiconicoSession niconicoSession,
     UserMylistManager userMylistManager,
     Services.HohoemaPlaylist hohoemaPlaylist,
     NicoVideoProvider nicoVideoProvider,
     LoginUserMylistProvider loginUserMylistProvider,
     VideoCacheManager videoCacheManager,
     Models.NicoVideoStreamingSessionProvider nicoVideo,
     Services.Helpers.MylistHelper mylistHelper,
     Services.PageManager pageManager,
     Services.NotificationService notificationService,
     Services.DialogService dialogService,
     Services.ExternalAccessService externalAccessService,
     Commands.AddMylistCommand addMylistCommand,
     Commands.Subscriptions.CreateSubscriptionGroupCommand createSubscriptionGroupCommand
     )
     : base(pageManager)
 {
     NgSettings              = ngSettings;
     NiconicoSession         = niconicoSession;
     UserMylistManager       = userMylistManager;
     HohoemaPlaylist         = hohoemaPlaylist;
     NicoVideoProvider       = nicoVideoProvider;
     LoginUserMylistProvider = loginUserMylistProvider;
     VideoCacheManager       = videoCacheManager;
     NicoVideo                      = nicoVideo;
     MylistHelper                   = mylistHelper;
     NotificationService            = notificationService;
     DialogService                  = dialogService;
     ExternalAccessService          = externalAccessService;
     AddMylistCommand               = addMylistCommand;
     CreateSubscriptionGroupCommand = createSubscriptionGroupCommand;
     NowLoading                     = new ReactiveProperty <bool>(false);
     IsLoadFailed                   = new ReactiveProperty <bool>(false);
 }
Exemple #27
0
        public RankingCategoryListPageViewModel(
            Services.PageManager pageManager,
            Services.DialogService dialogService,
            RankingSettings rankingSettings
            )
            : base(pageManager)
        {
            HohoemaDialogService = dialogService;
            RankingSettings      = rankingSettings;


            Func <RankingCategory, bool> checkFavorite = (RankingCategory cat) =>
            {
                return(RankingSettings.HighPriorityCategory.Any(x => x.Category == cat));
            };


            RankingCategoryItems         = new ObservableCollection <RankingCategoryHostListItem>();
            FavoriteRankingCategoryItems = new ObservableCollection <RankingCategoryListPageListItem>();

            SelectedRankingCategory = new ReactiveProperty <RankingCategoryListPageListItem>();

            AddFavRankingCategory = new DelegateCommand(async() =>
            {
                var items = new AdvancedCollectionView();
                items.SortDescriptions.Add(new SortDescription("IsFavorit", SortDirection.Descending));
                items.SortDescriptions.Add(new SortDescription("Category", SortDirection.Ascending));

                var highPriCat = RankingSettings.HighPriorityCategory;
                var lowPriCat  = RankingSettings.LowPriorityCategory;
                foreach (var i in RankingSettings.HighPriorityCategory)
                {
                    items.Add(new CategoryWithFav()
                    {
                        Category = i.Category, IsFavorit = true
                    });
                }

                var middleRankingCategories = Enum.GetValues(typeof(RankingCategory)).Cast <RankingCategory>()
                                              .Where(x => !highPriCat.Any(h => x == h.Category))
                                              .Where(x => !lowPriCat.Any(l => x == l.Category))
                ;
                foreach (var category in middleRankingCategories)
                {
                    items.Add(new CategoryWithFav()
                    {
                        Category = category
                    });
                }
                items.Refresh();

                var choiceItems = await HohoemaDialogService.ShowMultiChoiceDialogAsync(
                    "優先表示にするカテゴリを選択",
                    items.Cast <CategoryWithFav>().Select(x => new RankingCategoryInfo(x.Category)),
                    RankingSettings.HighPriorityCategory.ToArray(),
                    x => x.DisplayLabel
                    );

                if (choiceItems == null)
                {
                    return;
                }

                // choiceItemsに含まれるカテゴリをMiddleとLowから削除
                RankingSettings.ResetFavoriteCategory();

                // HighにchoiceItemsを追加(重複しないよう注意)
                foreach (var cat in choiceItems)
                {
                    RankingSettings.AddFavoritCategory(cat.Category);
                }

                await RankingSettings.Save();

                ResetRankingCategoryItems();
            });



            AddDislikeRankingCategory = new DelegateCommand(async() =>
            {
                var items = new AdvancedCollectionView();
                items.SortDescriptions.Add(new SortDescription("IsFavorit", SortDirection.Descending));
                items.SortDescriptions.Add(new SortDescription("Category", SortDirection.Ascending));

                var highPriCat = RankingSettings.HighPriorityCategory;
                var lowPriCat  = RankingSettings.LowPriorityCategory;
                foreach (var i in lowPriCat)
                {
                    items.Add(new CategoryWithFav()
                    {
                        Category = i.Category, IsFavorit = true
                    });
                }
                var middleRankingCategories = Enum.GetValues(typeof(RankingCategory)).Cast <RankingCategory>()
                                              .Where(x => !highPriCat.Any(h => x == h.Category))
                                              .Where(x => !lowPriCat.Any(l => x == l.Category))
                ;
                foreach (var category in middleRankingCategories)
                {
                    items.Add(new CategoryWithFav()
                    {
                        Category = category
                    });
                }
                items.Refresh();

                var choiceItems = await HohoemaDialogService.ShowMultiChoiceDialogAsync(
                    "非表示にするカテゴリを選択",
                    items.Cast <CategoryWithFav>().Select(x => new RankingCategoryInfo(x.Category)),
                    RankingSettings.LowPriorityCategory,
                    x => x.DisplayLabel
                    );

                if (choiceItems == null)
                {
                    return;
                }

                // choiceItemsに含まれるカテゴリをMiddleとLowから削除
                RankingSettings.ResetDislikeCategory();

                // HighにchoiceItemsを追加(重複しないよう注意)
                foreach (var cat in choiceItems)
                {
                    RankingSettings.AddDislikeCategory(cat.Category);
                }

                await RankingSettings.Save();

                ResetRankingCategoryItems();
            });

            ResetRankingCategoryItems();
        }
        public MylistPageViewModel(
            Services.PageManager pageManager,
            NiconicoSession niconicoSession,
            MylistProvider mylistProvider,
            UserProvider userProvider,
            FollowManager followManager,
            LoginUserMylistProvider loginUserMylistProvider,
            NGSettings ngSettings,
            UserMylistManager userMylistManager,
            LocalMylistManager localMylistManager,
            Services.HohoemaPlaylist hohoemaPlaylist,
            SubscriptionManager subscriptionManager,
            Services.DialogService dialogService,
            NiconicoFollowToggleButtonService followToggleButtonService,
            Services.Helpers.MylistHelper mylistHelper,
            Commands.Subscriptions.CreateSubscriptionGroupCommand createSubscriptionGroupCommand
            )
            : base(pageManager)
        {
            NiconicoSession         = niconicoSession;
            MylistProvider          = mylistProvider;
            UserProvider            = userProvider;
            FollowManager           = followManager;
            LoginUserMylistProvider = loginUserMylistProvider;
            NgSettings                     = ngSettings;
            UserMylistManager              = userMylistManager;
            LocalMylistManager             = localMylistManager;
            HohoemaPlaylist                = hohoemaPlaylist;
            SubscriptionManager            = subscriptionManager;
            DialogService                  = dialogService;
            FollowToggleButtonService      = followToggleButtonService;
            MylistHelper                   = mylistHelper;
            CreateSubscriptionGroupCommand = createSubscriptionGroupCommand;
            Mylist       = new ReactiveProperty <Interfaces.IMylist>();
            MylistOrigin = new ReactiveProperty <Services.PlaylistOrigin>();

            /*
             * IsFavoriteMylist = new ReactiveProperty<bool>(mode: ReactivePropertyMode.DistinctUntilChanged)
             *  .AddTo(_CompositeDisposable);
             * CanChangeFavoriteMylistState = new ReactiveProperty<bool>()
             *  .AddTo(_CompositeDisposable);
             *
             *
             * IsFavoriteMylist
             *  .Where(x => PlayableList.Value.Id != null)
             *  .Subscribe(async x =>
             *  {
             *      if (PlayableList.Value.Origin != PlaylistOrigin.OtherUser) { return; }
             *
             *      if (_NowProcessFavorite) { return; }
             *
             *      _NowProcessFavorite = true;
             *
             *      CanChangeFavoriteMylistState.Value = false;
             *      if (x)
             *      {
             *          if (await FavoriteMylist())
             *          {
             *              Debug.WriteLine(_MylistTitle + "のマイリストをお気に入り登録しました.");
             *          }
             *          else
             *          {
             *              // お気に入り登録に失敗した場合は状態を差し戻し
             *              Debug.WriteLine(_MylistTitle + "のマイリストをお気に入り登録に失敗");
             *              IsFavoriteMylist.Value = false;
             *          }
             *      }
             *      else
             *      {
             *          if (await UnfavoriteMylist())
             *          {
             *              Debug.WriteLine(_MylistTitle + "のマイリストをお気に入り解除しました.");
             *          }
             *          else
             *          {
             *              // お気に入り解除に失敗した場合は状態を差し戻し
             *              Debug.WriteLine(_MylistTitle + "のマイリストをお気に入り解除に失敗");
             *              IsFavoriteMylist.Value = true;
             *          }
             *      }
             *
             *      CanChangeFavoriteMylistState.Value =
             *          IsFavoriteMylist.Value == true
             || FollowManager.CanMoreAddFollow(FollowItemType.Mylist);
             ||
             ||
             ||     _NowProcessFavorite = false;
             || })
             || .AddTo(_CompositeDisposable);
             ||
             ||
             ||UnregistrationMylistCommand = SelectedItems.ObserveProperty(x => x.Count)
             || .Where(_ => IsUserOwnerdMylist)
             || .Select(x => x > 0)
             || .ToReactiveCommand(false);
             ||
             ||UnregistrationMylistCommand.Subscribe(async _ =>
             ||{
             || if (PlayableList.Value.Origin == PlaylistOrigin.Local)
             || {
             ||     var localMylist = PlayableList.Value as LegacyLocalMylist;
             ||     var items = SelectedItems.ToArray();
             ||
             ||     foreach (var item in items)
             ||     {
             ||         localMylist.Remove(item.PlaylistItem);
             ||         IncrementalLoadingItems.Remove(item);
             ||     }
             || }
             || else if (PlayableList.Value.Origin == PlaylistOrigin.LoginUser)
             || {
             ||     var mylistGroup = HohoemaApp.UserMylistManager.GetMylistGroup(PlayableList.Value.Id);
             ||
             ||     var items = SelectedItems.ToArray();
             ||
             ||
             ||     var action = AsyncInfo.Run<uint>(async (cancelToken, progress) =>
             ||     {
             ||         uint progressCount = 0;
             ||         int successCount = 0;
             ||         int failedCount = 0;
             ||
             ||         Debug.WriteLine($"マイリストに追加解除を開始...");
             ||         foreach (var video in items)
             ||         {
             ||             var unregistrationResult = await mylistGroup.Unregistration(
             ||                 video.RawVideoId
             ||                 , withRefresh: false );
             ||
             ||             if (unregistrationResult == ContentManageResult.Success)
             ||             {
             ||                 successCount++;
             ||             }
             ||             else
             ||             {
             ||                 failedCount++;
             ||             }
             ||
             ||             progressCount++;
             ||             progress.Report(progressCount);
             ||
             ||             Debug.WriteLine($"{video.Label}[{video.RawVideoId}]:{unregistrationResult.ToString()}");
             ||         }
             ||
             ||         // 登録解除結果を得るためリフレッシュ
             ||         await mylistGroup.Refresh();
             ||
             ||
             ||         // ユーザーに結果を通知
             ||         var titleText = $"「{mylistGroup.Label}」から {successCount}件 の動画が登録解除されました";
             ||         var toastService = App.Current.Container.Resolve<NotificationService>();
             ||         var resultText = $"";
             ||         if (failedCount > 0)
             ||         {
             ||             resultText += $"\n登録解除に失敗した {failedCount}件 は選択されたままです";
             ||         }
             ||         toastService.ShowToast(titleText, resultText);
             ||
             ||         // 登録解除に失敗したアイテムだけを残すように
             ||         // マイリストから除外された動画を選択アイテムリストから削除
             ||         foreach (var item in SelectedItems.ToArray())
             ||         {
             ||             if (false == mylistGroup.CheckRegistratedVideoId(item.RawVideoId))
             ||             {
             ||                 SelectedItems.Remove(item);
             ||                 IncrementalLoadingItems.Remove(item);
             ||             }
             ||         }
             ||
             ||         Debug.WriteLine($"マイリストに追加解除完了---------------");
             ||     });
             ||
             ||     await PageManager.StartNoUIWork("マイリストに追加解除", items.Length, () => action);
             ||
             || }
             ||
             ||
             ||});
             ||
             ||
             */
        }
        public SearchPageViewModel(
            Models.NiconicoSession niconicoSession,
            SearchProvider searchProvider,
            Services.PageManager pageManager
            )
            : base(pageManager)
        {
            NiconicoSession = niconicoSession;
            SearchProvider = searchProvider;

            HashSet<string> HistoryKeyword = new HashSet<string>();
            foreach (var item in Database.SearchHistoryDb.GetAll().OrderByDescending(x => x.LastUpdated))
            {
                if (HistoryKeyword.Contains(item.Keyword))
                {
                    continue;
                }

                SearchHistoryItems.Add(new SearchHistoryListItem(item, this));
                HistoryKeyword.Add(item.Keyword);
            }

            SearchText = new ReactiveProperty<string>(_LastKeyword)
                .AddTo(_CompositeDisposable);

            TargetListItems = new List<SearchTarget>()
            {
                SearchTarget.Keyword,
                SearchTarget.Tag,
                SearchTarget.Niconama,
                SearchTarget.Mylist,
                SearchTarget.Community,
            };

            SelectedTarget = new ReactiveProperty<SearchTarget>(_LastSelectedTarget)
                .AddTo(_CompositeDisposable);

            SearchOptionVM = new ReactiveProperty<SearchOptionViewModelBase>();
            SearchOptionVMDict = new Dictionary<SearchTarget, SearchOptionViewModelBase>();

            SelectedTarget.Subscribe(x =>
            {
                RaiseSearchTargetFlags();

                var keyword = SearchOptionVM.Value?.Keyword ?? "";
                SearchOptionViewModelBase searchOptionVM = null;
                if (SearchOptionVMDict.ContainsKey(x))
                {
                    searchOptionVM = SearchOptionVMDict[x];
                }
                else
                {
                    searchOptionVM = SearchOptioniViewModelHelper.CreateFromTarget(x);
                    SearchOptionVMDict.Add(x, searchOptionVM);
                }

                searchOptionVM.Keyword = keyword;

                SearchOptionVM.Value = searchOptionVM;

            });



            DoSearchCommand =
                SearchText.Select(x => !String.IsNullOrEmpty(x))
                .ToReactiveCommand()
                .AddTo(_CompositeDisposable);

            SearchText.Subscribe(x =>
            {
                Debug.WriteLine($"検索:{x}");
            });


            DoSearchCommand.CanExecuteChangedAsObservable()
                .Subscribe(x =>
                {
                    Debug.WriteLine(DoSearchCommand.CanExecute());
                });
            DoSearchCommand.Subscribe(_ =>
            {
                if (SearchText.Value.Length == 0) { return; }

                // Note: Keywordの管理はSearchPage側で行うべき?
                SearchOptionVM.Value.Keyword = SearchText.Value;

                var searchOption = SearchOptionVM.Value.MakePayload();

                // 検索結果を表示
                PageManager.Search(searchOption);

                var searched = Database.SearchHistoryDb.Searched(SearchText.Value, SelectedTarget.Value);

                var oldSearchHistory = SearchHistoryItems.FirstOrDefault(x => x.Keyword == SearchText.Value);
                if (oldSearchHistory != null)
                {
                    SearchHistoryItems.Remove(oldSearchHistory);
                }
                SearchHistoryItems.Insert(0, new SearchHistoryListItem(searched, this));

            })
            .AddTo(_CompositeDisposable);
        }
Exemple #30
0
        public RankingCategoryListPageViewModel(
            ApplicationLayoutManager applicationLayoutManager,
            Services.PageManager pageManager,
            Services.DialogService dialogService,
            RankingSettings rankingSettings,
            IEventAggregator eventAggregator,
            AppFlagsRepository appFlagsRepository,
            RankingProvider rankingProvider
            )
        {
            ApplicationLayoutManager = applicationLayoutManager;
            PageManager          = pageManager;
            HohoemaDialogService = dialogService;
            RankingSettings      = rankingSettings;
            _eventAggregator     = eventAggregator;
            _appFlagsRepository  = appFlagsRepository;
            _rankingProvider     = rankingProvider;


            // TODO: ログインユーザーが成年であればR18ジャンルを表示するように
            _RankingGenreItemsSource = new List <RankingGenreItem>();

            FavoriteItems = new ObservableCollection <RankingItem>(GetFavoriteRankingItems());
            _favoriteRankingGenreGroupItem = new FavoriteRankingGenreGroupItem()
            {
                Label     = "FavoriteRankingTag".Translate(),
                IsDisplay = true,
                Items     = new AdvancedCollectionView(FavoriteItems),
            };
            _RankingGenreItemsSource.Add(_favoriteRankingGenreGroupItem);


            var sourceGenreItems = Enum.GetValues(typeof(RankingGenre)).Cast <RankingGenre>()
                                   .Where(x => x != RankingGenre.R18)
                                   .Select(x =>
            {
                var acv = new AdvancedCollectionView(new ObservableCollection <RankingItem>(GetGenreTagRankingItems(x, RankingSettings)), isLiveShaping: true)
                {
                    Filter = (item) => (item as RankingItem).IsDisplay,
                };
                acv.ObserveFilterProperty(nameof(RankingItem.IsDisplay));

                return(new RankingGenreItem()
                {
                    Genre = x,
                    Label = x.Translate(),
                    IsDisplay = !RankingSettings.IsHiddenGenre(x),
                    Items = acv
                });
            });

            foreach (var genreItem in sourceGenreItems)
            {
                _RankingGenreItemsSource.Add(genreItem);
            }


            foreach (var item in _RankingGenreItemsSource)
            {
                if (item.Genre == null)
                {
                    _RankingGenreItems.Add(item);
                }
                else if (!RankingSettings.IsHiddenGenre(item.Genre.Value))
                {
                    _RankingGenreItems.Add(item);
                }
            }


            {
                RankingGenreItems = new CollectionViewSource()
                {
                    Source          = _RankingGenreItems,
                    ItemsPath       = new Windows.UI.Xaml.PropertyPath(nameof(RankingGenreItem.Items)),
                    IsSourceGrouped = true,
                };
            }

            _eventAggregator.GetEvent <Events.RankingGenreShowRequestedEvent>()
            .Subscribe((args) =>
            {
                // Tagの指定が無い場合はジャンル自体の非表示として扱う
                var genreItem = _RankingGenreItemsSource.First(x => x.Genre == args.RankingGenre);
                if (string.IsNullOrEmpty(args.Tag))
                {
                    genreItem.IsDisplay = true;
                    RankingSettings.RemoveHiddenGenre(args.RankingGenre);
                    _ = RankingSettings.Save();

                    _RankingGenreItems.Clear();
                    foreach (var item in _RankingGenreItemsSource)
                    {
                        if (item.Genre == null)
                        {
                            _RankingGenreItems.Add(item);
                        }
                        else if (!RankingSettings.IsHiddenGenre(item.Genre.Value))
                        {
                            _RankingGenreItems.Add(item);
                        }
                    }

                    System.Diagnostics.Debug.WriteLine($"Genre Show: {args.RankingGenre}");
                }
                else
                {
                    var sameTagItem = genreItem.Items.SourceCollection.Cast <RankingItem>().FirstOrDefault(x => x.Tag == args.Tag);
                    if (sameTagItem != null)
                    {
                        sameTagItem.IsDisplay = true;
                        RankingSettings.RemoveHiddenTag(args.RankingGenre, args.Tag);
                        _ = RankingSettings.Save();

                        System.Diagnostics.Debug.WriteLine($"Tag Show: {args.Tag}");
                    }
                }
            })
            .AddTo(_CompositeDisposable);

            _eventAggregator.GetEvent <Events.RankingGenreHiddenRequestedEvent>()
            .Subscribe((args) =>
            {
                // Tagの指定が無い場合はジャンル自体の非表示として扱う
                var genreItem = _RankingGenreItemsSource.First(x => x.Genre == args.RankingGenre);
                if (string.IsNullOrEmpty(args.Tag))
                {
                    genreItem.IsDisplay = false;
                    RankingSettings.AddHiddenGenre(args.RankingGenre);
                    _ = RankingSettings.Save();

                    _RankingGenreItems.Clear();
                    foreach (var item in _RankingGenreItemsSource)
                    {
                        if (item.Genre == null)
                        {
                            _RankingGenreItems.Add(item);
                        }
                        else if (!RankingSettings.IsHiddenGenre(item.Genre.Value))
                        {
                            _RankingGenreItems.Add(item);
                        }
                    }

                    System.Diagnostics.Debug.WriteLine($"Genre Hidden: {args.RankingGenre}");
                }
                else
                {
                    var sameTagItem = genreItem.Items.SourceCollection.Cast <RankingItem>().FirstOrDefault(x => x.Tag == args.Tag);
                    if (sameTagItem != null)
                    {
                        sameTagItem.IsDisplay = false;
                        RankingSettings.AddHiddenTag(sameTagItem.Genre.Value, sameTagItem.Tag, sameTagItem.Label);
                        _ = RankingSettings.Save();
                        System.Diagnostics.Debug.WriteLine($"Tag Hidden: {args.Tag}");
                    }
                }
            })
            .AddTo(_CompositeDisposable);

            _eventAggregator.GetEvent <Events.RankingGenreFavoriteRequestedEvent>()
            .Subscribe((args) =>
            {
                if (false == FavoriteItems.Any(x => x.Genre == args.RankingGenre && x.Tag == args.Tag))
                {
                    var addedItem = new RankingItem()
                    {
                        Genre      = args.RankingGenre,
                        IsDisplay  = true,
                        IsFavorite = true,
                        Label      = args.Label,
                        Tag        = args.Tag
                    };

                    FavoriteItems.Add(addedItem);
                    RankingSettings.AddFavoriteTag(addedItem.Genre.Value, addedItem.Tag, addedItem.Label);
                    _ = RankingSettings.Save();
                    System.Diagnostics.Debug.WriteLine($"Favorite added: {args.Label}");
                }
            })
            .AddTo(_CompositeDisposable);

            _eventAggregator.GetEvent <Events.RankingGenreUnFavoriteRequestedEvent>()
            .Subscribe((args) =>
            {
                var unFavoriteItem = FavoriteItems.FirstOrDefault(x => x.Genre == args.RankingGenre && x.Tag == args.Tag);
                if (unFavoriteItem != null)
                {
                    FavoriteItems.Remove(unFavoriteItem);
                    RankingSettings.RemoveFavoriteTag(unFavoriteItem.Genre.Value, unFavoriteItem.Tag);
                    _ = RankingSettings.Save();
                    System.Diagnostics.Debug.WriteLine($"Favorite removed: {args.RankingGenre} {args.Tag}");
                }
            })
            .AddTo(_CompositeDisposable);
        }