예제 #1
0
        private void LibraryVM_Searched(object sender, SearchedEventArgs e)
        {
            if (string.IsNullOrEmpty(e.PreviousSearchingText))
            {
                HomeDocumentViewModel.StoreScrollOffset(Guid.Empty);
            }

            HomeDocumentViewModel.ResetScrollOffset();
        }
예제 #2
0
        private void SearchByAuthor(IEnumerable <AuthorCountViewModel> items)
        {
            var activeViewModel = MainWindowViewModel.Value.ActiveDocumentViewModel;

            activeViewModel.BookCabinet.ClearSearchResult();
            foreach (var item in items)
            {
                item.IsSearchingKey = true;
            }
            AuthorManager.ShowBySelectedItems(MainWindowViewModel.Value, items.Select(ac => ac.Author));
            HomeDocumentViewModel.ResetScrollOffset();
        }
예제 #3
0
        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();
        }
예제 #4
0
        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();
            }
        }
예제 #5
0
 private void GeneralCancel()
 {
     HomeDocumentViewModel.CloseSearchPane();
 }
예제 #6
0
 private void LibraryVM_SearchCleared(object sender, EventArgs e)
 {
     HomeDocumentViewModel.RestoreScrollOffset(Guid.Empty);
 }