Exemplo n.º 1
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 SearchResultLivePageViewModel(
            ILoggerFactory loggerFactory,
            ApplicationLayoutManager applicationLayoutManager,
            NiconicoSession niconicoSession,
            SearchProvider searchProvider,
            PageManager pageManager,
            SearchHistoryRepository searchHistoryRepository,
            NicoLiveCacheRepository nicoLiveCacheRepository,
            OpenLiveContentCommand openLiveContentCommand
            )
            : base(loggerFactory.CreateLogger <SearchResultLivePageViewModel>())
        {
            ApplicationLayoutManager = applicationLayoutManager;
            NiconicoSession          = niconicoSession;
            SearchProvider           = searchProvider;
            PageManager = pageManager;
            _searchHistoryRepository = searchHistoryRepository;
            _nicoLiveCacheRepository = nicoLiveCacheRepository;
            OpenLiveContentCommand   = openLiveContentCommand;

            SelectedSearchSort = new ReactiveProperty <LiveSearchPageSortOrder>(SortOptionItems[0], mode: ReactivePropertyMode.DistinctUntilChanged);
            SelectedLiveStatus = new ReactiveProperty <LiveStatus>(LiveStatusItems[0], mode: ReactivePropertyMode.DistinctUntilChanged);
            SelectedProviders  = new ObservableCollection <ProviderType>();

            IsTagSearch          = new ReactiveProperty <bool>(false);
            IsTimeshiftAvairable = new ReactiveProperty <bool>(false);
            IsHideMemberOnly     = new ReactiveProperty <bool>(false);
            IsDisableGrouping    = new ReactiveProperty <bool>(false);

            Observable.Merge(
                SelectedSearchSort.ToUnit(),
                SelectedLiveStatus.ToUnit(),
                SelectedProviders.CollectionChangedAsObservable().ToUnit()
                )
            .Subscribe(async _ =>
            {
                if (_NowNavigatingTo)
                {
                    return;
                }

                if (_query is not null)
                {
                    if (_query.Keyword == Keyword &&
                        _query.SortOrder == SelectedSearchSort.Value &&
                        _query.LiveStatus == SelectedLiveStatus.Value &&
                        (_query.ProviderTypes?.Any() ?? false) &&
                        SelectedProviders.Count == _query.ProviderTypes.Length &&
                        SelectedProviders.All(x => _query.ProviderTypes.Contains(x))
                        )
                    {
                        return;
                    }
                }

                ResetList();
            })
            .AddTo(_CompositeDisposable);
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
 public TimeshiftPageViewModel(
     ILoggerFactory loggerFactory,
     ApplicationLayoutManager applicationLayoutManager,
     LoginUserLiveReservationProvider loginUserLiveReservationProvider,
     NicoLiveProvider nicoLiveProvider,
     NoUIProcessScreenContext noUIProcessScreenContext,
     Services.DialogService dialogService,
     OpenLiveContentCommand openLiveContentCommand
     )
     : base(loggerFactory.CreateLogger <TimeshiftPageViewModel>())
 {
     ApplicationLayoutManager         = applicationLayoutManager;
     LoginUserLiveReservationProvider = loginUserLiveReservationProvider;
     NicoLiveProvider          = nicoLiveProvider;
     _noUIProcessScreenContext = noUIProcessScreenContext;
     DialogService             = dialogService;
     OpenLiveContentCommand    = openLiveContentCommand;
 }
Exemplo n.º 5
0
        public NicoRepoPageViewModel(
            ILoggerFactory loggerFactory,
            IScheduler scheduler,
            ApplicationLayoutManager applicationLayoutManager,
            NicoVideoProvider nicoVideoProvider,
            PageManager pageManager,
            NicoRepoSettings activityFeedSettings,
            LoginUserNicoRepoProvider loginUserNicoRepoProvider,
            SubscriptionManager subscriptionManager,
            OpenLiveContentCommand openLiveContentCommand,
            VideoPlayWithQueueCommand videoPlayWithQueueCommand
            )
            : base(loggerFactory.CreateLogger <NicoRepoPageViewModel>())
        {
            _scheduler = scheduler;
            ApplicationLayoutManager  = applicationLayoutManager;
            _nicoVideoProvider        = nicoVideoProvider;
            ActivityFeedSettings      = activityFeedSettings;
            LoginUserNicoRepoProvider = loginUserNicoRepoProvider;
            SubscriptionManager       = subscriptionManager;
            _openLiveContentCommand   = openLiveContentCommand;
            VideoPlayWithQueueCommand = videoPlayWithQueueCommand;
            NicoRepoType          = new ReactiveProperty <NicoRepoType>(NiconicoToolkit.NicoRepo.NicoRepoType.Video, mode: ReactivePropertyMode.DistinctUntilChanged);
            NicoRepoDisplayTarget = new ReactiveProperty <NicoRepoDisplayTarget>(mode: ReactivePropertyMode.DistinctUntilChanged);

            new[]
            {
                NicoRepoType.ToUnit(),
                    NicoRepoDisplayTarget.ToUnit()
            }
            .Merge()
            .Subscribe(_ =>
            {
                ResetList();
            })
            .AddTo(_CompositeDisposable);
        }
        // TODO: 視聴開始(会場後のみ、チャンネル会員限定やチケット必要な場合あり)
        // TODO: タイムシフト予約(tsがある場合のみ、会場前のみ、プレミアムの場合は会場後でも可)
        // TODO: 後からタイムシフト予約(プレミアムの場合のみ)
        // TODO: 配信説明
        // TODO: タグ
        // TODO: 配信者(チャンネルやコミュニティ)の概要説明
        // TODO: 配信者(チャンネルやコミュニティ)のフォロー
        // TODO: オススメ生放送(放送中、放送予定を明示)
        // TODO: ニコニコ市場
        // TODO: SNS共有


        // gateとwatchをどちらも扱った上でその差を意識させないように表現する

        // LiveInfo.Video.CurrentStatusは開演前、放送中は時間の経過によって変化する可能性がある

        public LiveInfomationPageViewModel(
            ApplicationLayoutManager applicationLayoutManager,
            AppearanceSettings appearanceSettings,
            PageManager pageManager,
            NiconicoSession niconicoSession,
            NicoLiveProvider nicoLiveProvider,
            DialogService dialogService,
            OpenLiveContentCommand openLiveContentCommand,
            OpenLinkCommand openLinkCommand,
            CopyToClipboardCommand copyToClipboardCommand,
            CopyToClipboardWithShareTextCommand copyToClipboardWithShareTextCommand
            )
        {
            ApplicationLayoutManager = applicationLayoutManager;
            _appearanceSettings      = appearanceSettings;
            PageManager            = pageManager;
            NiconicoSession        = niconicoSession;
            NicoLiveProvider       = nicoLiveProvider;
            HohoemaDialogService   = dialogService;
            OpenLiveContentCommand = openLiveContentCommand;
            OpenLinkCommand        = openLinkCommand;
            CopyToClipboardCommand = copyToClipboardCommand;
            CopyToClipboardWithShareTextCommand = copyToClipboardWithShareTextCommand;
            IsLoadFailed = new ReactiveProperty <bool>(false)
                           .AddTo(_CompositeDisposable);
            LoadFailedMessage = new ReactiveProperty <string>()
                                .AddTo(_CompositeDisposable);



            IsLiveIdAvairable = this.ObserveProperty(x => x.LiveId)
                                .Select(x => x != default(LiveId))
                                .ToReadOnlyReactiveProperty()
                                .AddTo(_CompositeDisposable);



            IsLoggedIn = NiconicoSession.ObserveProperty(x => x.IsLoggedIn)
                         .ToReadOnlyReactiveProperty()
                         .AddTo(_CompositeDisposable);

            IsPremiumAccount = NiconicoSession.ObserveProperty(x => x.IsPremiumAccount)
                               .ToReadOnlyReactiveProperty()
                               .AddTo(_CompositeDisposable);



            _IsTsPreserved = new ReactiveProperty <bool>(false)
                             .AddTo(_CompositeDisposable);

            LiveTags = new ReadOnlyObservableCollection <LiveTagViewModel>(_LiveTags);

            IchibaItems = new ReadOnlyObservableCollection <IchibaItem>(_IchibaItems);

            /*
             * ReccomendItems = _ReccomendItems.ToReadOnlyReactiveCollection(x =>
             * {
             *  var liveId = x.ProgramId;
             *  var liveInfoVM = new LiveInfoListItemViewModel(liveId);
             *  liveInfoVM.Setup(x);
             *
             *  var reserve = _Reservations?.ReservedProgram.FirstOrDefault(reservation => liveId == reservation.Id);
             *  if (reserve != null)
             *  {
             *      liveInfoVM.SetReservation(reserve);
             *  }
             *
             *  return liveInfoVM;
             * })
             *  .AddTo(_CompositeDisposable);
             */

            IsShowOpenLiveContentButton =
                new[]
            {
                this.ObserveProperty(x => LiveProgram).ToUnit(),
                NiconicoSession.ObserveProperty(x => x.IsLoggedIn).ToUnit(),
                _IsTsPreserved.ToUnit()
            }
            .Merge()
            .Select(x =>
            {
                if (LiveProgram == null)
                {
                    return(false);
                }

                if (NiconicoSession.IsPremiumAccount)
                {
                    if (LiveProgram.OnAirTime.BeginAt > DateTime.Now)
                    {
                        return(false);
                    }

                    return(LiveProgram.Timeshift.Enabled);
                }
                else
                {
                    // 一般アカウントは放送中のみ
                    if (LiveProgram.OnAirTime.BeginAt > DateTime.Now)
                    {
                        return(false);
                    }

                    if (_IsTsPreserved.Value)
                    {
                        return(true);
                    }

                    if (LiveProgram.OnAirTime.EndAt < DateTime.Now)
                    {
                        return(false);
                    }

                    return(true);
                }
            })
            .ToReadOnlyReactiveProperty()
            .AddTo(_CompositeDisposable);

            IsShowAddTimeshiftButton =
                new []
            {
                this.ObserveProperty(x => LiveProgram).ToUnit(),
                NiconicoSession.ObserveProperty(x => x.IsLoggedIn).ToUnit(),
                _IsTsPreserved.ToUnit()
            }
            .Merge()
            .Select(x =>
            {
                if (LiveProgram == null)
                {
                    return(false);
                }
                if (!LiveProgram.Timeshift.Enabled)
                {
                    return(false);
                }
                if (!NiconicoSession.IsLoggedIn)
                {
                    return(false);
                }

                if (!NiconicoSession.IsPremiumAccount)
                {
                    // 一般アカウントは放送開始の30分前からタイムシフトの登録はできなくなる
                    if ((LiveProgram.ShowTime.BeginAt - TimeSpan.FromMinutes(30)) < DateTime.Now)
                    {
                        return(false);
                    }
                }

                // 放送前、及び放送中はタイムシフトボタンを非表示…?
                // プレ垢なら常に表示しておいていいんじゃないの?
                //if (LiveProgram.ShowTime.EndAt > DateTime.Now) { return false; }

                // タイムシフト予約済み
                if (_IsTsPreserved.Value)
                {
                    return(false);
                }

                return(true);
            })
            .ToReadOnlyReactiveProperty()
            .AddTo(_CompositeDisposable);

            IsShowDeleteTimeshiftButton = _IsTsPreserved;
        }
        public PrimaryWindowCoreLayoutViewModel(
            ILoggerFactory loggerFactory,
            NiconicoSession niconicoSession,
            PageManager pageManager,
            PinSettings pinSettings,
            AppearanceSettings appearanceSettings,
            SearchCommand searchCommand,
            DialogService dialogService,
            NotificationService notificationService,
            PrimaryViewPlayerManager primaryViewPlayerManager,
            ObservableMediaPlayer observableMediaPlayer,
            NiconicoLoginService niconicoLoginService,
            LogoutFromNiconicoCommand logoutFromNiconicoCommand,
            WindowService windowService,
            ApplicationLayoutManager applicationLayoutManager,
            RestoreNavigationManager restoreNavigationManager,
            VideoItemsSelectionContext videoItemsSelectionContext,
            QueueMenuItemViewModel queueMenuItemViewModel,
            LoginUserOwnedMylistManager userMylistManager,
            LocalMylistManager localMylistManager,
            OpenLiveContentCommand openLiveContentCommand
            )
        {
            _logger                    = loggerFactory.CreateLogger <PrimaryWindowCoreLayoutViewModel>();
            NiconicoSession            = niconicoSession;
            PageManager                = pageManager;
            PinSettings                = pinSettings;
            AppearanceSettings         = appearanceSettings;
            SearchCommand              = searchCommand;
            _dialogService             = dialogService;
            _notificationService       = notificationService;
            PrimaryViewPlayerManager   = primaryViewPlayerManager;
            ObservableMediaPlayer      = observableMediaPlayer;
            NiconicoLoginService       = niconicoLoginService;
            LogoutFromNiconicoCommand  = logoutFromNiconicoCommand;
            WindowService              = windowService;
            ApplicationLayoutManager   = applicationLayoutManager;
            RestoreNavigationManager   = restoreNavigationManager;
            VideoItemsSelectionContext = videoItemsSelectionContext;

            WeakReferenceMessenger.Default.Register <SettingsRestoredMessage>(this);

            SearchAutoSuggestItems = new ObservableCollection <SearchAutoSuggestItemViewModel>
            {
                new SearchAutoSuggestItemViewModel()
                {
                    Id           = "VideoSearchSuggest",
                    SearchAction = (s) => PageManager.Search(SearchTarget.Keyword, s),
                },
                new SearchAutoSuggestItemViewModel()
                {
                    Id           = "LiveSearchSuggest",
                    SearchAction = (s) => PageManager.Search(SearchTarget.Niconama, s),
                },
                new SearchAutoSuggestItemViewModel()
                {
                    Id           = "DetailSearchSuggest",
                    SearchAction = (s) => PageManager.OpenPage(HohoemaPageType.Search, ""),
                },
            };

            _queueMenuItemViewModel          = queueMenuItemViewModel;
            _userMylistManager               = userMylistManager;
            _localMylistManager              = localMylistManager;
            OpenLiveContentCommand           = openLiveContentCommand;
            _pinsMenuSubItemViewModel        = new PinsMenuSubItemViewModel("Pin".Translate(), PinSettings, _dialogService, _notificationService);
            _localMylistMenuSubItemViewModel = new LocalMylistSubMenuItemViewModel(_localMylistManager, PageManager.OpenPageCommand);

            // メニュー項目の初期化
            MenuItems_LoggedIn = new ObservableCollection <HohoemaListingPageItemBase>()
            {
                _pinsMenuSubItemViewModel,
                _queueMenuItemViewModel,
                new LogginUserLiveSummaryItemViewModel(NiconicoSession, _logger, OpenLiveContentCommand),
                new SeparatorMenuItemViewModel(),
                new MenuItemViewModel(HohoemaPageType.RankingCategoryList.Translate(), HohoemaPageType.RankingCategoryList),
                new MenuItemViewModel(HohoemaPageType.NicoRepo.Translate(), HohoemaPageType.NicoRepo),
                new MenuItemViewModel(HohoemaPageType.WatchHistory.Translate(), HohoemaPageType.WatchHistory),
                new MenuItemViewModel("WatchAfterMylist".Translate(), HohoemaPageType.Mylist, new NavigationParameters(("id", MylistId.WatchAfterMylistId.ToString()))),
                new MylistSubMenuMenu(_userMylistManager, PageManager.OpenPageCommand),
                _localMylistMenuSubItemViewModel,
                new MenuItemViewModel(HohoemaPageType.FollowManage.Translate(), HohoemaPageType.FollowManage),
                new MenuItemViewModel(HohoemaPageType.Timeshift.Translate(), HohoemaPageType.Timeshift),
                new MenuItemViewModel(HohoemaPageType.SubscriptionManagement.Translate(), HohoemaPageType.SubscriptionManagement),
                new MenuItemViewModel(HohoemaPageType.CacheManagement.Translate(), HohoemaPageType.CacheManagement),
            };

            MenuItems_Offline = new ObservableCollection <HohoemaListingPageItemBase>()
            {
                _pinsMenuSubItemViewModel,
                _queueMenuItemViewModel,
                new SeparatorMenuItemViewModel(),
                new MenuItemViewModel(HohoemaPageType.RankingCategoryList.Translate(), HohoemaPageType.RankingCategoryList),
                _localMylistMenuSubItemViewModel,
                new MenuItemViewModel(HohoemaPageType.SubscriptionManagement.Translate(), HohoemaPageType.SubscriptionManagement),
                new MenuItemViewModel(HohoemaPageType.CacheManagement.Translate(), HohoemaPageType.CacheManagement),
            };
        }