Ejemplo n.º 1
0
 public CacheAddRequestCommand(
     Models.Cache.VideoCacheManager videoCacheManager,
     Services.DialogService dialogService
     )
 {
     VideoCacheManager = videoCacheManager;
     DialogService     = dialogService;
 }
        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>();
        }
Ejemplo n.º 3
0
 public VideoInfomationPageViewModel(
     ILoggerFactory loggerFactory,
     ApplicationLayoutManager applicationLayoutManager,
     AppearanceSettings appearanceSettings,
     VideoFilteringSettings ngSettings,
     NiconicoSession niconicoSession,
     LoginUserOwnedMylistManager userMylistManager,
     NicoVideoProvider nicoVideoProvider,
     LoginUserMylistProvider loginUserMylistProvider,
     SubscriptionManager subscriptionManager,
     NicoVideoSessionProvider nicoVideo,
     PageManager pageManager,
     Services.NotificationService notificationService,
     Services.DialogService dialogService,
     VideoPlayWithQueueCommand videoPlayWithQueueCommand,
     MylistAddItemCommand addMylistCommand,
     LocalPlaylistAddItemCommand localPlaylistAddItemCommand,
     AddSubscriptionCommand addSubscriptionCommand,
     OpenLinkCommand openLinkCommand,
     CopyToClipboardCommand copyToClipboardCommand,
     CopyToClipboardWithShareTextCommand copyToClipboardWithShareTextCommand,
     OpenShareUICommand openShareUICommand,
     CacheAddRequestCommand cacheAddRequestCommand,
     RecommendProvider recommendProvider,
     UserFollowProvider userFollowProvider,
     ChannelFollowProvider channelFollowProvider
     )
 {
     _logger = loggerFactory.CreateLogger <VideoInfomationPageViewModel>();
     ApplicationLayoutManager = applicationLayoutManager;
     AppearanceSettings       = appearanceSettings;
     NgSettings              = ngSettings;
     NiconicoSession         = niconicoSession;
     UserMylistManager       = userMylistManager;
     NicoVideoProvider       = nicoVideoProvider;
     LoginUserMylistProvider = loginUserMylistProvider;
     SubscriptionManager     = subscriptionManager;
     NicoVideo                           = nicoVideo;
     PageManager                         = pageManager;
     NotificationService                 = notificationService;
     DialogService                       = dialogService;
     VideoPlayWithQueueCommand           = videoPlayWithQueueCommand;
     AddMylistCommand                    = addMylistCommand;
     LocalPlaylistAddItemCommand         = localPlaylistAddItemCommand;
     AddSubscriptionCommand              = addSubscriptionCommand;
     OpenLinkCommand                     = openLinkCommand;
     CopyToClipboardCommand              = copyToClipboardCommand;
     CopyToClipboardWithShareTextCommand = copyToClipboardWithShareTextCommand;
     OpenShareUICommand                  = openShareUICommand;
     CacheAddRequestCommand              = cacheAddRequestCommand;
     _recommendProvider                  = recommendProvider;
     _userFollowProvider                 = userFollowProvider;
     _channelFollowProvider              = channelFollowProvider;
     NowLoading                          = new ReactiveProperty <bool>(false);
     IsLoadFailed                        = new ReactiveProperty <bool>(false);
 }
Ejemplo n.º 4
0
        public VideoCommentSidePaneContentViewModel(
            VideoCommentPlayer commentPlayer,
            CommentFilteringFacade commentFiltering,
            Services.DialogService dialogService
            )
        {
            CommentPlayer    = commentPlayer;
            CommentFiltering = commentFiltering;
            _dialogService   = dialogService;
            Comments         = new AdvancedCollectionView(CommentPlayer.Comments, true);

            HandleCommentFilterConditionChanged();

            void HandleCommentFilterConditionChanged()
            {
#pragma warning disable IDISP004 // Don't ignore created IDisposable.
                new[]
                {
                    Observable.FromEventPattern <CommentFilteringFacade.CommentOwnerIdFilteredEventArgs>(
                        h => CommentFiltering.FilteringCommentOwnerIdAdded += h,
                        h => CommentFiltering.FilteringCommentOwnerIdAdded -= h
                        ).ToUnit(),
                    Observable.FromEventPattern <CommentFilteringFacade.CommentOwnerIdFilteredEventArgs>(
                        h => CommentFiltering.FilteringCommentOwnerIdRemoved += h,
                        h => CommentFiltering.FilteringCommentOwnerIdRemoved -= h
                        ).ToUnit(),

                    Observable.FromEventPattern <CommentFilteringFacade.FilteringCommentTextKeywordEventArgs>(
                        h => CommentFiltering.FilterKeywordAdded += h,
                        h => CommentFiltering.FilterKeywordAdded -= h
                        ).ToUnit(),
                    Observable.FromEventPattern <CommentFilteringFacade.FilteringCommentTextKeywordEventArgs>(
                        h => CommentFiltering.FilterKeywordUpdated += h,
                        h => CommentFiltering.FilterKeywordUpdated -= h
                        ).ToUnit(),
                    Observable.FromEventPattern <CommentFilteringFacade.FilteringCommentTextKeywordEventArgs>(
                        h => CommentFiltering.FilterKeywordRemoved += h,
                        h => CommentFiltering.FilterKeywordRemoved -= h
                        ).ToUnit(),
                }
                .Merge()
                .Subscribe(_ => Comments.RefreshFilter())
#pragma warning restore IDISP004 // Don't ignore created IDisposable.
                .AddTo(_disposables);

                using (Comments.DeferRefresh())
                {
                    Comments.SortDescriptions.Add(new SortDescription("VideoPosition", SortDirection.Ascending));
                    Comments.Filter = (c) => !isCommentFiltered(c as VideoComment);
                }
            }
        }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
 public TimeshiftPageViewModel(
     ApplicationLayoutManager applicationLayoutManager,
     LoginUserLiveReservationProvider loginUserLiveReservationProvider,
     NicoLiveProvider nicoLiveProvider,
     HohoemaPlaylist hohoemaPlaylist,
     NoUIProcessScreenContext noUIProcessScreenContext,
     Services.DialogService dialogService
     )
 {
     ApplicationLayoutManager         = applicationLayoutManager;
     LoginUserLiveReservationProvider = loginUserLiveReservationProvider;
     NicoLiveProvider          = nicoLiveProvider;
     HohoemaPlaylist           = hohoemaPlaylist;
     _noUIProcessScreenContext = noUIProcessScreenContext;
     DialogService             = dialogService;
 }
Ejemplo n.º 7
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);
        }
        public RankingCategoryListPageViewModel(
            IMessenger messenger,
            ApplicationLayoutManager applicationLayoutManager,
            PageManager pageManager,
            Services.DialogService dialogService,
            VideoRankingSettings rankingSettings,
            AppFlagsRepository appFlagsRepository,
            RankingProvider rankingProvider
            )
        {
            _messenger = messenger;
            ApplicationLayoutManager = applicationLayoutManager;
            PageManager          = pageManager;
            HohoemaDialogService = dialogService;
            RankingSettings      = rankingSettings;
            _appFlagsRepository  = appFlagsRepository;
            _rankingProvider     = rankingProvider;

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

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

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


            var sourceGenreItems = Enum.GetValues(typeof(RankingGenre)).Cast <RankingGenre>()
                                   .Where(x => x != RankingGenre.R18)
                                   .Select(genre =>
            {
                var rankingItems = ToRankingItem(genre, _rankingProvider.GetRankingGenreTagsFromCache(genre));
                var acv          = new AdvancedCollectionView(new ObservableCollection <RankingItem>(rankingItems), isLiveShaping: true)
                {
                    Filter = (item) =>
                    {
                        if (item is RankingItem rankingItem && rankingItem.Genre != null)
                        {
                            return(!(RankingSettings.IsHiddenGenre(rankingItem.Genre.Value) || RankingSettings.IsHiddenTag(rankingItem.Genre.Value, rankingItem.Tag)));
                        }
Ejemplo n.º 9
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;
 }
        public LocalPlaylistManagePageViewModel(
            PageManager pageManager,
            Services.DialogService dialogService,
            ApplicationLayoutManager applicationLayoutManager,
            LocalMylistManager localMylistManager,
            PlaylistPlayAllCommand playlistPlayAllCommand,
            LocalPlaylistCreateCommand localPlaylistCreateCommand,
            LocalPlaylistDeleteCommand localPlaylistDeleteCommand
            )
        {
            _pageManager               = pageManager;
            ApplicationLayoutManager   = applicationLayoutManager;
            _localMylistManager        = localMylistManager;
            PlaylistPlayAllCommand     = playlistPlayAllCommand;
            CreateLocalMylistCommand   = localPlaylistCreateCommand;
            DeleteLocalPlaylistCommand = localPlaylistDeleteCommand;
            ItemsView = new AdvancedCollectionView(_localMylistManager.LocalPlaylists);

            OpenMylistCommand = new ReactiveCommand <IPlaylist>()
                                .AddTo(_CompositeDisposable);

            OpenMylistCommand.Subscribe(listItem =>
            {
                _pageManager.OpenPageWithId(HohoemaPageType.LocalPlaylist, listItem.PlaylistId.Id);
            });


            RenameLocalPlaylistCommand = new RelayCommand <LocalPlaylist>(async playlist =>
            {
                var result = await dialogService.GetTextAsync(
                    "RenameLocalPlaylist",
                    "RenameLocalPlaylist_Placeholder",
                    playlist.Name,
                    name => !string.IsNullOrWhiteSpace(name)
                    );

                if (result is not null)
                {
                    playlist.Name = result;
                }
            });
        }
Ejemplo n.º 11
0
 public UserMylistPageViewModel(
     ILoggerFactory loggerFactory,
     ApplicationLayoutManager applicationLayoutManager,
     PageManager pageManager,
     Services.DialogService dialogService,
     NiconicoSession niconicoSession,
     UserProvider userProvider,
     MylistResolver mylistRepository,
     LocalMylistManager localMylistManager
     )
     : base(loggerFactory.CreateLogger <UserMylistPageViewModel>())
 {
     ApplicationLayoutManager = applicationLayoutManager;
     PageManager         = pageManager;
     DialogService       = dialogService;
     NiconicoSession     = niconicoSession;
     UserProvider        = userProvider;
     _mylistRepository   = mylistRepository;
     _localMylistManager = localMylistManager;
 }
 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);
 }
Ejemplo n.º 13
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);
 }
Ejemplo n.º 14
0
        public SettingsPageViewModel(
            PageManager pageManager,
            NotificationService toastService,
            Services.DialogService dialogService,
            PlayerSettings playerSettings,
            VideoRankingSettings rankingSettings,
            NicoRepoSettings nicoRepoSettings,
            AppearanceSettings appearanceSettings,
            VideoCacheSettings cacheSettings,
            VideoCacheFolderManager videoCacheFolderManager,
            ApplicationLayoutManager applicationLayoutManager,
            VideoFilteringSettings videoFilteringRepository,
            BackupManager backupManager,
            ILoggerFactory loggerFactory
            )
        {
            _notificationService      = toastService;
            RankingSettings           = rankingSettings;
            _HohoemaDialogService     = dialogService;
            PlayerSettings            = playerSettings;
            ActivityFeedSettings      = nicoRepoSettings;
            AppearanceSettings        = appearanceSettings;
            VideoCacheSettings        = cacheSettings;
            _videoCacheFolderManager  = videoCacheFolderManager;
            ApplicationLayoutManager  = applicationLayoutManager;
            _videoFilteringRepository = videoFilteringRepository;
            _backupManager            = backupManager;
            _logger = loggerFactory.CreateLogger <SettingsPageViewModel>();

            // NG Video Owner User Id
            NGVideoOwnerUserIdEnable = _videoFilteringRepository.ToReactivePropertyAsSynchronized(x => x.NGVideoOwnerUserIdEnable)
                                       .AddTo(_CompositeDisposable);
            NGVideoOwnerUserIds = _videoFilteringRepository.GetVideoOwnerIdFilteringEntries();

            OpenUserPageCommand = new RelayCommand <VideoOwnerIdFilteringEntry>(userIdInfo =>
            {
                pageManager.OpenPageWithId(HohoemaPageType.UserInfo, userIdInfo.UserId);
            });

            // NG Keyword on Video Title
            VideoTitleFilteringItems = new ObservableCollection <VideoFilteringTitleViewModel>();

            NGVideoTitleKeywordEnable = _videoFilteringRepository.ToReactivePropertyAsSynchronized(x => x.NGVideoTitleKeywordEnable)
                                        .AddTo(_CompositeDisposable);

            TestText = _videoFilteringRepository.ToReactivePropertyAsSynchronized(x => x.NGVideoTitleTestText)
                       .AddTo(_CompositeDisposable);

            /*
             * NGVideoTitleKeywordError = NGVideoTitleKeywords
             *  .Select(x =>
             *  {
             *      if (x == null) { return null; }
             *
             *      var keywords = x.Split('\r');
             *      var invalidRegex = keywords.FirstOrDefault(keyword =>
             *      {
             *          Regex regex = null;
             *          try
             *          {
             *              regex = new Regex(keyword);
             *          }
             *          catch { }
             *          return regex == null;
             *      });
             *
             *      if (invalidRegex == null)
             *      {
             *          return null;
             *      }
             *      else
             *      {
             *          return $"Error in \"{invalidRegex}\"";
             *      }
             *  })
             *  .ToReadOnlyReactiveProperty()
             *  .AddTo(_CompositeDisposable);
             */
            // アピアランス

            StartupPageType = AppearanceSettings.ToReactivePropertyAsSynchronized(x => x.FirstAppearPageType)
                              .AddTo(_CompositeDisposable);

            var currentTheme = App.GetTheme();

            SelectedTheme = new ReactiveProperty <ElementTheme>(AppearanceSettings.ApplicationTheme, mode: ReactivePropertyMode.DistinctUntilChanged)
                            .AddTo(_CompositeDisposable);

            SelectedTheme.Subscribe(theme =>
            {
                AppearanceSettings.ApplicationTheme = theme;

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

                App.SetTheme(appTheme);

                var appView = ApplicationView.GetForCurrentView();
                if (appTheme == ApplicationTheme.Light)
                {
                    appView.TitleBar.ButtonForegroundColor         = Colors.Black;
                    appView.TitleBar.ButtonHoverBackgroundColor    = Colors.DarkGray;
                    appView.TitleBar.ButtonHoverForegroundColor    = Colors.Black;
                    appView.TitleBar.ButtonInactiveForegroundColor = Colors.Gray;
                }
                else
                {
                    appView.TitleBar.ButtonForegroundColor         = Colors.White;
                    appView.TitleBar.ButtonHoverBackgroundColor    = Colors.DimGray;
                    appView.TitleBar.ButtonHoverForegroundColor    = Colors.White;
                    appView.TitleBar.ButtonInactiveForegroundColor = Colors.DarkGray;
                }
            })
            .AddTo(_CompositeDisposable);



            IsDefaultFullScreen = new ReactiveProperty <bool>(ApplicationView.PreferredLaunchWindowingMode == ApplicationViewWindowingMode.FullScreen)
                                  .AddTo(_CompositeDisposable);
            IsDefaultFullScreen.Subscribe(x =>
            {
                if (x)
                {
                    ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;
                }
                else
                {
                    ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto;
                }
            })
            .AddTo(_CompositeDisposable);

            AppearanceSettings.ObserveProperty(x => x.Locale, isPushCurrentValueAtFirst: false).Subscribe(locale =>
            {
                I18NPortable.I18N.Current.Locale = locale;
            })
            .AddTo(_CompositeDisposable);

            // キャッシュ
            DefaultCacheQuality = VideoCacheSettings.ToReactivePropertyAsSynchronized(x => x.DefaultCacheQuality)
                                  .AddTo(_CompositeDisposable);
            IsAllowDownloadOnMeteredNetwork = VideoCacheSettings.ToReactivePropertyAsSynchronized(x => x.IsAllowDownloadOnMeteredNetwork)
                                              .AddTo(_CompositeDisposable);
            MaxVideoCacheStorageSize = VideoCacheSettings.ToReactivePropertyAsSynchronized(x => x.MaxVideoCacheStorageSize)
                                       .AddTo(_CompositeDisposable);
            OpenCurrentCacheFolderCommand = new RelayCommand(async() =>
            {
                var folder = _videoCacheFolderManager.VideoCacheFolder;
                if (folder != null)
                {
                    await Windows.System.Launcher.LaunchFolderAsync(folder);
                }
            });

            // シェア
            IsLoginTwitter = new ReactiveProperty <bool>(/*TwitterHelper.IsLoggedIn*/ false)
                             .AddTo(_CompositeDisposable);
            TwitterAccountScreenName = new ReactiveProperty <string>(/*TwitterHelper.TwitterUser?.ScreenName ?? ""*/)
                                       .AddTo(_CompositeDisposable);


            StringBuilder sb = new StringBuilder();

            sb.Append(SystemInformation.Instance.ApplicationName)
            .Append(" v").Append(SystemInformation.Instance.ApplicationVersion.ToFormattedString())
            .AppendLine();
            sb.Append(SystemInformation.Instance.OperatingSystem).Append(" ").Append(SystemInformation.Instance.OperatingSystemArchitecture)
            .Append("(").Append(SystemInformation.Instance.OperatingSystemVersion).Append(")")
            .Append(" ").Append(DeviceInfo.Idiom)
            ;
            VersionText = sb.ToString();

            IsDebugModeEnabled = new ReactiveProperty <bool>((App.Current as App).IsDebugModeEnabled, mode: ReactivePropertyMode.DistinctUntilChanged)
                                 .AddTo(_CompositeDisposable);
            IsDebugModeEnabled.Subscribe(isEnabled =>
            {
                (App.Current as App).IsDebugModeEnabled = isEnabled;
            })
            .AddTo(_CompositeDisposable);
        }
Ejemplo n.º 15
0
        public SettingsPageViewModel(
            PageManager pageManager,
            NotificationService toastService,
            Services.DialogService dialogService,
            NGSettings ngSettings,
            RankingSettings rankingSettings,
            ActivityFeedSettings activityFeedSettings,
            AppearanceSettings appearanceSettings,
            CacheSettings cacheSettings
            )
            : base(pageManager)
        {
            ToastNotificationService = toastService;
            NgSettings            = ngSettings;
            RankingSettings       = rankingSettings;
            _HohoemaDialogService = dialogService;
            NgSettings            = ngSettings;
            RankingSettings       = rankingSettings;
            ActivityFeedSettings  = activityFeedSettings;
            AppearanceSettings    = appearanceSettings;
            CacheSettings         = cacheSettings;


            IsLiveAlertEnabled = ActivityFeedSettings.ToReactivePropertyAsSynchronized(x => x.IsLiveAlertEnabled)
                                 .AddTo(_CompositeDisposable);

            // NG Video Owner User Id
            NGVideoOwnerUserIdEnable = NgSettings.ToReactivePropertyAsSynchronized(x => x.NGVideoOwnerUserIdEnable);
            NGVideoOwnerUserIds      = NgSettings.NGVideoOwnerUserIds
                                       .ToReadOnlyReactiveCollection();

            OpenUserPageCommand = new DelegateCommand <UserIdInfo>(userIdInfo =>
            {
                pageManager.OpenPage(HohoemaPageType.UserInfo, userIdInfo.UserId);
            });

            // NG Keyword on Video Title
            NGVideoTitleKeywordEnable = NgSettings.ToReactivePropertyAsSynchronized(x => x.NGVideoTitleKeywordEnable);
            NGVideoTitleKeywords      = new ReactiveProperty <string>();
            NGVideoTitleKeywordError  = NGVideoTitleKeywords
                                        .Select(x =>
            {
                if (x == null)
                {
                    return(null);
                }

                var keywords     = x.Split('\r');
                var invalidRegex = keywords.FirstOrDefault(keyword =>
                {
                    Regex regex = null;
                    try
                    {
                        regex = new Regex(keyword);
                    }
                    catch { }
                    return(regex == null);
                });

                if (invalidRegex == null)
                {
                    return(null);
                }
                else
                {
                    return($"Error in \"{invalidRegex}\"");
                }
            })
                                        .ToReadOnlyReactiveProperty();

            // アピアランス

            var currentTheme = App.GetTheme();

            SelectedApplicationTheme = new ReactiveProperty <string>(currentTheme.ToString(), mode: ReactivePropertyMode.DistinctUntilChanged);

            SelectedApplicationTheme.Subscribe(x =>
            {
                var type = (ApplicationTheme)Enum.Parse(typeof(ApplicationTheme), x);
                App.SetTheme(type);

                // 一度だけトースト通知
                if (!ThemeChanged)
                {
                    toastService.ShowToast("Hohoemaを再起動するとテーマが適用されます。", "");
                }

                ThemeChanged = true;
                RaisePropertyChanged(nameof(ThemeChanged));
            });

            IsTVModeEnable = AppearanceSettings
                             .ToReactivePropertyAsSynchronized(x => x.IsForceTVModeEnable);
            IsXbox = Services.Helpers.DeviceTypeHelper.IsXbox;

            IsForceMobileModeEnable = AppearanceSettings
                                      .ToReactivePropertyAsSynchronized(x => x.IsForceMobileModeEnable);



            IsDefaultFullScreen = new ReactiveProperty <bool>(ApplicationView.PreferredLaunchWindowingMode == ApplicationViewWindowingMode.FullScreen);
            IsDefaultFullScreen.Subscribe(x =>
            {
                if (x)
                {
                    ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;
                }
                else
                {
                    ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto;
                }
            });

            StartupPageType = AppearanceSettings
                              .ToReactivePropertyAsSynchronized(x => x.StartupPageType);


            // キャッシュ
            DefaultCacheQuality                 = CacheSettings.ToReactivePropertyAsSynchronized(x => x.DefaultCacheQuality);
            IsAllowDownloadOnMeteredNetwork     = CacheSettings.ToReactivePropertyAsSynchronized(x => x.IsAllowDownloadOnMeteredNetwork);
            DefaultCacheQualityOnMeteredNetwork = CacheSettings.ToReactivePropertyAsSynchronized(x => x.DefaultCacheQualityOnMeteredNetwork);

            // シェア
            IsLoginTwitter           = new ReactiveProperty <bool>(/*TwitterHelper.IsLoggedIn*/ false);
            TwitterAccountScreenName = new ReactiveProperty <string>(/*TwitterHelper.TwitterUser?.ScreenName ?? ""*/);


            // アバウト
            var version = Windows.ApplicationModel.Package.Current.Id.Version;

#if DEBUG
            VersionText = $"{version.Major}.{version.Minor}.{version.Build} DEBUG";
#else
            VersionText = $"{version.Major}.{version.Minor}.{version.Build}";
#endif


            var dispatcher = Window.Current.CoreWindow.Dispatcher;
            LisenceSummary.Load()
            .ContinueWith(async prevResult =>
            {
                await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    var lisenceSummary = prevResult.Result;

                    LisenceItems = lisenceSummary.Items
                                   .OrderBy(x => x.Name)
                                   .Select(x => new LisenceItemViewModel(x))
                                   .ToList();
                    RaisePropertyChanged(nameof(LisenceItems));
                });
            });


            IsDebugModeEnabled = new ReactiveProperty <bool>((App.Current as App).IsDebugModeEnabled, mode: ReactivePropertyMode.DistinctUntilChanged);
            IsDebugModeEnabled.Subscribe(isEnabled =>
            {
                (App.Current as App).IsDebugModeEnabled = isEnabled;
            })
            .AddTo(_CompositeDisposable);
        }
        public OwnerMylistManagePageViewModel(
            NiconicoSession niconicoSession,
            PageManager pageManager,
            Services.DialogService dialogService,
            ApplicationLayoutManager applicationLayoutManager,
            LoginUserOwnedMylistManager userMylistManager,
            PlaylistPlayAllCommand playlistPlayAllCommand
            )
        {
            _dispatcherQueue         = DispatcherQueue.GetForCurrentThread();
            _niconicoSession         = niconicoSession;
            _pageManager             = pageManager;
            _dialogService           = dialogService;
            ApplicationLayoutManager = applicationLayoutManager;
            _userMylistManager       = userMylistManager;
            PlaylistPlayAllCommand   = playlistPlayAllCommand;

            ItemsView = new AdvancedCollectionView(_sourcePlaylistItems);

            OpenMylistCommand = new ReactiveCommand <LoginUserMylistPlaylist>()
                                .AddTo(_CompositeDisposable);

            OpenMylistCommand.Subscribe(listItem =>
            {
                _pageManager.OpenPageWithId(HohoemaPageType.Mylist, listItem.MylistId);
            });

            AddMylistGroupCommand = new RelayCommand(async() =>
            {
                MylistGroupEditData data = new MylistGroupEditData()
                {
                    Name             = "",
                    Description      = "",
                    IsPublic         = false,
                    DefaultSortKey   = MylistSortKey.AddedAt,
                    DefaultSortOrder = MylistSortOrder.Desc
                };

                // 成功するかキャンセルが押されるまで繰り返す
                while (true)
                {
                    if (true == await _dialogService.ShowCreateMylistGroupDialogAsync(data))
                    {
                        var result = await _userMylistManager.AddMylist(
                            data.Name,
                            data.Description,
                            data.IsPublic,
                            data.DefaultSortKey,
                            data.DefaultSortOrder
                            );

                        if (result != null)
                        {
                            await RefreshPlaylistItems();
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
                                                     , () => _userMylistManager.Mylists.Count < _userMylistManager.MaxMylistGroupCountCurrentUser
                                                     );

            RemoveMylistGroupCommand = new RelayCommand <LoginUserMylistPlaylist>(async(mylist) =>
            {
                if (mylist.MylistId.IsWatchAfterMylist)
                {
                    return;
                }

                // 確認ダイアログ
                var contentMessage = "ConfirmDeleteX_ImpossibleReDo".Translate(mylist.Name);

                var dialog = new MessageDialog(contentMessage, "ConfirmDeleteX".Translate("Mylist".Translate()));
                dialog.Commands.Add(new UICommand("Delete".Translate(), async(i) =>
                {
                    if (await _userMylistManager.RemoveMylist(mylist.MylistId))
                    {
                        await RefreshPlaylistItems();
                    }
                }));

                dialog.Commands.Add(new UICommand("Cancel".Translate()));
                dialog.CancelCommandIndex  = 1;
                dialog.DefaultCommandIndex = 1;

                await dialog.ShowAsync();
            });


            EditMylistGroupCommand = new RelayCommand <LoginUserMylistPlaylist>(async mylist =>
            {
                if (mylist.MylistId.IsWatchAfterMylist)
                {
                    return;
                }

                MylistGroupEditData data = new MylistGroupEditData()
                {
                    Name             = mylist.Name,
                    Description      = mylist.Description,
                    IsPublic         = mylist.IsPublic,
                    DefaultSortKey   = mylist.DefaultSortKey,
                    DefaultSortOrder = mylist.DefaultSortOrder,
                };

                // 成功するかキャンセルが押されるまで繰り返す
                while (true)
                {
                    if (true == await _dialogService.ShowCreateMylistGroupDialogAsync(data))
                    {
                        if (await mylist.UpdateMylistInfo(data.Name, data.Description, data.IsPublic, data.DefaultSortKey, data.DefaultSortOrder))
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            });
        }
Ejemplo n.º 17
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);
        }
 public ShereLiveInfoContentViewModel(NicoLiveVideo liveVideo, Services.DialogService dialogService)
 {
     NicoLiveVideo          = liveVideo;
     HohoemaDialogService   = dialogService;
     IsStillLoggedInTwitter = new ReactiveProperty <bool>(false /*!TwitterHelper.IsLoggedIn*/);
 }
Ejemplo n.º 19
0
        public UserMylistPageViewModel(
            Services.PageManager pageMaanger,
            Services.DialogService dialogService,
            NiconicoSession niconicoSession,
            UserProvider userProvider,
            LoginUserMylistProvider loginUserMylistProvider,
            OtherOwneredMylistManager otherOwneredMylistManager,
            UserMylistManager userMylistManager,
            LocalMylistManager localMylistManager,
            HohoemaPlaylist hohoemaPlaylist
            )
            : base(pageMaanger, useDefaultPageTitle: false)
        {
            DialogService             = dialogService;
            NiconicoSession           = niconicoSession;
            UserProvider              = userProvider;
            LoginUserMylistProvider   = loginUserMylistProvider;
            OtherOwneredMylistManager = otherOwneredMylistManager;
            UserMylistManager         = userMylistManager;
            LocalMylistManager        = localMylistManager;
            HohoemaPlaylist           = hohoemaPlaylist;
            IsLoginUserMylist         = new ReactiveProperty <bool>(false);

            OpenMylistCommand = new ReactiveCommand <Interfaces.IMylist>();

            OpenMylistCommand.Subscribe(listItem =>
            {
                PageManager.OpenPage(HohoemaPageType.Mylist,
                                     new MylistPagePayload()
                {
                    Id = listItem.Id, Origin = listItem.ToMylistOrigin()
                }
                                     .ToParameterString()
                                     );
            });

            AddMylistGroupCommand = new DelegateCommand(async() =>
            {
                MylistGroupEditData data = new MylistGroupEditData()
                {
                    Name              = "新しいマイリスト",
                    Description       = "",
                    IsPublic          = false,
                    MylistDefaultSort = MylistDefaultSort.Latest,
                    IconType          = IconType.Default,
                };

                // 成功するかキャンセルが押されるまで繰り返す
                while (true)
                {
                    if (true == await DialogService.ShowCreateMylistGroupDialogAsync(data))
                    {
                        var result = await UserMylistManager.AddMylist(
                            data.Name,
                            data.Description,
                            data.IsPublic,
                            data.MylistDefaultSort,
                            data.IconType
                            );

                        if (result == Mntone.Nico2.ContentManageResult.Success)
                        {
                            await ResetList();
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
                                                        , () => UserMylistManager.Mylists.Count < UserMylistManager.MaxMylistGroupCountCurrentUser
                                                        );

            RemoveMylistGroupCommand = new DelegateCommand <Interfaces.IMylist>(async(item) =>
            {
                var mylistOrigin = item.ToMylistOrigin();
                if (mylistOrigin == PlaylistOrigin.Local)
                {
                    if (item.Id == HohoemaPlaylist.WatchAfterPlaylistId)
                    {
                        return;
                    }
                }
                else if (mylistOrigin == PlaylistOrigin.LoginUser)
                {
                    if (item.Id == "0")
                    {
                        return;
                    }
                }

                // 確認ダイアログ
                var originText     = mylistOrigin == PlaylistOrigin.Local ? "ローカルマイリスト" : "マイリスト";
                var contentMessage = $"{item.Label} を削除してもよろしいですか?(変更は元に戻せません)";

                var dialog = new MessageDialog(contentMessage, $"{originText}削除の確認");
                dialog.Commands.Add(new UICommand("削除", async(i) =>
                {
                    if (mylistOrigin == PlaylistOrigin.Local)
                    {
                        LocalMylistManager.RemoveCommand.Execute(item as LocalMylistGroup);
                    }
                    else if (mylistOrigin == PlaylistOrigin.LoginUser)
                    {
                        await UserMylistManager.RemoveMylist(item.Id);
                        //                        await UpdateUserMylist();
                    }
                }));

                dialog.Commands.Add(new UICommand("キャンセル"));
                dialog.CancelCommandIndex  = 1;
                dialog.DefaultCommandIndex = 1;

                await dialog.ShowAsync();
            });


            EditMylistGroupCommand = new DelegateCommand <Interfaces.IMylist>(async item =>
            {
                var mylistOrigin = item.ToMylistOrigin();
                if (mylistOrigin == PlaylistOrigin.Local)
                {
                    if (item.Id == HohoemaPlaylist.WatchAfterPlaylistId)
                    {
                        return;
                    }
                }
                else if (mylistOrigin == PlaylistOrigin.LoginUser)
                {
                    if (item.Id == "0")
                    {
                        return;
                    }
                }

                if (mylistOrigin == PlaylistOrigin.Local)
                {
                    var localMylist = item as LocalMylistGroup;
                    var resultText  = await DialogService.GetTextAsync("プレイリスト名を変更",
                                                                       localMylist.Label,
                                                                       localMylist.Label,
                                                                       (tempName) => !string.IsNullOrWhiteSpace(tempName)
                                                                       );

                    if (!string.IsNullOrWhiteSpace(resultText))
                    {
                        localMylist.Label = resultText;
                    }
                }


                if (mylistOrigin == PlaylistOrigin.LoginUser)
                {
                    var mylistGroupListItem   = item as UserOwnedMylist;
                    var selectedMylistGroupId = mylistGroupListItem.Id;

                    if (selectedMylistGroupId == null)
                    {
                        return;
                    }

                    var mylistGroup          = UserMylistManager.GetMylistGroup(selectedMylistGroupId);
                    MylistGroupEditData data = new MylistGroupEditData()
                    {
                        Name              = mylistGroup.Label,
                        Description       = mylistGroup.Description,
                        IsPublic          = mylistGroup.IsPublic,
                        MylistDefaultSort = mylistGroup.Sort,
                        IconType          = mylistGroup.IconType,
                    };

                    // 成功するかキャンセルが押されるまで繰り返す
                    while (true)
                    {
                        if (true == await DialogService.ShowCreateMylistGroupDialogAsync(data))
                        {
                            mylistGroup.Label       = data.Name;
                            mylistGroup.Description = data.Description;
                            mylistGroup.IsPublic    = data.IsPublic;
                            mylistGroup.Sort        = data.MylistDefaultSort;
                            mylistGroup.IconType    = data.IconType;
                            var result = await LoginUserMylistProvider.UpdateMylist(mylistGroup);

                            if (result == Mntone.Nico2.ContentManageResult.Success)
                            {
                                // TODO: UI上のマイリスト表示を更新する
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            });

            PlayAllCommand = new DelegateCommand <Interfaces.IMylist>((mylist) =>
            {
                if (mylist.ItemCount == 0)
                {
                    return;
                }

                HohoemaPlaylist.Play(mylist);
            });



            AddLocalMylistCommand = new DelegateCommand(async() =>
            {
                var name = await DialogService.GetTextAsync("新しいローカルマイリスト名を入力", "ローカルマイリスト名", "",
                                                            (s) =>
                {
                    if (string.IsNullOrWhiteSpace(s))
                    {
                        return(false);
                    }

                    if (LocalMylistManager.Mylists.Any(x => x.Label == s))
                    {
                        return(false);
                    }

                    return(true);
                });

                if (name != null)
                {
                    LocalMylistManager.Mylists.Add(new LocalMylistGroup(Guid.NewGuid().ToString(), name));
                }
            });
        }
Ejemplo n.º 20
0
        public SettingsPageViewModel(
            PageManager pageManager,
            NotificationService toastService,
            Services.DialogService dialogService,
            PlayerSettings playerSettings,
            NGSettings ngSettings,
            RankingSettings rankingSettings,
            ActivityFeedSettings activityFeedSettings,
            AppearanceSettings appearanceSettings,
            CacheSettings cacheSettings,
            ApplicationLayoutManager applicationLayoutManager
            )
        {
            ToastNotificationService = toastService;
            NgSettings               = ngSettings;
            RankingSettings          = rankingSettings;
            _HohoemaDialogService    = dialogService;
            PlayerSettings           = playerSettings;
            NgSettings               = ngSettings;
            RankingSettings          = rankingSettings;
            ActivityFeedSettings     = activityFeedSettings;
            AppearanceSettings       = appearanceSettings;
            CacheSettings            = cacheSettings;
            ApplicationLayoutManager = applicationLayoutManager;

            // NG Video Owner User Id
            NGVideoOwnerUserIdEnable = NgSettings.ToReactivePropertyAsSynchronized(x => x.NGVideoOwnerUserIdEnable);
            NGVideoOwnerUserIds      = NgSettings.NGVideoOwnerUserIds
                                       .ToReadOnlyReactiveCollection();

            OpenUserPageCommand = new DelegateCommand <UserIdInfo>(userIdInfo =>
            {
                pageManager.OpenPageWithId(HohoemaPageType.UserInfo, userIdInfo.UserId);
            });

            // NG Keyword on Video Title
            NGVideoTitleKeywordEnable = NgSettings.ToReactivePropertyAsSynchronized(x => x.NGVideoTitleKeywordEnable);
            NGVideoTitleKeywords      = new ReactiveProperty <string>();
            NGVideoTitleKeywordError  = NGVideoTitleKeywords
                                        .Select(x =>
            {
                if (x == null)
                {
                    return(null);
                }

                var keywords     = x.Split('\r');
                var invalidRegex = keywords.FirstOrDefault(keyword =>
                {
                    Regex regex = null;
                    try
                    {
                        regex = new Regex(keyword);
                    }
                    catch { }
                    return(regex == null);
                });

                if (invalidRegex == null)
                {
                    return(null);
                }
                else
                {
                    return($"Error in \"{invalidRegex}\"");
                }
            })
                                        .ToReadOnlyReactiveProperty();

            // アピアランス

            var currentTheme = App.GetTheme();

            SelectedTheme = new ReactiveProperty <ElementTheme>(AppearanceSettings.Theme, mode: ReactivePropertyMode.DistinctUntilChanged);

            SelectedTheme.Subscribe(theme =>
            {
                AppearanceSettings.Theme = theme;

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

                App.SetTheme(appTheme);

                var appView = ApplicationView.GetForCurrentView();
                if (appTheme == ApplicationTheme.Light)
                {
                    appView.TitleBar.ButtonForegroundColor         = Colors.Black;
                    appView.TitleBar.ButtonHoverBackgroundColor    = Colors.DarkGray;
                    appView.TitleBar.ButtonHoverForegroundColor    = Colors.Black;
                    appView.TitleBar.ButtonInactiveForegroundColor = Colors.Gray;
                }
                else
                {
                    appView.TitleBar.ButtonForegroundColor         = Colors.White;
                    appView.TitleBar.ButtonHoverBackgroundColor    = Colors.DimGray;
                    appView.TitleBar.ButtonHoverForegroundColor    = Colors.White;
                    appView.TitleBar.ButtonInactiveForegroundColor = Colors.DarkGray;
                }
            });



            IsDefaultFullScreen = new ReactiveProperty <bool>(ApplicationView.PreferredLaunchWindowingMode == ApplicationViewWindowingMode.FullScreen);
            IsDefaultFullScreen.Subscribe(x =>
            {
                if (x)
                {
                    ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;
                }
                else
                {
                    ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto;
                }
            });

            StartupPageType = AppearanceSettings
                              .ToReactivePropertyAsSynchronized(x => x.StartupPageType);

            AppearanceSettings.ObserveProperty(x => x.Locale, isPushCurrentValueAtFirst: false).Subscribe(locale =>
            {
                I18NPortable.I18N.Current.Locale = locale;
            });

            // キャッシュ
            DefaultCacheQuality                 = CacheSettings.ToReactivePropertyAsSynchronized(x => x.DefaultCacheQuality);
            IsAllowDownloadOnMeteredNetwork     = CacheSettings.ToReactivePropertyAsSynchronized(x => x.IsAllowDownloadOnMeteredNetwork);
            DefaultCacheQualityOnMeteredNetwork = CacheSettings.ToReactivePropertyAsSynchronized(x => x.DefaultCacheQualityOnMeteredNetwork);

            // シェア
            IsLoginTwitter           = new ReactiveProperty <bool>(/*TwitterHelper.IsLoggedIn*/ false);
            TwitterAccountScreenName = new ReactiveProperty <string>(/*TwitterHelper.TwitterUser?.ScreenName ?? ""*/);


            // アバウト
            var version = Windows.ApplicationModel.Package.Current.Id.Version;

#if DEBUG
            VersionText = $"{version.Major}.{version.Minor}.{version.Build} DEBUG";
#else
            VersionText = $"{version.Major}.{version.Minor}.{version.Build}";
#endif


            var dispatcher = Window.Current.CoreWindow.Dispatcher;
            LisenceSummary.Load()
            .ContinueWith(async prevResult =>
            {
                await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    var lisenceSummary = prevResult.Result;

                    LisenceItems = lisenceSummary.Items
                                   .OrderBy(x => x.Name)
                                   .Select(x => new LisenceItemViewModel(x))
                                   .ToList();
                    RaisePropertyChanged(nameof(LisenceItems));
                });
            });


            IsDebugModeEnabled = new ReactiveProperty <bool>((App.Current as App).IsDebugModeEnabled, mode: ReactivePropertyMode.DistinctUntilChanged);
            IsDebugModeEnabled.Subscribe(isEnabled =>
            {
                (App.Current as App).IsDebugModeEnabled = isEnabled;
            })
            .AddTo(_CompositeDisposable);
        }
Ejemplo n.º 21
0
        public UserMylistPageViewModel(
            ApplicationLayoutManager applicationLayoutManager,
            Services.PageManager pageManager,
            Services.DialogService dialogService,
            NiconicoSession niconicoSession,
            UserProvider userProvider,
            MylistRepository mylistRepository,
            UserMylistManager userMylistManager,
            LocalMylistManager localMylistManager,
            HohoemaPlaylist hohoemaPlaylist,
            CreateLocalMylistCommand createLocalMylistCommand
            )
        {
            ApplicationLayoutManager = applicationLayoutManager;
            PageManager              = pageManager;
            DialogService            = dialogService;
            NiconicoSession          = niconicoSession;
            UserProvider             = userProvider;
            _mylistRepository        = mylistRepository;
            _userMylistManager       = userMylistManager;
            _localMylistManager      = localMylistManager;
            CreateLocalMylistCommand = createLocalMylistCommand;
            HohoemaPlaylist          = hohoemaPlaylist;
            IsLoginUserMylist        = new ReactiveProperty <bool>(false);

            OpenMylistCommand = new ReactiveCommand <IPlaylist>();

            OpenMylistCommand.Subscribe(listItem =>
            {
                PageManager.OpenPage(HohoemaPageType.Mylist, $"id={listItem.Id}");
            });

            AddMylistGroupCommand = new DelegateCommand(async() =>
            {
                MylistGroupEditData data = new MylistGroupEditData()
                {
                    Name              = "",
                    Description       = "",
                    IsPublic          = false,
                    MylistDefaultSort = MylistDefaultSort.Latest,
                    IconType          = IconType.Default,
                };

                // 成功するかキャンセルが押されるまで繰り返す
                while (true)
                {
                    if (true == await DialogService.ShowCreateMylistGroupDialogAsync(data))
                    {
                        var result = await _userMylistManager.AddMylist(
                            data.Name,
                            data.Description,
                            data.IsPublic,
                            data.MylistDefaultSort,
                            data.IconType
                            );

                        if (result == Mntone.Nico2.ContentManageResult.Success)
                        {
                            await ResetList();
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
                                                        , () => _userMylistManager.Mylists.Count < _userMylistManager.MaxMylistGroupCountCurrentUser
                                                        );

            RemoveMylistGroupCommand = new DelegateCommand <Interfaces.IPlaylist>(async(item) =>
            {
                {
                    if (item is LocalPlaylist localPlaylist)
                    {
                        if (localPlaylist.IsWatchAfterPlaylist())
                        {
                            return;
                        }
                    }
                    else if (item is LoginUserMylistPlaylist loginUserMylist)
                    {
                        if (loginUserMylist.IsDefaultMylist())
                        {
                            return;
                        }
                    }
                }

                // 確認ダイアログ
                var contentMessage = "ConfirmDeleteX_ImpossibleReDo".Translate(item.Label);

                var dialog = new MessageDialog(contentMessage, "ConfirmDeleteX".Translate(item.GetOrigin().Translate()));
                dialog.Commands.Add(new UICommand("Delete".Translate(), async(i) =>
                {
                    if (item is LocalPlaylist localPlaylist)
                    {
                        _localMylistManager.RemovePlaylist(localPlaylist);
                    }
                    else if (item is LoginUserMylistPlaylist loginUserMylist)
                    {
                        await _userMylistManager.RemoveMylist(item.Id);
                    }
                }));

                dialog.Commands.Add(new UICommand("Cancel".Translate()));
                dialog.CancelCommandIndex  = 1;
                dialog.DefaultCommandIndex = 1;

                await dialog.ShowAsync();
            });


            EditMylistGroupCommand = new DelegateCommand <Interfaces.IPlaylist>(async item =>
            {
                if (item is LocalPlaylist localPlaylist)
                {
                    if (item.Id == HohoemaPlaylist.WatchAfterPlaylistId)
                    {
                        return;
                    }

                    var resultText = await DialogService.GetTextAsync("RenameLocalPlaylist".Translate(),
                                                                      localPlaylist.Label,
                                                                      localPlaylist.Label,
                                                                      (tempName) => !string.IsNullOrWhiteSpace(tempName)
                                                                      );

                    if (!string.IsNullOrWhiteSpace(resultText))
                    {
                        localPlaylist.Label = resultText;
                    }
                }
                else if (item is LoginUserMylistPlaylist loginUserMylist)
                {
                    if (loginUserMylist.IsDefaultMylist())
                    {
                        return;
                    }

                    MylistGroupEditData data = new MylistGroupEditData()
                    {
                        Name              = loginUserMylist.Label,
                        Description       = loginUserMylist.Description,
                        IsPublic          = loginUserMylist.IsPublic,
                        MylistDefaultSort = loginUserMylist.DefaultSort,
                        IconType          = loginUserMylist.IconType,
                    };

                    // 成功するかキャンセルが押されるまで繰り返す
                    while (true)
                    {
                        if (true == await DialogService.ShowCreateMylistGroupDialogAsync(data))
                        {
                            var result = await loginUserMylist.UpdateMylist(data);

                            if (result == Mntone.Nico2.ContentManageResult.Success)
                            {
                                loginUserMylist.Label       = data.Name;
                                loginUserMylist.Description = data.Description;
                                loginUserMylist.IsPublic    = data.IsPublic;
                                loginUserMylist.DefaultSort = data.MylistDefaultSort;
                                loginUserMylist.IconType    = data.IconType;

                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            });
        }
Ejemplo n.º 22
0
 public ChatView()
 {
     InitializeComponent();
     dialogService = new Services.DialogService();
 }
Ejemplo n.º 23
0
        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);
             ||
             || }
             ||
             ||
             ||});
             ||
             ||
             */
        }
Ejemplo n.º 24
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();
        }
Ejemplo n.º 25
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);
             ||
             || }
             ||
             ||
             ||});
             ||
             ||
             */
        }