public ChapterCollectionViewModel(MangaSource mangaSource, Manga manga, uint numberOfChaptersPerLoading)
 {
     _mangaSource = mangaSource;
     _manga       = manga;
     _numberOfChaptersPerLoading = numberOfChaptersPerLoading;
     HasMoreItems = true;
 }
예제 #2
0
 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();
 }
예제 #4
0
 public MangaViewModel(MangaSource mangaSource, Manga manga)
 {
     _mangaSource = mangaSource;
     _manga       = manga;
     MangaName    = _manga.MangaInfo.MangaName;
     LoadImage();
 }
예제 #5
0
 public MangaCollectionViewModel(MangaSource mangaSource, Category category, int numberOfItemsPerLoading)
 {
     _mangaSource             = mangaSource;
     _category                = category;
     _numberOfItemsPerLoading = numberOfItemsPerLoading;
     HasMoreItems             = true;
     IsLoadingMore            = false;
 }
예제 #6
0
        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);
        }
예제 #7
0
        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));
        }
예제 #8
0
        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;
 }
예제 #10
0
 public MangaDetailViewModel(Manga manga, MangaSource mangaSource)
 {
     _manga       = manga;
     _mangaSource = mangaSource;
     LoadingInitializationData();
 }
예제 #11
0
 public MainViewModel(MangaSource mangaSource)
 {
     _mangaSource = mangaSource;
     _mostPopularMangaCollection   = new MangaCollectionViewModel(_mangaSource, Category.All, 50);
     _latestUpdatedMangaCollection = new MangaCollectionViewModel(_mangaSource, Category.LatestUpdated, 20);
 }
예제 #12
0
 public MainViewModel()
 {
     _mangaSource = new MangaSource(new TruyenTranhTuanDataService());
     _mostPopularMangaCollection   = new MangaCollectionViewModel(_mangaSource, Category.All, 50);
     _latestUpdatedMangaCollection = new MangaCollectionViewModel(_mangaSource, Category.LatestUpdated, 20);
 }