Ejemplo n.º 1
0
        public override IActionResult Execute(object pSouce, IAction pAction)
        {
            if (pAction is LoadAction)
            {
                return ExecuteToChildren(new LoadAction(this));
            }

            var startReadAction = pAction as StartReadAction;
            if (startReadAction != null)
            {
                return StartRead(startReadAction);
            }

            var selectItemAction = pAction as SelectItemAction;
            if (selectItemAction != null)
            {
                try
                {
                    SelectItem(selectItemAction);
                }
                catch (InvalidOperationException ex)
                {
                    //TODO: manage exception: log it and show any information to the user?
                    SelectedChapter = null;
                }
            }

            var startReadSelectedChapterAction = pAction as StartReadSelectedChapterAction;
            if (startReadSelectedChapterAction != null)
            {
                return StartReadSelectedChapter(startReadSelectedChapterAction);
            }

            return base.Execute(pSouce, pAction);
        } 
Ejemplo n.º 2
0
        private IActionResult StartReadingManga(MangaInformation pManga, ChapterInformation pChapter, MangaReaderManager pItemToActivate)
        {
            ArgumentsValidation.NotNull(pManga, "pManga");
            ArgumentsValidation.NotNull(pChapter, "pChapter");
            ArgumentsValidation.NotNull(pItemToActivate, "pItemToActivate");

            return pItemToActivate.Execute(this, new StartReadAction(this, pManga, pChapter));
        }
Ejemplo n.º 3
0
 private IActionResult StartReadingManga(MangaInformation pManga, ChapterInformation pChapter)
 {
     var reader = CreateNewReader(pManga);
     return StartReadingManga(pManga, pChapter, reader);
 }
Ejemplo n.º 4
0
        private IManager GetChapterManager(ChapterInformation pChapter)
        {
            var manager = GetChildren()
                .OfType<ChapterManager>()
                .FirstOrDefault(x => Equals(x.Chapter, pChapter));

            return manager;
        }
Ejemplo n.º 5
0
 public StartReadParameters(IAction pSourceAction, ChapterInformation pChapter)
 {
     _sourceAction = pSourceAction;
     _chapter = pChapter;
 }
Ejemplo n.º 6
0
 private IManager AddChapterManager(ChapterInformation pChapterToAdd)
 {
     var chapterManager = new ChapterManager(this, pChapterToAdd);
     GetController<IMangaReaderController>().CreateChapterReader(chapterManager);
     return chapterManager;
 }
Ejemplo n.º 7
0
 private void AddChapter(ChapterInformation pChapterToRead)
 {
     _chapters.Add(pChapterToRead);
     GetController<IMangaReaderController>().AddChapter(pChapterToRead);
 }
Ejemplo n.º 8
0
        private IActionResult DoStartRead(ChapterInformation pChapter)
        {
            if (IsChapterMissing(pChapter))
            {
                AddChapter(pChapter);
            }

            SelectChapter(pChapter);
            StartReadSelectedChapter();

            return new NotAvailableActionResult();
        }
Ejemplo n.º 9
0
        private bool IsChapterMissing(ChapterInformation pChapter)
        {
            ArgumentsValidation.NotNull(pChapter, "pChapter");

            var exists = _chapters.Any(x => Equals(x, pChapter));
            return exists;
        }
Ejemplo n.º 10
0
 private void SelectChapter(ChapterInformation pItem)
 {
     SelectedChapter = pItem;
     GetController<IMangaReaderController>().SelectChapter(SelectedChapter);
 }
 public void AddChapter(ChapterInformation pChapter)
 {
     ChaptersList.Items.Add(pChapter);
 }
 public void SelectChapter(ChapterInformation pChapter)
 {
     ChaptersList.SelectedItem = pChapter;
 }
Ejemplo n.º 13
0
 public StartReadAction(object pSource, MangaInformation pManga, ChapterInformation pChapter)
     : base(pSource)
 {
     Manga = pManga;
     Chapter = pChapter;
 }
Ejemplo n.º 14
0
 public ChapterManager(IManager pParent, ChapterInformation pChapterToRead)
     : base(pParent)
 {
     _chapterToRead = pChapterToRead;
 }