public NicoRepoPageViewModel( Services.HohoemaPlaylist hohoemaPlaylist, Services.PageManager pageManager, ActivityFeedSettings activityFeedSettings, Models.Provider.LoginUserNicoRepoProvider loginUserNicoRepoProvider, Models.Subscription.SubscriptionManager subscriptionManager ) : base(pageManager, useDefaultPageTitle: true) { HohoemaPlaylist = hohoemaPlaylist; ActivityFeedSettings = activityFeedSettings; LoginUserNicoRepoProvider = loginUserNicoRepoProvider; SubscriptionManager = subscriptionManager; DisplayNicoRepoItemTopics = ActivityFeedSettings.DisplayNicoRepoItemTopics.ToList(); /* * DisplayNicoRepoItemTopics.CollectionChangedAsObservable() * .Throttle(TimeSpan.FromSeconds(1)) * .Subscribe(async _ => * { * await HohoemaApp.UIDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => * { * await ResetList(); * }); * }); */ }
public NicoRepoPageViewModel( IScheduler scheduler, ApplicationLayoutManager applicationLayoutManager, HohoemaPlaylist hohoemaPlaylist, Services.PageManager pageManager, ActivityFeedSettings activityFeedSettings, Models.Provider.LoginUserNicoRepoProvider loginUserNicoRepoProvider, Models.Subscription.SubscriptionManager subscriptionManager, OpenLiveContentCommand openLiveContentCommand ) { _scheduler = scheduler; ApplicationLayoutManager = applicationLayoutManager; HohoemaPlaylist = hohoemaPlaylist; ActivityFeedSettings = activityFeedSettings; LoginUserNicoRepoProvider = loginUserNicoRepoProvider; SubscriptionManager = subscriptionManager; _openLiveContentCommand = openLiveContentCommand; DisplayNicoRepoItemTopics = new ObservableCollection <NicoRepoItemTopic>(ActivityFeedSettings.DisplayNicoRepoItemTopics); DisplayNicoRepoItemTopics.CollectionChangedAsObservable() .Subscribe(_ => { _NicoRepoItemTopicsChanged = true; }) .AddTo(_CompositeDisposable); }
public override void OnNavigatingFrom(NavigatingFromEventArgs e, Dictionary <string, object> viewModelState, bool suspending) { // ニレコポ表示設定をニコレポの設定に書き戻し var saveTopics = DisplayNicoRepoItemTopics.Distinct().ToList(); if (saveTopics.Count == 0) { saveTopics.Add(NicoRepoItemTopic.NicoVideo_User_Video_Upload); } ActivityFeedSettings.DisplayNicoRepoItemTopics = DisplayNicoRepoItemTopics.Distinct().ToList(); ActivityFeedSettings.Save().ConfigureAwait(false); base.OnNavigatingFrom(e, viewModelState, suspending); }
public override void OnNavigatedFrom(INavigationParameters parameters) { // ニレコポ表示設定をニコレポの設定に書き戻し var saveTopics = DisplayNicoRepoItemTopics.Distinct().ToList(); if (saveTopics.Count == 0) { saveTopics.Add(NicoRepoItemTopic.NicoVideo_User_Video_Upload); } ActivityFeedSettings.DisplayNicoRepoItemTopics = DisplayNicoRepoItemTopics.Distinct().ToList(); ActivityFeedSettings.Save().ConfigureAwait(false); base.OnNavigatedFrom(parameters); }
public NicoRepoPageViewModel(HohoemaApp app, PageManager pageManager) : base(app, pageManager, useDefaultPageTitle: true) { _NicoRepoFeedSettings = HohoemaApp.UserSettings.ActivityFeedSettings; DisplayNicoRepoItemTopics = _NicoRepoFeedSettings.DisplayNicoRepoItemTopics.ToList(); /* * DisplayNicoRepoItemTopics.CollectionChangedAsObservable() * .Throttle(TimeSpan.FromSeconds(1)) * .Subscribe(async _ => * { * await HohoemaApp.UIDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => * { * await ResetList(); * }); * }); */ }
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); }