Exemple #1
0
        public SettingsPageViewModel(
            HohoemaApp hohoemaApp
            , PageManager pageManager
            , RankingChoiceDialogService rakingChoiceDialog
            , EditAutoCacheConditionDialogService editAutoCacheDialog
            , AcceptCacheUsaseDialogService cacheAcceptDialogService
            , ToastNotificationService toastService
            )
            : base(hohoemaApp, pageManager)
        {
            RankingChoiceDialogService          = rakingChoiceDialog;
            EditAutoCacheConditionDialogService = editAutoCacheDialog;
            AcceptCacheUsaseDialogService       = cacheAcceptDialogService;
            ToastNotificationService            = toastService;

            SettingItems = ((IEnumerable <HohoemaSettingsKind>)Enum.GetValues(typeof(HohoemaSettingsKind)))
                           .Where(x => Util.DeviceTypeHelper.IsXbox ? x != HohoemaSettingsKind.Share : true)
                           .Select(x => KindToVM(x))
                           .ToList();

            CurrentSettingsContent = new ReactiveProperty <SettingsPageContentViewModel>();


            CurrentSettingsContent.Subscribe(x =>
            {
                _PrevSettingsContent?.Leaved();

                /*
                 * if (x != null)
                 * {
                 *  AddSubsitutionBackNavigateAction("settings_content_selection"
                 *      , () =>
                 *      {
                 *          CurrentSettingsContent.Value = null;
                 *
                 *          return true;
                 *      });
                 * }
                 * else
                 * {
                 *  RemoveSubsitutionBackNavigateAction("settings_content_selection");
                 * }
                 */

                _PrevSettingsContent = x;
                x?.Entered();
            });
        }
Exemple #2
0
        public FilteringSettingsPageContentViewModel(HohoemaApp hohoemaApp, PageManager pageManager, RankingChoiceDialogService rankingChoiceDialog)
            : base("除外設定", HohoemaSettingsKind.Filtering)
        {
            _HohoemaApp                 = hohoemaApp;
            _NGSettings                 = _HohoemaApp.UserSettings.NGSettings;
            _RankingSettings            = _HohoemaApp.UserSettings.RankingSettings;
            _RankingChoiceDialogService = rankingChoiceDialog;


            SelectableCategories = new ObservableCollection <RankingCategorySettingsListItem>(
                _RankingSettings.MiddlePriorityCategory
                .Select(x => new RankingCategorySettingsListItem(x, this))
                .ToList()
                );

            FavCategories = new ObservableCollection <RankingCategorySettingsListItem>(
                _RankingSettings.HighPriorityCategory
                .Select(x => new RankingCategorySettingsListItem(x, this))
                .ToList()
                );



            AddFavRankingCategory = new DelegateCommand(async() =>
            {
                var items       = _RankingSettings.MiddlePriorityCategory.ToArray();
                var choiceItems = await _RankingChoiceDialogService.ShowRankingCategoryChoiceDialog("好きなカテゴリを選択", items);

                if (choiceItems != null)
                {
                    foreach (var choiceItem in choiceItems)
                    {
                        var removeTarget = SelectableCategories.SingleOrDefault(x => x.CategoryInfo == choiceItem);
                        SelectableCategories.Remove(removeTarget);

                        FavCategories.Add(new RankingCategorySettingsListItem(choiceItem, this));
                    }
                }

                ApplyAllPriorityCategoriesToRankingSettings();
            });


            DislikeCategories = new ObservableCollection <RankingCategorySettingsListItem>(
                _RankingSettings.LowPriorityCategory
                .Select(x => new RankingCategorySettingsListItem(x, this))
                .ToList()
                );

            AddDislikeRankingCategory = new DelegateCommand(async() =>
            {
                var items       = _RankingSettings.MiddlePriorityCategory.ToArray();
                var choiceItems = await _RankingChoiceDialogService.ShowRankingCategoryChoiceDialog("非表示にするカテゴリを選択", items);

                if (choiceItems != null)
                {
                    foreach (var choiceItem in choiceItems)
                    {
                        var removeTarget = SelectableCategories.SingleOrDefault(x => x.CategoryInfo == choiceItem);
                        SelectableCategories.Remove(removeTarget);

                        DislikeCategories.Add(new RankingCategorySettingsListItem(choiceItem, this));
                    }
                }

                ApplyAllPriorityCategoriesToRankingSettings();
            });



            // 入れ替え説明テキストの表示フラグ
            FavCategories.ObserveProperty(x => x.Count)
            .Subscribe(x => IsDisplayReorderText = x >= 2);


            // NG Video


            // NG Video
            NGVideoIdEnable = _NGSettings.ToReactivePropertyAsSynchronized(x => x.NGVideoIdEnable);
            NGVideoIds      = _NGSettings.NGVideoIds
                              .ToReadOnlyReactiveCollection(x =>
                                                            RemovableSettingsListItemHelper.VideoIdInfoToRemovableListItemVM(x, OnRemoveNGVideoIdFromList)
                                                            );

            // NG Video Owner User Id
            NGVideoOwnerUserIdEnable = _NGSettings.ToReactivePropertyAsSynchronized(x => x.NGVideoOwnerUserIdEnable);
            NGVideoOwnerUserIds      = _NGSettings.NGVideoOwnerUserIds
                                       .ToReadOnlyReactiveCollection(x =>
                                                                     new SelectableItem <UserIdInfo>(x, (y) =>
            {
                pageManager.OpenPage(HohoemaPageType.UserInfo, x.UserId);
            })
                                                                     );

            // NG Keyword on Video Title
            NGVideoTitleKeywordEnable = _NGSettings.ToReactivePropertyAsSynchronized(x => x.NGVideoTitleKeywordEnable);
            NGVideoTitleKeywords      = _NGSettings.NGVideoTitleKeywords.ToReadOnlyReactiveCollection(
                x => new NGKeywordViewModel(x, OnRemoveNGTitleKeyword)
                );

            // NG動画タイトルキーワードを追加するコマンド
            NGVideoTitleKeyword = new ReactiveProperty <string>("");

            AddNewNGVideoTitleKeywordCommand = NGVideoTitleKeyword
                                               .Select(x => !string.IsNullOrWhiteSpace(x))
                                               .ToReactiveCommand();

            AddNewNGVideoTitleKeywordCommand.Subscribe(_ =>
            {
                _NGSettings.NGVideoTitleKeywords.Add(new NGKeyword()
                {
                    TestText = "",
                    Keyword  = NGVideoTitleKeyword.Value
                });

                NGVideoTitleKeyword.Value = "";
            });


            NGCommentUserIdEnable = _NGSettings.ToReactivePropertyAsSynchronized(x => x.NGCommentUserIdEnable);
            NGCommentUserIds      = _NGSettings.NGCommentUserIds
                                    .ToReadOnlyReactiveCollection(x =>
                                                                  RemovableSettingsListItemHelper.UserIdInfoToRemovableListItemVM(x, OnRemoveNGCommentUserIdFromList)
                                                                  );

            NGCommentKeywordEnable = _NGSettings.ToReactivePropertyAsSynchronized(x => x.NGCommentKeywordEnable);
            NGCommentKeywords      = _NGSettings.NGCommentKeywords.ToReadOnlyReactiveCollection(
                x => new NGKeywordViewModel(x, OnRemoveNGCommentKeyword)
                );



            NGCommentScoreTypes = ((IEnumerable <NGCommentScore>)Enum.GetValues(typeof(NGCommentScore))).ToList();

            SelectedNGCommentScore = _NGSettings.ToReactivePropertyAsSynchronized(x => x.NGCommentScoreType);

            NGCommentKeyword = new ReactiveProperty <string>("");

            AddNewNGCommentKeywordCommand = NGCommentKeyword
                                            .Select(x => !string.IsNullOrWhiteSpace(x))
                                            .ToReactiveCommand();

            AddNewNGCommentKeywordCommand.Subscribe(_ =>
            {
                _NGSettings.NGCommentKeywords.Add(new NGKeyword()
                {
                    TestText = "",
                    Keyword  = NGCommentKeyword.Value
                });
                NGCommentKeyword.Value = "";
            });
        }