Exemple #1
0
        //Load a directory when TabViewModel.SelectedFolder is changed.
        public void Open(DirectoryInfoEx dir)
        {
            if (!Directory.Exists(dir.FullName))
            {
                return;
            }
            if (_model != null)
            {
                CloseLibrary();
            }

            //open
            _model = new BblLibrary(dir);
            _model.LibraryLoaded += OnLibraryLoaded;

            Tab.ProgressValue         = 0;
            Tab.ProgressMaximum       = 100;
            Tab.ProgressIsDeterminate = true;

            _books = new VmCollection <BookViewModel, BblBook>(_model.Books, this);
            NotifyOfPropertyChange(() => Books);


            _booksCV = (ListCollectionView)CollectionViewSource.GetDefaultView(_books);
            ((INotifyCollectionChanged)(_booksCV)).CollectionChanged += OnBooksCollectionChanged;
            NotifyOfPropertyChange(() => BooksCV);

            Tab.ResetSortUI();
            Tab.TabState.currentBookmark.libraryPath = dir.FullName;
            _booksCV.CustomSort = comparer;
        }
Exemple #2
0
 public void CloseLibrary()
 {
     foreach (var b in Books)
     {
         b.OnLibraryClosed();
     }
     if (_model == null)
     {
         return;
     }
     _model.CloseLibrary(Tab.SaveToDBToggle);
     _model = null;
 }