private void InitializeWindowComponent() { DisplayAuthorPane = Configuration.ApplicationConfiguration.DisplayAuthorPane; DisplayTagPane = Configuration.ApplicationConfiguration.DisplayTagPane; DisplayInformationPane = Configuration.ApplicationConfiguration.DisplayInformationPane; DockingDocumentViewModels = new ObservableCollection <IDocumentViewModelBase>(); DockingDocumentViewModels.Add((HomeDocumentViewModel)HomeDocumentViewModel); DockingPaneViewModels = new ObservableCollection <PaneViewModelBase>(); if (DisplayAuthorPane) { DockingPaneViewModels.Add((AuthorPaneViewModel)AuthorPaneViewModel); } if (DisplayTagPane) { DockingPaneViewModels.Add((TagPaneViewModel)TagPaneViewModel); } if (DisplayInformationPane) { DockingPaneViewModels.Add((InformationPaneViewModel)InformationPaneViewModel); } LoadLayout(); HomeDocumentViewModel.CloseSearchPane(); HomeDocumentViewModel.CloseImage(); HomeDocumentViewModel.CloseBook(); HomeDocumentViewModel.ResetScrollOffsetPool(); //HomeDocumentViewModel.ResetScrollOffset(); LibraryVM.ProgressManager.Complete(); TooltipOnProgressBar = "Ready"; HomeDocumentViewModel.ClearSelectedItems(); AuthorPaneViewModel.ClearSelectedItems(); TagPaneViewModel.ClearSelectedItems(); }
public async Task Initialize(bool starting, bool shiftPressed = false) { if (starting) { LibraryVM.ProgressManager.PropertyChanged += ProgressManager_PropertyChanged; TagPaneViewModel.BuildContextMenus_Tags(); AuthorPaneViewModel.BuildContextMenus_Authors(); } WindowLeft = Configuration.ApplicationConfiguration.WindowRect.X; WindowTop = Configuration.ApplicationConfiguration.WindowRect.Y; WindowWidth = Configuration.ApplicationConfiguration.WindowRect.Width; WindowHeight = Configuration.ApplicationConfiguration.WindowRect.Height; if (shiftPressed || Configuration.ApplicationConfiguration.WorkingDirectory == null) { if (!OpenSwitchLibraryDialogAndChangeWorkingDirectory()) { Close(); return; } } CloseAllTab(); var authorSorting = Configuration.ApplicationConfiguration.AuthorSorting; if (authorSorting != null) { AuthorManager.Sorting = AuthorSorting.GetReferenceByName(authorSorting); } var tagSorting = Configuration.ApplicationConfiguration.TagSorting; if (tagSorting != null) { TagManager.Sorting = ImageTagCountSorting.GetReferenceByName(tagSorting); } SetMainWindowTitle(); HomeDocumentViewModel.ClearSearchResult(); InitializeWindowComponent(); ManageAppDB(); IncrementNumberOfBoots(); Configuration.ApplicationConfiguration.ConnectionString = Specifications.GenerateConnectionString(Configuration.ApplicationConfiguration.WorkingDirectory); ConnectionManager.SetDefaultConnection(Configuration.ApplicationConfiguration.ConnectionString, typeof(SQLiteConnection)); try { await LibraryVM.Initialize(); LibraryVM.UnlockIfLocked(); await LibraryVM.Load() .ContinueWith(_ => { HomeDocumentViewModel.BookCabinet = LibraryVM.CreateBookStorage(); (LibraryVM as IObservable <BookCollectionChanged>) .Subscribe(HomeDocumentViewModel.BookCabinet as IObserver <BookCollectionChanged>) .AddTo(_disposable); this.Subscribe((IObserver <ActiveTabChanged>)TagManager) .AddTo(_disposable); this.Subscribe((IObserver <ActiveTabChanged>)AuthorManager) .AddTo(_disposable); var sorting = Configuration.ApplicationConfiguration.BookSorting; if (sorting != null) { HomeDocumentViewModel.BookCabinet.Sorting = BookSorting.GetReferenceByName(sorting); } var displayType = Configuration.ApplicationConfiguration.DisplayType; if (displayType != null) { HomeDocumentViewModel.BookCabinet.DisplayType = DisplayType.GetReferenceByName(displayType); } ((DocumentViewModelBase)HomeDocumentViewModel).IsVisible = true; ((DocumentViewModelBase)HomeDocumentViewModel).IsSelected = true; SetEvent(); NotifyActiveTabChanged(); }); } catch (Exception e) { Close(); } }