protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            manga = (e.Parameter as object[])[1] as Manga
            ;
            index   = (int)(e.Parameter as object[])[0];
            chapter = manga.Chapters[index];

            previousChapterTitle.Tapped += (a, b) =>
            {
                if (manga.Chapters.Count <= index + 1)
                {
                    nextChapterTitle.Text = "";
                }
                try
                {
                    FillChapter(manga.Chapters[++index]);
                }
                catch { }
            };
            nextChapterTitle.Tapped += (a, b) =>
            {
                if (index - 1 < 0)
                {
                    previousChapterTitle.Text = "";
                }
                FillChapter(manga.Chapters[--index]);
            };



            DataContext = chapter;
            FillChapter(chapter);
            images.SelectionChanged += (a, b) =>
            {
                bar.Maximum = images.Items.Count;
                bar.Value   = images.SelectedIndex + 1;
                if (images.SelectedIndex == images.Items.Count - 1)
                {
                    //appbar.ClosedDisplayMode = AppBarClosedDisplayMode.Compact;
                }
                else
                {
                    //appbar.ClosedDisplayMode = AppBarClosedDisplayMode.Minimal;
                }
            };

            bar.ValueChanged += (a, b) =>
            {
                images.SelectedIndex = (int)bar.Value - 1;
            };
            images.ManipulationStarted += (a, b) => initialpoint = b.Position;
            images.ManipulationDelta   += images_ManipulationDelta;

            this.Loaded += ReaderPage_Loaded;
        }
        private void saved_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Manga m = (sender as ListView).SelectedValue as Manga;

            model.CurrentManga = m;
            if (m == null)
            {
                return;
            }
            Frame.Navigate(typeof(MangaPage), model);
        }
        private void latest_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var item = ((sender as ListView).ContainerFromIndex((sender as ListView).SelectedIndex) as ListViewItem).Content;
            //var pos = item.TransformToVisual(Window.Current.Content);
            //Point screenCoords = pos.TransformPoint(new Point(0, 0));
            Manga m = (sender as ListView).SelectedValue as Manga;

            model.CurrentManga = m;
            if (m == null)
            {
                return;
            }
            Frame.Navigate(typeof(MangaPage), model);
        }
        public async void GetMangasFromCategory(int category = 0)
        {
            CategoryMangas.Clear();
            string query = "http://www.mangareader.net/popular/" + CategoryURL[category].ToLower();

            HtmlDocument htmlDocument = new HtmlDocument();

            htmlDocument.OptionFixNestedTags = true;
            htmlDocument.LoadHtml(await Utils.DownloadPageStringAsync(query));


            foreach (HtmlNode link in htmlDocument.DocumentNode.Descendants("div").Where(x => x.Attributes.Contains("class") && x.Attributes["class"].Value == "mangaresultinner"))
            {
                if (CategoryMangas.Count == 5)
                {
                    break;
                }
                var lk = link.Descendants("a").First();


                Manga m =
                    new Manga {
                    Name = lk.InnerText, Url = "http://www.mangareader.net" + lk.Attributes["href"].Value
                };

                m.Chapters.Clear();
                HtmlDocument htmlDocument2 = new HtmlDocument();
                htmlDocument2.OptionFixNestedTags = true;
                htmlDocument2.LoadHtml(await Utils.DownloadPageStringAsync(m.Url));

                var txt = link.Descendants("div").Where(x => x.Attributes.Contains("class") && x.Attributes["class"].Value == "imgsearchresults").First();
                var tt  = txt.Attributes["style"].Value.Replace("background-image:url('", "").Replace("')", "");
                m.Image = tt;

                CategoryMangas.Add(m);

                /*foreach (HtmlNode link2 in htmlDocument2.DocumentNode.Descendants("a").Where(x => x.Attributes.Contains("href") && x.ParentNode.OriginalName == "td"))
                 * {
                 *  //Debug.WriteLine("Manga=" + m.Name + " Inner = " + link.InnerText);
                 *  m.Chapters.Add(new Chapter { Name = link2.InnerText.Replace(":", "\n"), Url = link2.Attributes["href"].Value });
                 * }*/
            }
            DataChanged(this, null);
        }
        public async void GetChapters(Manga manga)
        {
            manga.Chapters.Clear();
            HtmlDocument htmlDocument2 = new HtmlDocument();

            htmlDocument2.OptionFixNestedTags = true;
            htmlDocument2.LoadHtml(await Utils.DownloadPageStringAsync(manga.Url));

            manga.Image = htmlDocument2.DocumentNode.Descendants("div").First(x => x.Id == "mangaimg").Descendants().First().Attributes["src"].Value;

            foreach (HtmlNode link in htmlDocument2.DocumentNode.Descendants("a").Where(x => x.Attributes.Contains("href") && x.ParentNode.OriginalName == "td" && x.ParentNode.Descendants("div").Any(y => y.Attributes["class"].Value == "chico_manga")))
            {
                manga.Chapters.Insert(0, new Chapter {
                    Name = link.ParentNode.InnerText.Replace("\n", "").Replace(manga.Name, "").Replace(":", " "), Url = link.Attributes["href"].Value
                });
            }

            manga.Description = htmlDocument2.DocumentNode.Descendants("div").First(x => x.Id == "readmangasum").Descendants("p").First().InnerText;
        }
 public async void SaveChapter(Chapter c, Manga m)
 {
     /*string manga_url = m.Url.Replace("/", "").Replace(".", "").Replace(":", "").Replace("-", "").Replace("?","");
      * string chapter_url = c.Name.Replace("/", "").Replace(".", "").Replace(":", "").Replace("-", "").Replace("\n" , "");
      * StorageFolder folder =  (await localFolder.CreateFolderAsync(manga_url , CreationCollisionOption.OpenIfExists));
      * StorageFolder chapterFolder = await folder.CreateFolderAsync(chapter_url , CreationCollisionOption.OpenIfExists);
      *
      *
      * string manga_name = m.Name.Replace("/", "").Replace(".", "").Replace(":", "").Replace("-", "").Replace(".","");
      * var file = await folder.CreateFileAsync(manga_name, CreationCollisionOption.ReplaceExisting);
      * var downloader = new BackgroundDownloader();
      * var download = downloader.CreateDownload(new Uri(m.Image), file);
      *
      * var res = await download.StartAsync();
      *
      * BackgroundTransferGroup mangaGroup = BackgroundTransferGroup.CreateGroup(manga_url);
      * downloader.TransferGroup = mangaGroup;
      *
      * List<string> urls = await c.getImages();
      * foreach (string s in urls)
      * {
      *  string filename = s.Split('/').Last().ToString().Replace("-", "");
      *  try
      *  {
      *      var cfile = await chapterFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
      *      var cdownload = downloader.CreateDownload(new Uri(s), cfile);
      *      Utils.downloads.Add(cdownload);
      *      await cdownload.StartAsync();
      *      Debug.WriteLine("saving " + s);
      *  }
      *  catch
      *  {
      *      Debug.WriteLine(filename + " +");
      *  }
      * }
      *
      */
 }
        public async void Search(string name)
        {
            string query = String.Format("http://www.mangareader.net/search/?w={0}&rd=0&status=0&order=0&genre=0000000000000000000000000000000000000&p=0", name);

            HtmlDocument htmlDocument = new HtmlDocument();

            htmlDocument.OptionFixNestedTags = true;
            htmlDocument.LoadHtml(await Utils.DownloadPageStringAsync(query));


            foreach (HtmlNode link in htmlDocument.DocumentNode.Descendants("div").Where(x => x.Attributes.Contains("class") && x.Attributes["class"].Value == "mangaresultinner"))
            {
                var lk = link.Descendants("a").First();
                SearchResults.Add(new Manga {
                    Name = lk.InnerText, Url = "http://www.mangareader.net" + lk.Attributes["href"].Value
                });

                Manga m = SearchResults.Last();
                m.Chapters.Clear();
                HtmlDocument htmlDocument2 = new HtmlDocument();
                htmlDocument2.OptionFixNestedTags = true;
                htmlDocument2.LoadHtml(await Utils.DownloadPageStringAsync(m.Url));

                var txt = link.Descendants("div").Where(x => x.Attributes.Contains("class") && x.Attributes["class"].Value == "imgsearchresults").First();
                var tt  = txt.Attributes["style"].Value.Replace("background-image:url('", "").Replace("')", "");
                m.Image = tt;

                foreach (HtmlNode link2 in htmlDocument2.DocumentNode.Descendants("a").Where(x => x.Attributes.Contains("href") && x.ParentNode.OriginalName == "td"))
                {
                    //Debug.WriteLine("Manga=" + m.Name + " Inner = " + link.InnerText);
                    m.Chapters.Add(new Chapter {
                        Name = link2.InnerText.Replace(":", "\n"), Url = link2.Attributes["href"].Value
                    });
                }
            }
        }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            model       = e.Parameter as AppModel;
            DataContext = e.Parameter;
            Manga m = model.CurrentManga;


            if (!m.Saved)
            {
                /*m.Chapters.Clear();
                 * HtmlDocument htmlDocument2 = new HtmlDocument();
                 * htmlDocument2.OptionFixNestedTags = true;
                 * htmlDocument2.LoadHtml(await DownloadPageStringAsync(m.Url));
                 *
                 * m.Image = htmlDocument2.DocumentNode.Descendants("div").Where(x => x.Id == "mangaimg").First().Descendants().First().Attributes["src"].Value;
                 *
                 * foreach (HtmlNode link in htmlDocument2.DocumentNode.Descendants("a").Where(x => x.Attributes.Contains("href") && x.ParentNode.OriginalName == "td" && x.ParentNode.Descendants("div").Any(y => y.Attributes["class"].Value == "chico_manga")))
                 * {
                 *  m.Chapters.Insert(0, new Chapter { Name = link.ParentNode.InnerText, Url = link.Attributes["href"].Value });
                 * }
                 *
                 * m.Description = htmlDocument2.DocumentNode.Descendants("div").Where(x => x.Id == "readmangasum").First().Descendants("p").First().InnerText;*/
            }
        }
Exemple #9
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            manga = ((object[])e.Parameter)[1] as Manga
            ;
            index   = (int)(e.Parameter as object[])[0];
            chapter = manga.Chapters[index];

            AppModel.Current.Provider.GetImages(manga.Chapters[index]);



            DataContext = chapter;
            FillChapter(chapter);
            images.SelectionChanged += (a, b) =>
            {
                bar.Maximum = images.Items.Count;
                bar.Value   = images.SelectedIndex + 1;
                if (images.SelectedIndex == images.Items.Count - 1)
                {
                    //appbar.ClosedDisplayMode = AppBarClosedDisplayMode.Compact;
                }
                else
                {
                    //appbar.ClosedDisplayMode = AppBarClosedDisplayMode.Minimal;
                }
            };

            bar.ValueChanged += (a, b) =>
            {
                images.SelectedIndex = (int)bar.Value - 1;
            };
            images.ManipulationStarted += (a, b) => initialpoint = b.Position;
            images.ManipulationDelta   += images_ManipulationDelta;

            this.Loaded += ReaderPage_Loaded;
        }
Exemple #10
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (!loaded)
            {
                //loaded = true;
                model       = e.Parameter as AppModel;
                DataContext = e.Parameter;
                Manga m = model.CurrentManga;
                //img.Source = new BitmapImage(new Uri(m.Image));

                if (!m.Saved)
                {
                    // TODO maybe chapters here?
                }

                /*chapters.SelectionMode = ListViewSelectionMode.None;
                 * chapters.IsItemClickEnabled = true;
                 * chapters.ItemClick += (a, b) =>
                 * {
                 *
                 *  Frame.Navigate(typeof(ReaderPage), new object[] { (a as ListView).SelectedIndex, model.CurrentManga });
                 * };*/
            }
        }
        async void item_tapped(object sender, TappedRoutedEventArgs e)
        {
            var item = (sender as Grid);

            Manga m = (sender as Grid).DataContext as Manga;

            model.CurrentManga = m;
            if (!m.Saved)
            {
                m.Chapters.Clear();
                HtmlDocument htmlDocument2 = new HtmlDocument();
                htmlDocument2.OptionFixNestedTags = true;
                htmlDocument2.LoadHtml(await Utils.DownloadPageStringAsync(m.Url));

                m.Image = htmlDocument2.DocumentNode.Descendants("div").Where(x => x.Id == "mangaimg").First().Descendants().First().Attributes["src"].Value;

                foreach (HtmlNode link in htmlDocument2.DocumentNode.Descendants("a").Where(x => x.Attributes.Contains("href") && x.ParentNode.OriginalName == "td" && x.ParentNode.Descendants("div").Any(y => y.Attributes["class"].Value == "chico_manga")))
                {
                    m.Chapters.Insert(0, new Chapter {
                        Name = link.ParentNode.InnerText.Replace("\n", ""), Url = link.Attributes["href"].Value
                    });
                }

                m.Description = htmlDocument2.DocumentNode.Descendants("div").Where(x => x.Id == "readmangasum").First().Descendants("p").First().InnerText;
            }


            //var pos = item.TransformToVisual(Window.Current.Content);
            //Point screenCoords = pos.TransformPoint(new Point(0, 0));

            screenCoords = e.GetPosition(canvas);
            innerPos     = e.GetPosition(item);

            var inner = item.Children[0];



            var context = (inner as Grid).DataContext;

            item.Children.Remove(inner);
            canvas.Children.Add(inner);
            (inner as Grid).DataContext            = context;
            (inner as Grid).Children[1].Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            (inner as Grid).Children[2].Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            Canvas.SetLeft(inner, screenCoords.X - innerPos.X);
            Canvas.SetTop(inner, screenCoords.Y - innerPos.Y);
            Storyboard st = new Storyboard();

            ExponentialEase ease = new ExponentialEase();


            DoubleAnimation xanim = new DoubleAnimation();

            Storyboard.SetTargetProperty(xanim, "(Canvas.Left)");
            xanim.EasingFunction = ease;
            xanim.From           = screenCoords.X - innerPos.X;
            xanim.To             = 0;
            xanim.Duration       = TimeSpan.FromSeconds(0.5);
            DoubleAnimation yanim = new DoubleAnimation();

            Storyboard.SetTargetProperty(yanim, "(Canvas.Top)");
            yanim.EasingFunction = ease;
            yanim.From           = screenCoords.Y - innerPos.Y;
            yanim.To             = 0;
            yanim.Duration       = TimeSpan.FromSeconds(0.5);

            DoubleAnimation w = new DoubleAnimation();

            w.EnableDependentAnimation = true;
            w.EasingFunction           = ease;
            Storyboard.SetTargetProperty(w, "Width");
            w.From     = item.ActualWidth;
            w.To       = canvas.ActualWidth;
            w.Duration = TimeSpan.FromSeconds(0.3);

            DoubleAnimation h = new DoubleAnimation();

            h.EasingFunction           = ease;
            h.EnableDependentAnimation = true;
            Storyboard.SetTargetProperty(h, "Height");
            h.From     = item.ActualHeight;
            h.To       = 400;
            h.Duration = TimeSpan.FromSeconds(0.3);


            Storyboard.SetTarget(st, inner);
            st.Children.Add(xanim);
            st.Children.Add(yanim);
            st.Children.Add(w);
            st.Children.Add(h);
            (inner as Grid).Tag = item;
            st.Completed       += async(a, b) =>
            {
                chapters.ItemsSource = model.CurrentManga.Chapters;
                if (m == null)
                {
                    return;
                }
                //svar v = new NavigationThemeTransition();
                //v.DefaultNavigationTransitionInfo = null;
                //Frame.Navigate(typeof(MangaPage), model, null);
                chapters.Visibility = Visibility.Visible;
                grid.Visibility     = Visibility.Visible;
                btnBack.Visibility  = Visibility.Visible;
                introInfo.Begin();
            };
            st.Begin();
        }
        async void item_tapped(object sender, TappedRoutedEventArgs e)
        {
            var item = (sender as Grid);

            Manga m = (sender as Grid).DataContext as Manga;

            model.CurrentManga = m;
            if (!m.Saved)
            {
                model.Provider.GetChapters(m);
            }


            //var pos = item.TransformToVisual(Window.Current.Content);
            //Point screenCoords = pos.TransformPoint(new Point(0, 0));

            screenCoords = e.GetPosition(canvas);
            innerPos     = e.GetPosition(item);

            var inner = item.Children[0];



            var context = (inner as Grid).DataContext;

            item.Children.Remove(inner);
            canvas.Children.Add(inner);
            (inner as Grid).DataContext            = context;
            (inner as Grid).Children[1].Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            (inner as Grid).Children[2].Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            Canvas.SetLeft(inner, screenCoords.X - innerPos.X);
            Canvas.SetTop(inner, screenCoords.Y - innerPos.Y);
            Storyboard st = new Storyboard();

            ExponentialEase ease = new ExponentialEase();


            DoubleAnimation xanim = new DoubleAnimation();

            Storyboard.SetTargetProperty(xanim, "(Canvas.Left)");
            xanim.EasingFunction = ease;
            xanim.From           = screenCoords.X - innerPos.X;
            xanim.To             = 0;
            xanim.Duration       = TimeSpan.FromSeconds(0.5);
            DoubleAnimation yanim = new DoubleAnimation();

            Storyboard.SetTargetProperty(yanim, "(Canvas.Top)");
            yanim.EasingFunction = ease;
            yanim.From           = screenCoords.Y - innerPos.Y;
            yanim.To             = 0;
            yanim.Duration       = TimeSpan.FromSeconds(0.5);

            DoubleAnimation w = new DoubleAnimation();

            w.EnableDependentAnimation = true;
            w.EasingFunction           = ease;
            Storyboard.SetTargetProperty(w, "Width");
            w.From     = item.ActualWidth;
            w.To       = canvas.ActualWidth;
            w.Duration = TimeSpan.FromSeconds(0.3);

            DoubleAnimation h = new DoubleAnimation();

            h.EasingFunction           = ease;
            h.EnableDependentAnimation = true;
            Storyboard.SetTargetProperty(h, "Height");
            h.From     = item.ActualHeight;
            h.To       = 400;
            h.Duration = TimeSpan.FromSeconds(0.3);


            Storyboard.SetTarget(st, inner);
            st.Children.Add(xanim);
            st.Children.Add(yanim);
            st.Children.Add(w);
            st.Children.Add(h);
            (inner as Grid).Tag = item;
            st.Completed       += async(a, b) =>
            {
                //chapters.ItemsSource = model.CurrentManga.Chapters;
                if (m == null)
                {
                    return;
                }
                //svar v = new NavigationThemeTransition();
                //v.DefaultNavigationTransitionInfo = null;
                Frame.Navigate(typeof(MangaPage), model, null);
                //chapters.Visibility = Visibility.Visible;
                //grid.Visibility = Visibility.Visible;
                //introInfo.Begin();
            };
            st.Begin();
        }
        public async void GetLatest(int n = 0)
        {
            Latest.Clear();
            var htmlDocument = new HtmlDocument();

            htmlDocument.OptionFixNestedTags = true;
            htmlDocument.LoadHtml(await Utils.DownloadPageStringAsync("http://www.mangareader.net/"));

            var htmlDocument2 = new HtmlDocument();

            var mangas = new List <Manga>();

            foreach (HtmlNode cont in htmlDocument.DocumentNode.Descendants("tr").Where(x => x.Attributes.Contains("class") && x.Attributes["class"].Value == "c3"))
            {
                var link = cont.Descendants("a").First();

                var m = new Manga
                {
                    Name    = link.FirstChild.InnerText,
                    Url     = "http://www.mangareader.net" + link.Attributes["href"].Value,
                    Updated = cont.Descendants("td").ElementAt(2).InnerText
                };
                mangas.Add(m);


                htmlDocument2.OptionFixNestedTags = true;
                htmlDocument2.LoadHtml(await Utils.DownloadPageStringAsync(m.Url));

                m.Image = htmlDocument2.DocumentNode.Descendants("div").Where(x => x.Id == "mangaimg").First().Descendants().First().Attributes["src"].Value;
                var details =
                    htmlDocument2.DocumentNode.Descendants("div")
                    .Where(x => x.Id == "mangaproperties")
                    .First()
                    .Descendants("td")
                    .Select(y => y.InnerText).ToList();

                m.AlternateNames = details[3];
                m.Year           = details[5];
                m.Status         = details[7];
                m.Author         = details[9];
                m.Artist         = details[11];

                /*
                 * foreach (HtmlNode link2 in htmlDocument2.DocumentNode.Descendants("a").Where(x => x.Attributes.Contains("href") && x.ParentNode.OriginalName == "td"))
                 * {
                 *  //Debug.WriteLine("Manga=" + m.Name + " Inner = " + link.InnerText);
                 *
                 *  m.Chapters.Add(new Chapter { Name = link2.InnerText, Url = link2.Attributes["href"].Value });
                 * }*/

                if (mangas.Count == 5)
                {
                    foreach (Manga mx in mangas)
                    {
                        Latest.Add(mx);
                    }
                    mangas.Clear();
                    DataChanged(this, null);
                    return;
                }

                //if (Latest.Count > 4) return;
                Latest.Add(m);
            }
            //foreach (Manga mx in mangas) Latest.Add(mx);
            if (DataChanged != null)
            {
                DataChanged(this, null);
            }
        }