Exemplo n.º 1
0
        public override async Task <List <ChapterImage> > LoadChapterImageAsync(Uri chapterUri)
        {
            if (chapterUri == null)
            {
                throw new ArgumentNullException("chapterUri", "TruyenTranhTuan - LoadChapterImageAsync method.");
            }

            List <ChapterImage> images = null;

            using (var webClient = new HttpClient())
            {
                var html = await webClient.GetStringAsync(chapterUri);

                var imagesUriStringList = await GetImagesUriStringAsync(html);

                images = new List <ChapterImage>();
                int index = 1;
                foreach (var uriString in imagesUriStringList)
                {
                    var MangaImage = new ChapterImage
                    {
                        ImageUri   = new Uri(uriString),
                        ImageIndex = index++,
                    };
                    images.Add(MangaImage);
                }
            }
            return(images);
        }
Exemplo n.º 2
0
        private async Task <AsyncTryOut <Chapter> > TryFoundIllustration()
        {
            Volume       V      = ReaderPage.CurrentChapter.Volume;
            ChapterImage CImage = Shared.BooksDb.ChapterImages.FirstOrDefault(x => V.Chapters.Contains(x.Chapter));

            if (CImage != null)
            {
                return(new AsyncTryOut <Chapter>(true, CImage.Chapter));
            }

            bool NeedDownload = Shared.BooksDb.Chapters.Any(x => x.Volume == V && x.Content == null);

            if (!NeedDownload)
            {
                Message.Text = "No Image for this volume";
                return(new AsyncTryOut <Chapter>());
            }

            NeedDownload = false;

            StringResources stm = StringResources.Load("Message");

            await Popups.ShowDialog(UIAliases.CreateDialog(
                                        "Not enough information to see if there were any illustrations within this volume. Download this volume?"
                                        , () => NeedDownload = true
                                        , stm.Str("Yes"), stm.Str("No")
                                        ));

            if (!NeedDownload)
            {
                Message.Text = "Not enough information for finding illustrations. Consider downloading a specific chapter";
                return(new AsyncTryOut <Chapter>());
            }

            ChapterList.ItemsSource = V.Chapters.Select(x => new ChapterVModel(x));
            await AutoCache.DownloadVolumeAsync(ReaderPage.CurrentBook, V);

            Chapter ImageChapter = V.Chapters.FirstOrDefault(x => x.Image != null);

            if (ImageChapter == null)
            {
                Worker.UIInvoke(() => Message.Text = "No Illustration available");
                return(new AsyncTryOut <Chapter>());
            }

            return(new AsyncTryOut <Chapter>(true, ImageChapter));
        }
Exemplo n.º 3
0
 public ImageViewModel(ChapterImage image)
 {
     _image = image;
 }