コード例 #1
0
 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());
 }
コード例 #3
0
 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);
        }
コード例 #9
0
 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);
 }