private async Task RefreshCacheSaveFolderStatus() { var cacheFolderAccessState = await HohoemaApp.GetVideoCacheFolderState(); CacheSaveFolderPath.Value = ""; switch (cacheFolderAccessState) { case CacheFolderAccessState.NotAccepted: CacheFolderStateDescription.Value = "キャッシュ利用の同意が必要です。 「キャッシュを有効にする」ボタンを押すと同意文書が表示されます。"; break; case CacheFolderAccessState.NotEnabled: CacheFolderStateDescription.Value = "キャッシュの有効化が必要です"; break; case CacheFolderAccessState.NotSelected: CacheFolderStateDescription.Value = "フォルダを選択するとキャッシュ機能が使えるようになります"; break; case CacheFolderAccessState.SelectedButNotExist: CacheFolderStateDescription.Value = "選択されたフォルダが確認できません。外付けストレージを再接続するか、キャッシュ先フォルダを再選択してください。"; CacheSaveFolderPath.Value = "?????"; break; case CacheFolderAccessState.Exist: CacheFolderStateDescription.Value = "キャッシュ利用の準備ができました"; break; default: break; } var folder = await HohoemaApp.GetVideoCacheFolder(); if (folder != null) { CacheSaveFolderPath.Value = $"{folder.Path}"; } IsRequireUpdateCacheSaveFolder.Value = cacheFolderAccessState == CacheFolderAccessState.SelectedButNotExist || cacheFolderAccessState == CacheFolderAccessState.NotSelected ; }
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(); } }); }
public CacheManagementPageViewModel( HohoemaApp app, PageManager pageManager, HohoemaDialogService dialogService ) : base(app, pageManager) { _MediaManager = app.CacheManager; _HohoemaDialogService = dialogService; IsRequireUpdateCacheSaveFolder = new ReactiveProperty <bool>(false); IsCacheUserAccepted = HohoemaApp.UserSettings.CacheSettings.ObserveProperty(x => x.IsUserAcceptedCache) .ToReadOnlyReactiveProperty(); RequireEnablingCacheCommand = new DelegateCommand(async() => { var result = await _HohoemaDialogService.ShowAcceptCacheUsaseDialogAsync(); if (result) { HohoemaApp.UserSettings.CacheSettings.IsEnableCache = true; HohoemaApp.UserSettings.CacheSettings.IsUserAcceptedCache = true; (App.Current).Resources["IsCacheEnabled"] = true; await RefreshCacheSaveFolderStatus(); (App.Current as App).PublishInAppNotification( InAppNotificationPayload.CreateReadOnlyNotification("キャッシュの保存先フォルダを選択してください。\n保存先が選択されると利用準備が完了します。", showDuration: TimeSpan.FromSeconds(30) )); if (await HohoemaApp.ChangeUserDataFolder()) { await RefreshCacheSaveFolderStatus(); await ResetList(); (App.Current as App).PublishInAppNotification( InAppNotificationPayload.CreateReadOnlyNotification("キャッシュの利用準備が出来ました") ); } } }); ReadCacheAcceptTextCommand = new DelegateCommand(async() => { var result = await _HohoemaDialogService.ShowAcceptCacheUsaseDialogAsync(showWithoutConfirmButton: true); }); 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); } }); ChangeCacheFolderCommand = new DelegateCommand(async() => { var prevPath = CacheSaveFolderPath.Value; if (await HohoemaApp.ChangeUserDataFolder()) { (App.Current as App).PublishInAppNotification( InAppNotificationPayload.CreateReadOnlyNotification($"キャッシュの保存先を {CacheSaveFolderPath.Value} に変更しました") ); await RefreshCacheSaveFolderStatus(); await ResetList(); } }); }