public TranslationViewModel(int bookId)
 {
     selectChapterCommand   = null;
     selectedChapter        = null;
     selectedChapterContent = null;
     LoadBook(bookId);
 }
 public TranslationViewModel(int bookId)
 {
     selectChapterCommand = null;
     selectedChapter = null;
     selectedChapterContent = null;
     LoadBook(bookId);
 }
Beispiel #3
0
 public BookViewModel(int bookId)
 {
     bookModel              = new BookModel();
     isLoading              = true;
     selectChapterCommand   = null;
     selectedChapter        = null;
     selectedChapterContent = null;
     bookModel.OpenBookAsync(bookId).ContinueWith(epubBook => BookOpened(epubBook), TaskScheduler.FromCurrentSynchronizationContext());
 }
Beispiel #4
0
 private void SelectChapter(ChapterViewModel chapterViewModel)
 {
     if (selectedChapter != null)
         selectedChapter.IsSelected = false;
     selectedChapter = chapterViewModel;
     selectedChapter.IsTreeItemExpanded = true;
     selectedChapter.IsSelected = true;
     SelectedChapterContent = new ChapterContentViewModel(selectedChapter.HtmlContent, images, styleSheets, fonts);
 }
Beispiel #5
0
 private void SelectChapter(ChapterViewModel chapterViewModel)
 {
     if (selectedChapter != null)
     {
         selectedChapter.IsSelected = false;
     }
     selectedChapter = chapterViewModel;
     selectedChapter.IsTreeItemExpanded = true;
     selectedChapter.IsSelected         = true;
     SelectedChapterContent             = new ChapterContentViewModel(selectedChapter.FilePath, selectedChapter.HtmlContent, images, styleSheets, fonts);
 }
Beispiel #6
0
 private void SelectChapter(ChapterViewModel chapterViewModel)
 {
     if (string.IsNullOrEmpty(chapterViewModel.HtmlId))
     {
         bool samePage = false;
         if (selectedChapter != null)
         {
             selectedChapter.IsSelected = false;
             if (selectedChapter == chapterViewModel || (!string.IsNullOrEmpty(selectedChapter.HtmlId) && chapterViewModel.ParentChapter == selectedChapter))
             {
                 selectedChapter        = null;
                 selectedChapterContent = null;
                 samePage = true;
             }
         }
         selectedChapter = chapterViewModel;
         selectedChapter.IsTreeItemExpanded = true;
         selectedChapter.IsSelected         = true;
         SelectedChapterContent             = new ChapterContentViewModel(selectedChapter.HtmlContent, images, styleSheets, fonts);
         if (BookView.View != null && samePage)
         {
             BookView.View.ScrollTo("");
         }
     }
     else
     {
         if (selectedChapter == null)
         {
             selectedChapter = chapterViewModel.ParentChapter;
         }
         else
         {
             selectedChapter.IsSelected = false;
         }
         selectedChapter = chapterViewModel;
         selectedChapter.IsTreeItemExpanded = true;
         selectedChapter.IsSelected         = true;
         if (SelectedChapterContent.HtmlContent != chapterViewModel.ParentChapter.HtmlContent)
         {
             SelectedChapterContent = new ChapterContentViewModel(chapterViewModel.ParentChapter.HtmlContent, images, styleSheets, fonts);
         }
         Task.Run(async() =>
         {
             await Task.Delay(100);
             if (BookView.View != null)
             {
                 BookView.View.ScrollTo(chapterViewModel.HtmlId);
             }
         });
         // SelectedElement = chapterViewModel.HtmlContent;
     }
 }
Beispiel #7
0
 public BookViewModel(int bookId)
 {
     bookModel = new BookModel();
     epubBook = bookModel.OpenBook(bookId);
     Contents = new ObservableCollection<ChapterViewModel>(bookModel.GetChapters(epubBook));
     images = epubBook.Content.Images.ToDictionary(imageFile => imageFile.Key, imageFile => imageFile.Value.Content);
     styleSheets = epubBook.Content.Css.ToDictionary(cssFile => cssFile.Key, cssFile => cssFile.Value.Content);
     fonts = epubBook.Content.Fonts.ToDictionary(fontFile => fontFile.Key, fontFile => fontFile.Value.Content);
     selectChapterCommand = null;
     selectedChapter = null;
     selectedChapterContent = null;
     if (Contents.Any())
         SelectChapter(Contents.First());
 }
Beispiel #8
0
 public BookViewModel(int bookId)
 {
     bookModel              = new BookModel();
     epubBook               = bookModel.OpenBook(bookId);
     Contents               = new ObservableCollection <ChapterViewModel>(bookModel.GetChapters(epubBook));
     images                 = epubBook.Content.Images.ToDictionary(imageFile => imageFile.Key, imageFile => imageFile.Value.Content);
     styleSheets            = epubBook.Content.Css.ToDictionary(cssFile => cssFile.Key, cssFile => cssFile.Value.Content);
     fonts                  = epubBook.Content.Fonts.ToDictionary(fontFile => fontFile.Key, fontFile => fontFile.Value.Content);
     selectChapterCommand   = null;
     selectedChapter        = null;
     selectedChapterContent = null;
     if (Contents.Any())
     {
         SelectChapter(Contents.First());
     }
 }
Beispiel #9
0
        public void LoadBook(int bookId, bool append = false)
        {
            var epubBook = bookModel.OpenBook(bookId);

            Contents    = Contents.AddRange(bookModel.GetChapters(epubBook));
            images      = images.AddRange(epubBook.Content.Images.ToDictionary(imageFile => imageFile.Key, imageFile => imageFile.Value.Content));
            styleSheets = styleSheets.AddRange(epubBook.Content.Css.ToDictionary(cssFile => cssFile.Key, cssFile => cssFile.Value.Content));
            fonts       = fonts.AddRange(epubBook.Content.Fonts.ToDictionary(fontFile => fontFile.Key, fontFile => fontFile.Value.Content));

            selectChapterCommand   = null;
            selectedChapter        = null;
            selectedChapterContent = null;
            if (Contents.Any())
            {
                SelectChapter(Contents.First());
            }
        }
        private void SelectChapter(ChapterViewModel chapterViewModel)
        {
            if (string.IsNullOrEmpty(chapterViewModel.HtmlId))
            {
                bool samePage = false;
                if (selectedChapter != null)
                {
                    selectedChapter.IsSelected = false;
                    if (selectedChapter == chapterViewModel || (!string.IsNullOrEmpty(selectedChapter.HtmlId) && chapterViewModel.ParentChapter == selectedChapter))
                    {
                        selectedChapter = null;
                        selectedChapterContent = null;
                        samePage = true;

                    }
                }
                selectedChapter = chapterViewModel;
                selectedChapter.IsTreeItemExpanded = true;
                selectedChapter.IsSelected = true;
                SelectedChapterContent = new ChapterContentViewModel(selectedChapter.HtmlContent, images, styleSheets, fonts);
                if (BookView.View != null && samePage)
                    BookView.View.ScrollTo("");
            }
            else
            {
                if (selectedChapter == null)
                {
                    selectedChapter = chapterViewModel.ParentChapter;
                }
                else
                    selectedChapter.IsSelected = false;
                selectedChapter = chapterViewModel;
                selectedChapter.IsTreeItemExpanded = true;
                selectedChapter.IsSelected = true;
                if (SelectedChapterContent.HtmlContent != chapterViewModel.ParentChapter.HtmlContent)
                    SelectedChapterContent = new ChapterContentViewModel(chapterViewModel.ParentChapter.HtmlContent, images, styleSheets, fonts);
                Task.Run(async () =>
                {
                    await Task.Delay(100);
                    if (BookView.View != null)
                        BookView.View.ScrollTo(chapterViewModel.HtmlId);
                });
                // SelectedElement = chapterViewModel.HtmlContent;
            }
        }
        public void LoadBook(int bookId, bool append = false)
        {
            var epubBook = bookModel.OpenBook(bookId);
            Contents = Contents.AddRange(bookModel.GetChapters(epubBook));
            images = images.AddRange(epubBook.Content.Images.ToDictionary(imageFile => imageFile.Key, imageFile => imageFile.Value.Content));
            styleSheets = styleSheets.AddRange(epubBook.Content.Css.ToDictionary(cssFile => cssFile.Key, cssFile => cssFile.Value.Content));
            fonts = fonts.AddRange(epubBook.Content.Fonts.ToDictionary(fontFile => fontFile.Key, fontFile => fontFile.Value.Content));

            selectChapterCommand = null;
            selectedChapter = null;
            selectedChapterContent = null;
            if (Contents.Any())
                SelectChapter(Contents.First());
        }