예제 #1
0
        public UserVideoPageViewModel(
            ILoggerFactory loggerFactory,
            ApplicationLayoutManager applicationLayoutManager,
            UserProvider userProvider,
            SubscriptionManager subscriptionManager,
            PageManager pageManager,
            VideoPlayWithQueueCommand videoPlayWithQueueCommand,
            PlaylistPlayAllCommand playlistPlayAllCommand,
            AddSubscriptionCommand addSubscriptionCommand,
            SelectionModeToggleCommand selectionModeToggleCommand
            )
            : base(loggerFactory.CreateLogger <UserVideoPageViewModel>())
        {
            SubscriptionManager      = subscriptionManager;
            ApplicationLayoutManager = applicationLayoutManager;
            UserProvider             = userProvider;
            PageManager = pageManager;
            VideoPlayWithQueueCommand  = videoPlayWithQueueCommand;
            PlaylistPlayAllCommand     = playlistPlayAllCommand;
            AddSubscriptionCommand     = addSubscriptionCommand;
            SelectionModeToggleCommand = selectionModeToggleCommand;
            UserInfo = new ReactiveProperty <UserInfoViewModel>();

            CurrentPlaylistToken = Observable.CombineLatest(
                this.ObserveProperty(x => x.UserVideoPlaylist),
                this.ObserveProperty(x => x.SelectedSortOption),
                (x, y) => new PlaylistToken(x, y)
                )
                                   .ToReadOnlyReactivePropertySlim()
                                   .AddTo(_CompositeDisposable);

            SelectedSortOption = UserVideoPlaylist.DefaultSortOption;
        }
예제 #2
0
        public VideoQueuePageViewModel(
            ILoggerFactory loggerFactory,
            IMessenger messenger,
            QueuePlaylist queuePlaylist,
            QueuePlaylistSetting queuePlaylistSetting,
            ApplicationLayoutManager applicationLayoutManager,
            RemoveWatchedItemsInAfterWatchPlaylistCommand removeWatchedItemsInAfterWatchPlaylistCommand,
            PlaylistPlayAllCommand playlistPlayAllCommand,
            SelectionModeToggleCommand selectionModeToggleCommand,
            VideoPlayWithQueueCommand videoPlayWithQueueCommand,
            NicoVideoProvider nicoVideoProvider
            )
            : base(loggerFactory.CreateLogger <VideoQueuePageViewModel>())
        {
            _messenger               = messenger;
            QueuePlaylist            = queuePlaylist;
            _queuePlaylistSetting    = queuePlaylistSetting;
            ApplicationLayoutManager = applicationLayoutManager;
            RemoveWatchedItemsInAfterWatchPlaylistCommand = removeWatchedItemsInAfterWatchPlaylistCommand;
            PlaylistPlayAllCommand     = playlistPlayAllCommand;
            SelectionModeToggleCommand = selectionModeToggleCommand;
            VideoPlayWithQueueCommand  = videoPlayWithQueueCommand;
            _nicoVideoProvider         = nicoVideoProvider;

            IsEnableGroupingByTitleSimulality = _queuePlaylistSetting.ToReactivePropertyAsSynchronized(x => x.IsGroupingNearByTitleThenByTitleAscending, mode: ReactivePropertyMode.DistinctUntilChanged)
                                                .AddTo(_CompositeDisposable);

            CurrentPlaylistToken = this.ObserveProperty(x => x.SelectedSortOptionItem)
                                   .Select(x => new PlaylistToken(QueuePlaylist, x))
                                   .ToReadOnlyReactivePropertySlim()
                                   .AddTo(_CompositeDisposable);
        }
        public ChannelVideoPageViewModel(
            ILoggerFactory loggerFactory,
            ApplicationLayoutManager applicationLayoutManager,
            NiconicoSession niconicoSession,
            ChannelProvider channelProvider,
            ChannelFollowProvider channelFollowProvider,
            PageManager pageManager,
            VideoPlayWithQueueCommand videoPlayWithQueueCommand,
            PlaylistPlayAllCommand playlistPlayAllCommand,
            OpenLinkCommand openLinkCommand,
            SelectionModeToggleCommand selectionModeToggleCommand
            )
            : base(loggerFactory.CreateLogger <ChannelVideoPageViewModel>())
        {
            ApplicationLayoutManager = applicationLayoutManager;
            NiconicoSession          = niconicoSession;
            ChannelProvider          = channelProvider;
            _channelFollowProvider   = channelFollowProvider;
            PageManager = pageManager;
            VideoPlayWithQueueCommand  = videoPlayWithQueueCommand;
            PlaylistPlayAllCommand     = playlistPlayAllCommand;
            OpenLinkCommand            = openLinkCommand;
            SelectionModeToggleCommand = selectionModeToggleCommand;

            CurrentPlaylistToken = Observable.CombineLatest(
                this.ObserveProperty(x => x.ChannelVideoPlaylist),
                this.ObserveProperty(x => x.SelectedSortOption),
                (x, y) => new PlaylistToken(x, y)
                )
                                   .ToReadOnlyReactivePropertySlim()
                                   .AddTo(_CompositeDisposable);
        }
예제 #4
0
        public LocalPlaylistPageViewModel(
            ILoggerFactory loggerFactory,
            IMessenger messenger,
            ApplicationLayoutManager applicationLayoutManager,
            PageManager pageManager,
            LocalMylistManager localMylistManager,
            NicoVideoProvider nicoVideoProvider,
            VideoPlayWithQueueCommand videoPlayWithQueueCommand,
            PlaylistPlayAllCommand playlistPlayAllCommand,
            LocalPlaylistDeleteCommand localPlaylistDeleteCommand,
            SelectionModeToggleCommand selectionModeToggleCommand
            )
            : base(loggerFactory.CreateLogger <LocalPlaylistPageViewModel>())
        {
            ApplicationLayoutManager   = applicationLayoutManager;
            _pageManager               = pageManager;
            _localMylistManager        = localMylistManager;
            _nicoVideoProvider         = nicoVideoProvider;
            LocalPlaylistDeleteCommand = localPlaylistDeleteCommand;
            VideoPlayWithQueueCommand  = videoPlayWithQueueCommand;
            PlaylistPlayAllCommand     = playlistPlayAllCommand;
            SelectionModeToggleCommand = selectionModeToggleCommand;
            _messenger = messenger;

            CurrentPlaylistToken = Observable.CombineLatest(
                this.ObserveProperty(x => x.Playlist),
                this.ObserveProperty(x => x.SelectedSortOptionItem),
                (x, y) => new PlaylistToken(x, y)
                )
                                   .ToReadOnlyReactivePropertySlim()
                                   .AddTo(_CompositeDisposable);
        }
예제 #5
0
        public SearchResultTagPageViewModel(
            ILoggerFactory loggerFactory,
            ApplicationLayoutManager applicationLayoutManager,
            NiconicoSession niconicoSession,
            SearchProvider searchProvider,
            TagFollowProvider tagFollowProvider,
            SubscriptionManager subscriptionManager,
            PageManager pageManager,
            SearchHistoryRepository searchHistoryRepository,
            Services.DialogService dialogService,
            VideoPlayWithQueueCommand videoPlayWithQueueCommand,
            PlaylistPlayAllCommand playlistPlayAllCommand,
            AddTagSearchSubscriptionCommand addTagSearchSubscriptionCommand,
            SelectionModeToggleCommand selectionModeToggleCommand
            )
            : base(loggerFactory.CreateLogger <SearchResultTagPageViewModel>())
        {
            SearchProvider                  = searchProvider;
            _tagFollowProvider              = tagFollowProvider;
            SubscriptionManager             = subscriptionManager;
            PageManager                     = pageManager;
            _searchHistoryRepository        = searchHistoryRepository;
            ApplicationLayoutManager        = applicationLayoutManager;
            NiconicoSession                 = niconicoSession;
            HohoemaDialogService            = dialogService;
            VideoPlayWithQueueCommand       = videoPlayWithQueueCommand;
            PlaylistPlayAllCommand          = playlistPlayAllCommand;
            AddTagSearchSubscriptionCommand = addTagSearchSubscriptionCommand;
            SelectionModeToggleCommand      = selectionModeToggleCommand;
            FailLoading                     = new ReactiveProperty <bool>(false)
                                              .AddTo(_CompositeDisposable);

            LoadedPage = new ReactiveProperty <int>(1)
                         .AddTo(_CompositeDisposable);

            SelectedSearchTarget = new ReactiveProperty <SearchTarget>();


            CurrentPlaylistToken = Observable.CombineLatest(
                this.ObserveProperty(x => x.SearchVideoPlaylist),
                this.ObserveProperty(x => x.SelectedSortOption),
                (x, y) => new PlaylistToken(x, y)
                )
                                   .ToReadOnlyReactivePropertySlim()
                                   .AddTo(_CompositeDisposable);
        }
예제 #6
0
 public SeriesPageViewModel(
     ILoggerFactory loggerFactory,
     SeriesProvider seriesRepository,
     VideoPlayWithQueueCommand videoPlayWithQueueCommand,
     AddSubscriptionCommand addSubscriptionCommand,
     SelectionModeToggleCommand selectionModeToggleCommand,
     PlaylistPlayAllCommand playlistPlayAllCommand
     )
     : base(loggerFactory.CreateLogger <SeriesPageViewModel>())
 {
     _seriesProvider            = seriesRepository;
     VideoPlayWithQueueCommand  = videoPlayWithQueueCommand;
     AddSubscriptionCommand     = addSubscriptionCommand;
     SelectionModeToggleCommand = selectionModeToggleCommand;
     PlaylistPlayAllCommand     = playlistPlayAllCommand;
     CurrentPlaylistToken       = Observable.CombineLatest(
         this.ObserveProperty(x => x.SeriesVideoPlaylist),
         this.ObserveProperty(x => x.SelectedSortOption),
         (x, y) => new PlaylistToken(x, y)
         )
                                  .ToReadOnlyReactivePropertySlim()
                                  .AddTo(_CompositeDisposable);
 }
        public WatchHistoryPageViewModel(
            ILoggerFactory loggerFactory,
            ApplicationLayoutManager applicationLayoutManager,
            NiconicoSession niconicoSession,
            WatchHistoryManager watchHistoryManager,
            PageManager pageManager,
            VideoPlayWithQueueCommand videoPlayWithQueueCommand,
            WatchHistoryRemoveAllCommand watchHistoryRemoveAllCommand,
            SelectionModeToggleCommand selectionModeToggleCommand
            )
        {
            _logger = loggerFactory.CreateLogger <WatchHistoryPageViewModel>();
            ApplicationLayoutManager = applicationLayoutManager;
            _niconicoSession         = niconicoSession;
            _watchHistoryManager     = watchHistoryManager;
            PageManager = pageManager;
            VideoPlayWithQueueCommand    = videoPlayWithQueueCommand;
            WatchHistoryRemoveAllCommand = watchHistoryRemoveAllCommand;
            SelectionModeToggleCommand   = selectionModeToggleCommand;
            Histories = new ObservableCollection <HistoryVideoListItemControlViewModel>();

            NowUpdating = new ReactivePropertySlim <bool>(false)
                          .AddTo(_CompositeDisposable);
        }
예제 #8
0
        public CacheManagementPageViewModel(
            IScheduler scheduler,
            NiconicoSession niconicoSession,
            ApplicationLayoutManager applicationLayoutManager,
            VideoCacheSettings cacheSettings,
            VideoCacheManager videoCacheManager,
            VideoCacheFolderManager videoCacheFolderManager,
            VideoCacheDownloadOperationManager videoCacheDownloadOperationManager,
            NicoVideoProvider nicoVideoProvider,
            PageManager pageManager,
            DialogService dialogService,
            NotificationService notificationService,
            SelectionModeToggleCommand selectionModeToggleCommand,
            VideoPlayWithQueueCommand videoPlayWithQueueCommand
            )
        {
            _scheduler                          = scheduler;
            _niconicoSession                    = niconicoSession;
            ApplicationLayoutManager            = applicationLayoutManager;
            VideoCacheSettings                  = cacheSettings;
            VideoCacheManager                   = videoCacheManager;
            _videoCacheFolderManager            = videoCacheFolderManager;
            _videoCacheDownloadOperationManager = videoCacheDownloadOperationManager;
            NicoVideoProvider                   = nicoVideoProvider;
            HohoemaDialogService                = dialogService;
            NotificationService                 = notificationService;
            SelectionModeToggleCommand          = selectionModeToggleCommand;
            VideoPlayWithQueueCommand           = videoPlayWithQueueCommand;
            Groups = new (new[]
            {
                VideoCacheStatus.Failed,
                VideoCacheStatus.Downloading,
                VideoCacheStatus.DownloadPaused,
                VideoCacheStatus.Pending,
                VideoCacheStatus.Completed,
            }
                          .Select(x => new CacheItemsGroup(x, new ObservableCollection <CacheVideoViewModel>()))
                          );

            IsLoggedInWithPremiumMember = _niconicoSession.ObserveProperty(x => x.IsPremiumAccount).ToReadOnlyReactivePropertySlim(_niconicoSession.IsPremiumAccount)
                                          .AddTo(_CompositeDisposable);

            CurrentlyCachedStorageSize = VideoCacheSettings.ObserveProperty(x => x.CachedStorageSize).ToReadOnlyReactivePropertySlim(VideoCacheSettings.CachedStorageSize)
                                         .AddTo(_CompositeDisposable);

            MaxCacheStorageSize = VideoCacheSettings.ObserveProperty(x => x.MaxVideoCacheStorageSize).ToReadOnlyReactivePropertySlim(VideoCacheSettings.MaxVideoCacheStorageSize)
                                  .AddTo(_CompositeDisposable);

            IsAllowDownload = new ReactivePropertySlim <bool>(_videoCacheDownloadOperationManager.IsAllowDownload, mode: ReactivePropertyMode.DistinctUntilChanged);
            IsAllowDownload.Subscribe(isAllowDownload =>
            {
                if (isAllowDownload)
                {
                    _videoCacheDownloadOperationManager.ResumeDownload();
                }
                else
                {
                    _videoCacheDownloadOperationManager.SuspendDownload();
                }
            })
            .AddTo(_CompositeDisposable);

            AvairableStorageSizeNormalized = new[]
            {
                CurrentlyCachedStorageSize,
                MaxCacheStorageSize.Select(x => x ?? 0),
            }
            .CombineLatest()
            .Select(xy => xy[1] == 0 ? 0.0 : ((double)xy[0] / xy[1]))
            .ToReadOnlyReactivePropertySlim()
            .AddTo(_CompositeDisposable);
        }
예제 #9
0
        public MylistPageViewModel(
            ILoggerFactory loggerFactory,
            IMessenger messenger,
            ApplicationLayoutManager applicationLayoutManager,
            PageManager pageManager,
            NiconicoSession niconicoSession,
            MylistProvider mylistProvider,
            MylistFollowProvider mylistFollowProvider,
            UserProvider userProvider,
            LoginUserMylistProvider loginUserMylistProvider,
            LoginUserOwnedMylistManager userMylistManager,
            LocalMylistManager localMylistManager,
            MylistResolver mylistRepository,
            SubscriptionManager subscriptionManager,
            MylistUserSelectedSortRepository mylistUserSelectedSortRepository,
            Services.DialogService dialogService,
            AddSubscriptionCommand addSubscriptionCommand,
            SelectionModeToggleCommand selectionModeToggleCommand,
            PlaylistPlayAllCommand playlistPlayAllCommand,
            VideoPlayWithQueueCommand videoPlayWithQueueCommand
            )
        {
            _logger    = loggerFactory.CreateLogger <MylistPageViewModel>();
            _messenger = messenger;
            ApplicationLayoutManager = applicationLayoutManager;
            PageManager                       = pageManager;
            NiconicoSession                   = niconicoSession;
            MylistProvider                    = mylistProvider;
            _mylistFollowProvider             = mylistFollowProvider;
            UserProvider                      = userProvider;
            LoginUserMylistProvider           = loginUserMylistProvider;
            UserMylistManager                 = userMylistManager;
            LocalMylistManager                = localMylistManager;
            _mylistRepository                 = mylistRepository;
            SubscriptionManager               = subscriptionManager;
            _mylistUserSelectedSortRepository = mylistUserSelectedSortRepository;
            DialogService                     = dialogService;
            AddSubscriptionCommand            = addSubscriptionCommand;
            SelectionModeToggleCommand        = selectionModeToggleCommand;
            PlaylistPlayAllCommand            = playlistPlayAllCommand;
            VideoPlayWithQueueCommand         = videoPlayWithQueueCommand;
            Mylist = new ReactiveProperty <MylistPlaylist>();

            SelectedSortOptionItem = new ReactiveProperty <MylistPlaylistSortOption>(mode: ReactivePropertyMode.DistinctUntilChanged);

            CurrentPlaylistToken = Observable.CombineLatest(
                Mylist,
                SelectedSortOptionItem,
                (x, y) => new PlaylistToken(x, y)
                )
                                   .ToReadOnlyReactivePropertySlim()
                                   .AddTo(_CompositeDisposable);


            /*
             * 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 = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService<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);
             ||
             || }
             ||
             ||
             ||});
             ||
             ||
             */
        }