Exemple #1
0
        private void SetupSaveWithPropertyChanged()
        {
            NGSettings.PropertyChangedAsObservable()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(e => _ = RankingSettings.Save());

            RankingSettings.PropertyChangedAsObservable()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(e => _ = RankingSettings.Save());

            CacheSettings.PropertyChangedAsObservable()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(e => _ = CacheSettings.Save());

            AppearanceSettings.PropertyChangedAsObservable()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(e => _ = AppearanceSettings.Save());

            ActivityFeedSettings.PropertyChangedAsObservable()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(e => _ = ActivityFeedSettings.Save());

            PlayerSettings.PropertyChangedAsObservable()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(e => _ = PlayerSettings.Save());

            new[] {
                PinSettings.PropertyChangedAsObservable().ToUnit(),
                    PinSettings.Pins.CollectionChangedAsObservable().ToUnit(),
                    PinSettings.Pins.ObserveElementPropertyChanged().ToUnit()
            }
            .Merge()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(pair => _ = PinSettings.Save());
        }
Exemple #2
0
        public static async Task <HohoemaUserSettings> LoadSettings(StorageFolder userFolder)
        {
            var ranking = await SettingsBase.Load <RankingSettings>(RankingSettingsFileName, userFolder);

            var playlist = await SettingsBase.Load <PlaylistSettings>(PlaylistSettingsFileName, userFolder);

            var ng = await SettingsBase.Load <NGSettings>(NGSettingsFileName, userFolder);

            var player = await SettingsBase.Load <PlayerSettings>(PlayerSettingsFileName, userFolder);

            var cache = await SettingsBase.Load <CacheSettings>(CacheSettingsFileName, userFolder);

            var appearance = await SettingsBase.Load <AppearanceSettings>(AppearanceSettingsFileName, userFolder);

            var nicorepoAndFeed = await SettingsBase.Load <ActivityFeedSettings>(NicoRepoAndFeedSettingsFileName, userFolder);

            var pin = await SettingsBase.Load <PinSettings>(PinSettingsFileName, userFolder);

            if (nicorepoAndFeed.DisplayNicoRepoItemTopics.Count == 0)
            {
                nicorepoAndFeed.DisplayNicoRepoItemTopics.AddRange(new []
                {
                    NicoRepoItemTopic.NicoVideo_User_Video_Upload,
                    NicoRepoItemTopic.NicoVideo_User_Mylist_Add_Video,
                    NicoRepoItemTopic.Live_Channel_Program_Onairs,
                    NicoRepoItemTopic.Live_Channel_Program_Reserve,
                    NicoRepoItemTopic.NicoVideo_Channel_Video_Upload,
                    NicoRepoItemTopic.Live_User_Program_OnAirs,
                    NicoRepoItemTopic.Live_User_Program_Reserve,
                });
            }

            var settings = new HohoemaUserSettings()
            {
                RankingSettings  = ranking,
                PlaylistSettings = playlist,
                NGSettings       = ng,

                PlayerSettings       = player,
                CacheSettings        = cache,
                AppearanceSettings   = appearance,
                ActivityFeedSettings = nicorepoAndFeed,
                PinSettings          = pin,
            };

            try
            {
                PinSettings.MigratePinParameter_Prism6_to_Prism7(pin);
            }
            catch { }

            settings.SetupSaveWithPropertyChanged();

            return(settings);
        }
        public async Task Save()
        {
            await RankingSettings.Save();

            await PlayerSettings.Save();

            await NGSettings.Save();

            await CacheSettings.Save();

            await PlaylistSettings.Save();

            await AppearanceSettings.Save();

            await ActivityFeedSettings.Save();

            await PinSettings.Save();
        }
Exemple #4
0
        public static void MigratePinParameter_Prism6_to_Prism7(PinSettings pinSettings)
        {
            if (pinSettings.IsMigrated_Prism6_to_Prism7)
            {
                return;
            }
            foreach (var pin in pinSettings.Pins)
            {
                // Mylist
                switch (pin.PageType)
                {
                case Services.HohoemaPageType.RankingCategoryList:
                    break;

                case Services.HohoemaPageType.RankingCategory:
                    pin.Parameter = $"category={pin.Parameter}";
                    break;

                case Services.HohoemaPageType.UserMylist:
                    break;

                case Services.HohoemaPageType.Mylist:
                    try
                    {
                        var mylistPayload = MylistPagePayload.FromParameterString <MylistPagePayload>(pin.Parameter);
                        if (mylistPayload != null)
                        {
                            if (mylistPayload.Origin.HasValue)
                            {
                                pin.Parameter = $"id={mylistPayload.Id}&origin={mylistPayload.Origin}";
                            }
                            else
                            {
                                pin.Parameter = $"id={mylistPayload.Id}";
                            }
                        }
                    }
                    catch { }

                    break;

                case Services.HohoemaPageType.FollowManage:
                    break;

                case Services.HohoemaPageType.WatchHistory:
                    break;

                case Services.HohoemaPageType.Search:
                    break;

                case Services.HohoemaPageType.SearchSummary:
                    break;

                case Services.HohoemaPageType.SearchResultCommunity:
                    try
                    {
                        var content = SearchPagePayload.FromParameterString <CommunitySearchPagePayloadContent>(pin.Parameter);
                        if (content != null)
                        {
                            pin.Parameter = $"keyword={System.Net.WebUtility.UrlEncode(content.Keyword)}&target={content.SearchTarget}";
                        }
                    }
                    catch { }
                    break;

                case Services.HohoemaPageType.SearchResultTag:
                    try
                    {
                        var content = SearchPagePayload.FromParameterString <TagSearchPagePayloadContent>(pin.Parameter);
                        if (content != null)
                        {
                            pin.Parameter = $"keyword={System.Net.WebUtility.UrlEncode(content.Keyword)}&target={content.SearchTarget}";
                        }
                    }
                    catch { }
                    break;

                case Services.HohoemaPageType.SearchResultKeyword:
                    try
                    {
                        var content = SearchPagePayload.FromParameterString <KeywordSearchPagePayloadContent>(pin.Parameter);
                        if (content != null)
                        {
                            pin.Parameter = $"keyword={System.Net.WebUtility.UrlEncode(content.Keyword)}&target={content.SearchTarget}";
                        }
                    }
                    catch { }
                    break;

                case Services.HohoemaPageType.SearchResultMylist:
                    try
                    {
                        var content = SearchPagePayload.FromParameterString <MylistSearchPagePayloadContent>(pin.Parameter);
                        if (content != null)
                        {
                            pin.Parameter = $"keyword={System.Net.WebUtility.UrlEncode(content.Keyword)}&target={content.SearchTarget}";
                        }
                    }
                    catch { }
                    break;

                case Services.HohoemaPageType.SearchResultLive:
                    try
                    {
                        var content = SearchPagePayload.FromParameterString <LiveSearchPagePayloadContent>(pin.Parameter);
                        if (content != null)
                        {
                            pin.Parameter = $"keyword={System.Net.WebUtility.UrlEncode(content.Keyword)}&target={content.SearchTarget}";
                        }
                    }
                    catch { }
                    break;

                case Services.HohoemaPageType.FeedGroupManage:
                    break;

                case Services.HohoemaPageType.FeedGroup:
                    break;

                case Services.HohoemaPageType.FeedVideoList:
                    break;

                case Services.HohoemaPageType.UserInfo:
                    pin.Parameter = $"id={pin.Parameter}";
                    break;

                case Services.HohoemaPageType.UserVideo:
                    pin.Parameter = $"id={pin.Parameter}";
                    break;

                case Services.HohoemaPageType.Community:
                    pin.Parameter = $"id={pin.Parameter}";
                    break;

                case Services.HohoemaPageType.CommunityVideo:
                    pin.Parameter = $"id={pin.Parameter}";
                    break;

                case Services.HohoemaPageType.VideoInfomation:
                    pin.Parameter = $"id={pin.Parameter}";
                    break;

                case Services.HohoemaPageType.CacheManagement:
                    break;

                case Services.HohoemaPageType.Settings:
                    break;

                case Services.HohoemaPageType.Splash:
                    break;

                case Services.HohoemaPageType.VideoPlayer:
                    break;

                case Services.HohoemaPageType.NicoRepo:
                    break;

                case Services.HohoemaPageType.Recommend:
                    break;

                case Services.HohoemaPageType.ChannelInfo:
                    pin.Parameter = $"id={pin.Parameter}";
                    break;

                case Services.HohoemaPageType.ChannelVideo:
                    pin.Parameter = $"id={pin.Parameter}";
                    break;

                case Services.HohoemaPageType.PrologueIntroduction:
                    break;

                case Services.HohoemaPageType.NicoAccountIntroduction:
                    break;

                case Services.HohoemaPageType.VideoCacheIntroduction:
                    break;

                case Services.HohoemaPageType.EpilogueIntroduction:
                    break;

                case Services.HohoemaPageType.LiveInfomation:
                    pin.Parameter = $"id={pin.Parameter}";
                    break;

                case Services.HohoemaPageType.Timeshift:
                    break;

                case Services.HohoemaPageType.Subscription:
                    break;

                default:
                    break;
                }
            }

            pinSettings.IsMigrated_Prism6_to_Prism7 = true;
            _ = pinSettings.Save();
        }