public AboutSettingsPageContentViewModel() : base("このアプリについて", HohoemaSettingsKind.About) { var version = Windows.ApplicationModel.Package.Current.Id.Version; VersionText = $"{version.Major}.{version.Minor}.{version.Build}"; 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(); OnPropertyChanged(nameof(LisenceItems)); }); }); }
public override async Task OnNavigatedToAsync(INavigationParameters parameters) { await base.OnNavigatedToAsync(parameters); _NowNavigateProccess = true; try { VideoTitleFilteringItems.Clear(); foreach (var item in _videoFilteringRepository.GetVideoTitleFilteringEntries().Select(x => new VideoFilteringTitleViewModel(x, OnRemoveVideoTitleFilterEntry, _videoFilteringRepository, TestText)) ) { VideoTitleFilteringItems.Add(item); } try { var listing = await Models.Domain.Purchase.HohoemaPurchase.GetAvailableCheersAddOn(); PurchaseItems = listing.ProductListings.Select(x => new ProductViewModel(x.Value)).ToList(); OnPropertyChanged(nameof(PurchaseItems)); } catch { } var lisenceSummary = await LisenceSummary.Load(); LisenceItems = lisenceSummary.Items .OrderBy(x => x.Name) .Select(x => new LisenceItemViewModel(x)) .ToList(); OnPropertyChanged(nameof(LisenceItems)); } finally { _NowNavigateProccess = false; } }
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 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); }