Esempio n. 1
0
 public BookViewModel(BblBook book, LibraryViewModel library)
 {
     _book                 = book;
     Library               = library;
     book.Demoted         += OnBookDemoted;
     book.Deleted         += OnBookDeleted;
     book.Renamed         += OnBookRenamed;
     book.Populated       += OnBookPopulated;
     book.Unpopulated     += OnBookUnpopulated;
     book.ThumbnailLoaded += OnBookThumbnailChanged;
 }
Esempio n. 2
0
        public TabViewModel(ShellViewModel conductor, BblTabState tabstate, ObservableCollection <TabOptions> savedOptions)
        {
            _conductor  = conductor;
            _tabState   = tabstate;
            Library     = new LibraryViewModel(this);
            DisplayName = tabstate.displayName;

            TabUIState uistate = tabstate.uiState;

            uistate.doLoad = true;
            TabUIState     = uistate;
            _savedOptions  = savedOptions;

            if (string.IsNullOrEmpty(tabstate.windowedOptions))
            {
                tabstate.windowedOptions = "default";
            }
            if (string.IsNullOrEmpty(tabstate.fullscreenOptions))
            {
                tabstate.fullscreenOptions = "default";
            }

            foreach (var o in savedOptions)
            {
                if (tabstate.windowedOptions == o.Name)
                {
                    WindowedOptions = o;
                }
                else if (tabstate.fullscreenOptions == o.Name)
                {
                    FullscreenOptions = o;
                }
            }

            TheExplorer = new XamlFSExplorer.FSExplorer(new DirectoryInfoEx[] { FSExplorer.MyComputerDirectory })
            {
                HideAttributes = FileAttributes.Hidden | FileAttributes.System | FileAttributes.Offline,
                ShowDisabled   = true
            };
            var bookmark = _tabState.currentBookmark;

            bookmark.destroyOnClose = true;
            var fsbm = TheExplorer.AddBookmark(bookmark);

            fsbm.BookmarkClicked += GotoBookmark;
            fsbm.BookmarkDeleted += OnBookmarkDeleted;
            _bookmarks.Add(fsbm);

            foreach (var bm in _tabState.savedBookmarks)
            {
                fsbm = TheExplorer.AddBookmark(bm);
                fsbm.BookmarkClicked += GotoBookmark;
                fsbm.BookmarkDeleted += OnBookmarkDeleted;
                _bookmarks.Add(fsbm);
            }
            _tabState.savedBookmarks.Clear();

            _customSorts.Add(new CustomSort("Natural"));
            _customSorts.Add(new CustomSort("Path"));
            _customSorts.Add(new CustomSort("Name"));
            _customSorts.Add(new CustomSort("Creation Time"));
            _customSorts.Add(new CustomSort("Last Modified"));
            _customSorts.Add(new CustomSort("Randomized"));

            if (string.IsNullOrEmpty(_tabState.booksSort))
            {
                _tabState.booksSort = "Creation Time";
            }

            SelectedCustomSort = _customSorts.Where(x => x.Name == _tabState.booksSort).FirstOrDefault();
            SortDirection      = _tabState.booksSortDirection;
        }