public async Task DownloadThread(int nHentaiId, WinForms.FolderBrowserDialog folder) { Doujin doujin = new Doujin(nHentaiId); string newName = doujin.name.Replace("/", "").Replace("?", "").Replace("%", "").Replace("*", "").Replace(":", "").Replace("|", "").Replace(".", "").Replace("<", "").Replace(">", "").Replace('"'.ToString(), ""); if (!Directory.Exists($@"{folder.SelectedPath}/{newName}")) { using (WebClient client = new WebClient()) { int i = 1; var notify = Notifications.Notifications.CreateNotificationWPBarNImg("Download", $"{doujin.name} is being downloaded", $"{i} of {doujin.pageCount}", 1, doujin.pageCount); notify.LayoutTransform = new RotateTransform(180); var window = DoujinUtility.MainWindow; window.notificationPanellul.Children.Add(notify); foreach (string ext in DoujinUtility.GetPage(doujin)) { Console.WriteLine($"https://i.nhentai.net/galleries/{doujin.mediaId}/{i}{ext}, {folder.SelectedPath}/{newName}/{i}{ext}"); Directory.CreateDirectory($@"{folder.SelectedPath}/{newName}"); await Task.Run(() => client.DownloadFile(new Uri("https://i.nhentai.net/galleries/" + doujin.mediaId + "/" + i + ext), $@"{folder.SelectedPath}/{newName}/{i}{ext}")); notify.UpdateNotificationWBarNImg($"{i} of {doujin.pageCount}", i); i++; } // OR } } else { Console.WriteLine("DAS GIBTS DOCH SCHON!!!!11!!elf"); } }
private void LoadPage(int p) { if (cache.Count == 0) { for (int i = 1; i <= gDoujin.pageCount; i++) { var bmp = new BitmapImage(new Uri("https://i.nhentai.net/galleries/" + gDoujin.mediaId + "/" + i + gDoujin.pageExt.ElementAt(i - 1))); cache.Add(bmp); } page.Source = cache.ElementAt(p - 1); ratio = page.Width / page.Height; //Console.WriteLine($"Doujin Viewer: Ratio is {ratio}, {page.Source.Width}/{page.Source.Height}"); } else { page.Source = cache.ElementAt(p - 1); } readP = (double)p / (double)gDoujin.pageCount; Console.WriteLine($"Doujin Viewer: p={p}, page count={gDoujin.pageCount}, readP={readP}"); if (readP >= 0.8 && !(Database.DatabaseControler.doujinCache.AsEnumerable().Any(row => gDoujin.nhentaiId == row.Field <Int32>("hentaiID")))) { Database.DatabaseControler.doujinCache.AddDoujinCacheRow(gDoujin.nhentaiId, true); Database.DatabaseControler.doujinCache.WriteXml("cache.xml"); if (DoujinUtility.FindChild <DoujinControl>(DoujinUtility.MainWindow.picgrid, gDoujin.nhentaiId.ToString()) != null) { DoujinUtility.FindChild <DoujinControl>(DoujinUtility.MainWindow.picgrid, gDoujin.nhentaiId.ToString()).img.Opacity = 0.3; } } }
private void Heart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Image obj = (Image)sender; Grid grid = (Grid)obj.Parent; DoujinControl control = (DoujinControl)grid.Parent; int nhId = (int)control.img.Tag; if (DoujinUtility.CheckFavorised(new Doujin(nhId))) { DatabaseControler.favorites.FindBynHentaiID(nhId).favorite = false; //DatabaseControler.mainDataTable.FindBynHentaiID(nhId).favorite = false; control.heart.Source = new BitmapImage(new Uri("pack://application:,,,/UiElements/heart_nofav.png")); DatabaseControler.favorites.RemoveDoujinDataRow(DatabaseControler.favorites.FindBynHentaiID(nhId)); DatabaseControler.favorites.WriteXml(DatabaseControler.favDataPath); } else { Doujin doujin = new Doujin(nhId); //DatabaseControler.mainDataTable.FindBynHentaiID(nhId).favorite = true; control.heart.Source = new BitmapImage(new Uri("pack://application:,,,/UiElements/heart_fav.png")); DoujinUtility.AddDoujinDataRow(doujin, DatabaseControler.favorites); DatabaseControler.favorites.WriteXml(DatabaseControler.favDataPath); //.Add(); var notify = Notifications.Notifications.NotificationNoImg(doujin.name, "", "The doujin got favorised and you can acess it at your favourite page"); DoujinUtility.MainWindow.notificationPanellul.Children.Add(notify); } }
public DoujinViewer(int mediaid, int nhentaiid, int pages, string coverurl, string ext) { InitializeComponent(); viewport.BeginInit(); gDoujin.mediaId = mediaid; gDoujin.nhentaiId = nhentaiid; gDoujin.pageCount = pages; gDoujin.coverUrl = coverurl; gDoujin.coverExt = ext; gDoujin.thumbnailExt = ext; Load(gDoujin); viewport.EndInit(); gDoujin.pageExt = DoujinUtility.GetPage(nhentaiid); }
private void Heart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Image obj = (Image)sender; Grid grid = (Grid)obj.Parent; DoujinControl control = (DoujinControl)grid.Parent; int nhId = (int)control.img.Tag; if (DoujinUtility.CheckFavorised(new Doujin(nhId))) { DatabaseControler.favorites.FindBynHentaiID(nhId).favorite = false; //DatabaseControler.mainDataTable.FindBynHentaiID(nhId).favorite = false; control.heart.Source = new BitmapImage(new Uri("pack://application:,,,/UiElements/heart_nofav.png")); DatabaseControler.favorites.RemoveDoujinDataRow(DatabaseControler.favorites.FindBynHentaiID(nhId)); DatabaseControler.favorites.WriteXml(DatabaseControler.favDataPath); } else { Doujin doujin = new Doujin(nhId); //DatabaseControler.mainDataTable.FindBynHentaiID(nhId).favorite = true; control.heart.Source = new BitmapImage(new Uri("pack://application:,,,/UiElements/heart_fav.png")); DoujinUtility.AddDoujinDataRow(doujin, DatabaseControler.favorites); DatabaseControler.favorites.WriteXml(DatabaseControler.favDataPath); //.Add(); var notify = Notifications.Notifications.NotificationNoImg(doujin.name, "", "The doujin got favorised and you can acess it at your favourite page"); DoujinUtility.MainWindow.notificationPanellul.Children.Add(notify); try { if (DoujinUtility.MainWindow.accountElement.loggedIn) { DoujinUtility.MainWindow.accountElement.apiHelper.PostFavorite(nhId); } else { DoujinUtility.MainWindow.accountElement.apiHelper.user = Newtonsoft.Json.JsonConvert.DeserializeObject <Doujin_Interface.Connection.Models.AuthenticatedUser>(Doujin_Interface.Properties.Settings.Default.User); DoujinUtility.MainWindow.accountElement.apiHelper.PostFavorite(nhId); } } catch (Exception ex) { throw ex; } } }
//viewport public void Load(Doujin doujin) { for (int i = 1; i < doujin.pageCount; i++) { //WebClient webClient = new WebClient(); //webClient.DownloadFile(new Uri("https://i.nhentai.net/galleries/" + gDoujin.mediaId + "/" + i +gDoujin.pageExt.ElementAt(i-1)), i + gDoujin.pageExt.ElementAt(i-1)); if (doujin.thumbnailExt == null) { Console.WriteLine(i); Image img = new Image(); img.Source = new BitmapImage(new Uri("https://t.nhentai.net/galleries/" + doujin.mediaId + "/" + i + "t" + DoujinUtility.GetExtension(doujin.mediaId, false, doujin))); img.Width = 162; img.Height = 231; img.Margin = new Thickness(5, 3, 5, 3); viewport.Children.Add(img); images.Add(img); } else { Console.WriteLine(i); Image img = new Image(); viewport.Children.Add(img); img.Source = new BitmapImage(new Uri("https://t.nhentai.net/galleries/" + doujin.mediaId + "/" + i + "t" + doujin.pageExt.ElementAt(i - 1))); img.Width = 250; img.Height = 347; img.Margin = new Thickness(5, 3, 5, 3); img.MouseLeftButtonDown += Img_MouseLeftButtonDown; images.Add(img); Console.WriteLine(img.Source); } Console.WriteLine("pages=" + doujin.pageCount + ", entires=" + images.Count); pageNumberText.Text = $"Pages: {gDoujin.pageCount}"; } }