public bool Initialize(string saveDirectory) { // Set the user interface to display in the same culture as that set in Control Panel. System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture; //ストレージに保存する設定 this.SettingsXml = new XmlSettingManager <ApplicationSettings> (Path.Combine(saveDirectory, settingsFileName)); this.Settings = SettingsXml .LoadXml(XmlLoadingOptions.IgnoreAllException | XmlLoadingOptions.UseBackup) .Value; this.ImageBuffer = new ImageBuffer().AddTo(this.Disposables); this.ImageBuffer.MetaImageExtention = this.MetaImageExtention; var config = new LibraryConfiguration(saveDirectory) { Concurrency = 512, FileTypeFilter = new HashSet <string>(this.FileTypeFilter), FileSystem = new FileSystem(), }; LibraryOwner.SetConfig(config); var library = LibraryOwner.GetCurrent(); library.InitSettings(); library.LoadAsync().Wait(); library.AddTo(this.Disposables); this.Library = library; this.LibraryUpdateHistory = new ReactiveCollection <LibraryUpdateHistoryItem>().AddTo(this.Disposables); this.Library.Loaded .Subscribe(x => this.LibraryUpdateHistory.AddRangeOnScheduler( x.AddedFiles.Select(y => new LibraryUpdateHistoryItem() { Date = x.DateTime, Path = y.Key, Type = LibraryUpdateType.Add }) .Concat(x.RemovedFiles.Select(y => new LibraryUpdateHistoryItem() { Date = x.DateTime, Path = y.Key, Type = LibraryUpdateType.Remove })) .Concat(x.UpdatedFiles.Select(y => new LibraryUpdateHistoryItem() { Date = x.DateTime, Path = y.Key, Type = LibraryUpdateType.Update })))) .AddTo(this.Disposables); this.SystemNotification = this.Library.Loaded .Select(x => this.ShowLibraryResult(x)) .Where(x => x != null) .Publish().RefCount(); //リソースから文字列を取得 this.InitializeResourceString(); //色テーマ this.ObserveProperty(x => x.IsDarkTheme) .Subscribe(x => { ((App)Application.Current).ChangeTheme(x ? darkThemeName : lightThemeName); }) .AddTo(this.Disposables); this.ObserveProperty(x => x.BackgroundColor) .Subscribe(x => { Application.Current.Resources["BasicBackColor"] = new SolidColorBrush(x); }) .AddTo(this.Disposables); this.isChanged = true; this.PropertyChangedAsObservable().Subscribe(x => this.isChanged = true).AddTo(this.Disposables); var libraryHasItem = this.Library.HasItems(); //ライブラリ更新 if (libraryHasItem && this.RefreshLibraryOnLaunched) { this.Library.StartRefreshLibrary(false); } return(libraryHasItem); }