Beispiel #1
0
        public void AddChapter(Chapter chapter)
        {
            if (Chapters.Any(v => v.Title == chapter.Title))
            {
                return;
            }

            Chapters.Add(chapter);
        }
Beispiel #2
0
        public void AddChapters(Chapter chapter)
        {
            if (Chapters.Any(c => c.Title == chapter.Title))
            {
                return;
            }

            Chapters.Add(chapter);
        }
Beispiel #3
0
 private void SetProgress(Chapter chapter, int addonLength = 0)
 {
     if (Chapters == null || Chapters.Count == 0 || !Chapters.Any(p => p.Equals(chapter)))
     {
         throw new ArgumentOutOfRangeException("The chapter list don't have this chapter");
     }
     if (chapter != CurrentChapter)
     {
         ChapterChanged?.Invoke(this, chapter);
     }
     CurrentChapter = Chapters.Where(p => p.Equals(chapter)).FirstOrDefault();
     if (ReaderType == Enums.ReaderType.Txt)
     {
         int    nextIndex = CurrentChapter.Index + 1;
         string content   = "";
         if (nextIndex >= Chapters.Count)
         {
             content = _txtContent.Substring(CurrentChapter.StartLength);
         }
         else
         {
             content = _txtContent.Substring(CurrentChapter.StartLength, Chapters[nextIndex].StartLength - CurrentChapter.StartLength);
         }
         _readerView.SetContent(content, Enums.ReaderStartMode.First, addonLength);
     }
     else if (ReaderType == Enums.ReaderType.Custom)
     {
         var detail = CustomChapterDetailList.Where(p => p.Index == CurrentChapter.Index).FirstOrDefault();
         if (detail != null)
         {
             _readerView.SetContent(detail.GetReadContent(), Enums.ReaderStartMode.First, addonLength);
         }
         else
         {
             CustomContentRequest?.Invoke(this, new CustomRequestEventArgs(Enums.ReaderStartMode.First, CurrentChapter, addonLength));
         }
     }
     else
     {
         var    info    = _epubContent.SpecialResources.HtmlInReadingOrder.Where(p => p.AbsolutePath.Equals(chapter.Link, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
         string content = string.Empty;
         if (info != null)
         {
             content = info.TextContent;
             _tempEpubChapterIndex = _epubContent.SpecialResources.HtmlInReadingOrder.IndexOf(info);
         }
         else
         {
             content = chapter.Title;
         }
         _readerView.SetContent(content, Enums.ReaderStartMode.First, addonLength);
     }
     RaiseProgressChanged(addonLength);
 }
Beispiel #4
0
 public override bool CanDelete()
 {
     return(!Chapters.Any() && !Components.Any() && !Projects.Any() && !Maintenances.Any());
 }