public ChapterCollectionViewModel(MangaSource mangaSource, Manga manga, uint numberOfChaptersPerLoading) { _mangaSource = mangaSource; _manga = manga; _numberOfChaptersPerLoading = numberOfChaptersPerLoading; HasMoreItems = true; }
public ChapterViewModel(MangaSource mangaSource, Manga manga, Chapter chapter) { _chapter = chapter; _manga = manga; _mangaSource = mangaSource; DownloadCommand = new RelayCommand(() => DownloadChapter()); }
public ChapterReadingViewModel(ChapterViewModel chapterViewModel) { _chapterViewModel = chapterViewModel; _mangaSource = chapterViewModel.MangaSource; ImageCollection = new ObservableCollection <ImageViewModel>(); //LoadImageAsync(); }
public MangaViewModel(MangaSource mangaSource, Manga manga) { _mangaSource = mangaSource; _manga = manga; MangaName = _manga.MangaInfo.MangaName; LoadImage(); }
public MangaCollectionViewModel(MangaSource mangaSource, Category category, int numberOfItemsPerLoading) { _mangaSource = mangaSource; _category = category; _numberOfItemsPerLoading = numberOfItemsPerLoading; HasMoreItems = true; IsLoadingMore = false; }
protected virtual MangaInfo FillMangaInfo(MangaInfo mangaInfo, MangaSource source, HtmlDocument document) { IMangaParser mangaParser = _parsersFactory.GetParser(source.Code); List <MangaChapterInfo> chaptersList = mangaParser.GetMangaChapters(document, source); chaptersList.Reverse(); chaptersList.ForEach(chapter => chapter.MangaId = mangaInfo.Id); string imageUrl = mangaParser.GetMangaImageUrl(document, source.ImageXpath); string name = mangaParser.GetMangaName(document, source.TitleXpath); var manga = new MangaInfo(); manga.Id = mangaInfo.Id; manga.ImageUrl = imageUrl; manga.Chapters = chaptersList; manga.Name = name; manga.Href = mangaInfo.Href; manga.Source = mangaInfo.Source; return(manga); }
public async Task <MangaInfo> LoadMangaInfoAsync(MangaInfo mangaInfo) { mangaInfo.CheckArgumentNull(nameof(mangaInfo)); string mangaUrl = mangaInfo.Href; mangaUrl.CheckArgumentEmptyOrNull(nameof(mangaUrl)); Uri mangaUri = new Uri(mangaUrl); MangaSource mangaSource = GetSourceByUrl(mangaUri); mangaInfo.Source = mangaSource ?? throw new ArgumentException("Wrong url domain"); string sourceName = mangaSource.Name; ServiceConfigrationSection config = _configHelper.GetServiceConfig(sourceName); if (config == null) { throw new ArgumentException($"No handler for source {sourceName}"); } _htmlDocumentLoader.Cookies = config.Cookies; HtmlDocument document = await _htmlDocumentLoader.GetHtmlDoc(mangaInfo.Href); return(FillMangaInfo(mangaInfo, mangaSource, document)); }
public List <MangaChapterInfo> GetMangaChapters(HtmlDocument htmlDoc, MangaSource source) { var chaptersList = new List <MangaChapterInfo>(); try { HtmlNodeCollection nodes = htmlDoc.DocumentNode.SelectNodes(source.ChapterXpath); foreach (var item in nodes) { var chapterXpath = item.XPath; var titleElems = htmlDoc.DocumentNode.SelectNodes(chapterXpath + source.ChapterTitleXpath); var hrefElements = htmlDoc.DocumentNode.SelectNodes(chapterXpath + source.ChapterHrefXpath); var dataElems = htmlDoc.DocumentNode.SelectNodes(chapterXpath + source.ChapterDateXpath); string chapterName = titleElems.FirstOrDefault()?.InnerText; string releaseDate = dataElems.FirstOrDefault()?.InnerText; string href = hrefElements.FirstOrDefault()?.GetAttributeValue("href", ""); chaptersList.Add(new MangaChapterInfo { Name = chapterName, Date = releaseDate, Href = href }); } } catch { } return(chaptersList); }
public ChapterCollectionViewModel(MangaSource mangaSource, Manga manga) { _mangaSource = mangaSource; _manga = manga; HasMoreItems = true; }
public MangaDetailViewModel(Manga manga, MangaSource mangaSource) { _manga = manga; _mangaSource = mangaSource; LoadingInitializationData(); }
public MainViewModel(MangaSource mangaSource) { _mangaSource = mangaSource; _mostPopularMangaCollection = new MangaCollectionViewModel(_mangaSource, Category.All, 50); _latestUpdatedMangaCollection = new MangaCollectionViewModel(_mangaSource, Category.LatestUpdated, 20); }
public MainViewModel() { _mangaSource = new MangaSource(new TruyenTranhTuanDataService()); _mostPopularMangaCollection = new MangaCollectionViewModel(_mangaSource, Category.All, 50); _latestUpdatedMangaCollection = new MangaCollectionViewModel(_mangaSource, Category.LatestUpdated, 20); }