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(); }); }
public CacheSettingsPageContentViewModel( HohoemaApp hohoemaApp , EditAutoCacheConditionDialogService editDialogService , AcceptCacheUsaseDialogService cacheConfirmDialogService ) : base("キャッシュ", HohoemaSettingsKind.Cache) { _HohoemaApp = hohoemaApp; _CacheSettings = _HohoemaApp.UserSettings.CacheSettings; _EditDialogService = editDialogService; _AcceptCacheUsaseDialogService = cacheConfirmDialogService; IsAutoCacheOnPlayEnable = _CacheSettings.ToReactivePropertyAsSynchronized(x => x.IsAutoCacheOnPlayEnable); IsUserAcceptRegalNotice = _CacheSettings.ToReactivePropertyAsSynchronized(x => x.IsUserAcceptedCache); IsCacheFolderSelectedButNotExist = new ReactiveProperty <bool>(false); ReadCacheAcceptTextCommand = new DelegateCommand(async() => { await cacheConfirmDialogService.ShowAcceptCacheTextDialog(); }); AddAutoCacheConditionCommand = new DelegateCommand(() => { _CacheSettings.CacheOnPlayTagConditions.Add(new TagCondition() { Label = "NewCondition" }); }); AutoCacheConditions = _CacheSettings.CacheOnPlayTagConditions.ToReadOnlyReactiveCollection( x => new AutoCacheConditionViewModel(_CacheSettings, x) ); EditAutoCacheConditionCommnad = new DelegateCommand <AutoCacheConditionViewModel>(async(conditionVM) => { await EditAutoCacheCondition(conditionVM); }); Observable.Merge( IsUserAcceptRegalNotice.ToUnit(), IsAutoCacheOnPlayEnable.ToUnit() ) .Subscribe(async _ => { await _CacheSettings.Save().ConfigureAwait(false); }); CacheFolderStateDescription = new ReactiveProperty <string>(""); CacheSaveFolderPath = new ReactiveProperty <string>(""); OpenCurrentCacheFolderCommand = new DelegateCommand(async() => { await RefreshCacheSaveFolderStatus(); var folder = await _HohoemaApp.GetVideoCacheFolder(); if (folder != null) { await Launcher.LaunchFolderAsync(folder); } }); IsEnableCache = _HohoemaApp.UserSettings .CacheSettings.ToReactivePropertyAsSynchronized(x => x.IsEnableCache); IsEnableCache .Where(x => x) .Where(_ => false == _HohoemaApp.UserSettings.CacheSettings.IsUserAcceptedCache) .Subscribe(async x => { // ユーザーがキャッシュ機能利用に対する承諾を行っていない場合に // 確認のダイアログを表示する var result = await _AcceptCacheUsaseDialogService.ShowConfirmAcceptCacheDialog(); if (result) { _HohoemaApp.UserSettings.CacheSettings.IsUserAcceptedCache = true; await RefreshCacheSaveFolderStatus(); } else { IsEnableCache.Value = false; } }); IsEnableCache.Subscribe(async _ => { await RefreshCacheSaveFolderStatus(); }); ChangeCacheFolderCommand = new DelegateCommand(async() => { if (await _HohoemaApp.ChangeUserDataFolder()) { await RefreshCacheSaveFolderStatus(); } }); }