Beispiel #1
0
 public MainWindowViewModel()
 {
     YouTubeUrlDialogViewModel                 = new YouTubeUrlDialogViewModel(this);
     OpenYouTubeUrlDialogCommand               = new OpenYouTubeUrlDialogCommand(this);
     PlayerSeekToCommand                       = new PlayerSeekToCommand(this);
     SaveScriptCommand                         = new SaveScriptCommand();
     AddBookmarkCommand                        = new AddBookmarkCommand(this);
     RemoveBookmarkCommand                     = new RemoveBookmarkCommand(this);
     ExecutePapagoCommand                      = new ExecutePapagoCommand();
     CopySubtitleTextToClipboardCommand        = new CopySubtitleTextToClipboardCommand();
     CopyTimeAndSubtitleTextToClipboardCommand = new CopyTimeAndSubtitleTextToClipboardCommand();
 }
Beispiel #2
0
        public async void OnNavigatedTo(NavigationEventArgs e)
        {
            IsProgressVisible = true;

            _book = e.Parameter as IBook;
            if (_book != null)
            {
                _file = await StorageFile.GetFileFromPathAsync(_book.BookPath);
            }
            else if (e.Parameter is IStorageFile)
            {
                _file = (IStorageFile)e.Parameter;
            }
            else
            {
                throw new Exception("Invalid parameter.");
            }

            DjvuDocument document;

            try
            {
                document = await DjvuDocument.LoadAsync(_file);
            }
            catch
            {
                if (Debugger.IsAttached)
                {
                    throw;
                }

                IsProgressVisible = false;
                ShowFileOpeningError();
                return;
            }

            CurrentDocument   = document;
            CurrentPageNumber = _book?.LastOpenedPage ?? 1;
            TotalPageNumber   = document.PageCount;

            if (_book != null)
            {
                _book.LastOpeningTime = DateTime.Now;
                await _book.SaveChangesAsync();

                _bookmarks = _book?.Bookmarks;
                ((INotifyCollectionChanged)_bookmarks).CollectionChanged += Bookmarks_CollectionChanged;
                UpdateIsCurrentPageBookmarked();
            }

            _outline = await document.GetOutlineAsync();

            IsProgressVisible = false;

            ShowOutlineCommand.RaiseCanExecuteChanged();
            AddBookmarkCommand.RaiseCanExecuteChanged();
            RemoveBookmarkCommand.RaiseCanExecuteChanged();
            ShowBookmarksCommand.RaiseCanExecuteChanged();

            var applicationView = ApplicationView.GetForCurrentView();

            applicationView.Title = _book?.Title ?? _file.Name;

            _dataTransferManager.DataRequested += DataRequestedHandler;
            CoreApplication.Suspending         += ApplicationSuspendingHandler;
        }