/// <summary> /// プロパティ変更時に自動保存される設定値を作成する。 /// </summary> /// <typeparam name="TConfig">設定値の型。</typeparam> /// <param name="keeper">初期値と保存処理を提供するオブジェクト。</param> /// <returns>設定値。</returns> private ReactiveProperty <TConfig> MakeConfig <TConfig>( ConfigKeeper <TConfig> keeper) where TConfig : INotifyPropertyChanged { var result = new ReactiveProperty <TConfig>(keeper.Value) .AddTo(this.CompositeDisposable); // 自動保存設定 // 100ms 以内のプロパティ値変更はまとめて保存する result .Select(c => c.PropertyChangedAsObservable()) .Switch() .Throttle(TimeSpan.FromMilliseconds(100)) .Where(_ => !this.IsLoading.Value && this.IsLoaded.Value) .Subscribe( _ => { keeper.Value = result.Value; keeper.Save(); }) .AddTo(this.CompositeDisposable); return(result); }
/// <summary> /// コンストラクタ。 /// </summary> public LipAndCapConfig() { this.BasicKeeper = new ConfigKeeper<BasicData>(BasicFilePath); this.LipPresetKeeper = new ConfigKeeper<LipPresetData>(LipPresetFilePath); this.CaptionPresetKeeper = new ConfigKeeper<CaptionPresetData>(CaptionPresetFilePath); this.ModelPresetRelationKeeper = new ConfigKeeper<ModelPresetRelationData>(ModelPresetRelationFilePath); }