private void Button_Click(object sender, RoutedEventArgs e) { var tag = (sender as Button).Tag.ToString(); if (tag == "Search" && IsMetadataLoaded) { lock (load_lock) { if (!loading) { AppendAsync(SearchText.Text); } else { StopLoad(); } } } else if (tag == "Tidy") { if (!Settings.Instance.UXSetting.UsingThumbnailSearchElements) { int count = SearchPanel.Children.Count / 2; SearchPanel.Children.Clear(); GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); if (count > 0) { MainWindow.Instance.FadeOut_MiddlePopup($"{count}{(string)FindResource("msg_tidy")}", false); } } else { int count = SearchMaterialPanel.Children.Count / 2; SearchMaterialPanel.Children.Clear(); GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); if (count > 0) { MainWindow.Instance.FadeOut_MiddlePopup($"{count}{(string)FindResource("msg_tidy")}", false); } } } else if (tag == "SelectAll") { if (!Settings.Instance.UXSetting.UsingThumbnailSearchElements) { SearchPanel.Children.OfType <SearchElements>().ToList().ForEach(x => x.Select = true); } else { SearchMaterialPanel.Children.OfType <SearchMaterialElements>().ToList().ForEach(x => x.Select = true); } } else if (tag == "DeSelectAll") { if (!Settings.Instance.UXSetting.UsingThumbnailSearchElements) { SearchPanel.Children.OfType <SearchElements>().ToList().ForEach(x => x.Select = false); } else { SearchMaterialPanel.Children.OfType <SearchMaterialElements>().ToList().ForEach(x => x.Select = false); } } else if (tag == "Download") { if (!Settings.Instance.UXSetting.UsingThumbnailSearchElements) { int count = 0; SearchPanel.Children.OfType <SearchElements>().ToList().Where(x => x.Select).ToList().ForEach(x => { var ha = x.Article as HitomiArticle; var prefix = HitomiCommon.MakeDownloadDirectory(ha, SearchText.Text); Directory.CreateDirectory(prefix); if (!ha.IsUnstable) { DownloadSpace.Instance.RequestDownload(x.Article.Title, x.Article.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress((x.Article as HitomiArticle).Magic, y)).ToArray(), x.Article.ImagesLink.Select(y => Path.Combine(prefix, y)).ToArray(), Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, x.Article); } else { DownloaderHelper.ProcessUnstable(ha.UnstableModel); } count++; }); if (count > 0) { MainWindow.Instance.FadeOut_MiddlePopup($"{count}{(string)FindResource("msg_download_start")}"); } } else { int count = 0; SearchMaterialPanel.Children.OfType <SearchMaterialElements>().ToList().Where(x => x.Select).ToList().ForEach(x => { var ha = x.Article as HitomiArticle; var prefix = HitomiCommon.MakeDownloadDirectory(x.Article as HitomiArticle, SearchText.Text); Directory.CreateDirectory(prefix); if (!ha.IsUnstable) { DownloadSpace.Instance.RequestDownload(x.Article.Title, x.Article.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress((x.Article as HitomiArticle).Magic, y)).ToArray(), x.Article.ImagesLink.Select(y => Path.Combine(prefix, y)).ToArray(), Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, x.Article); } else { DownloaderHelper.ProcessUnstable(ha.UnstableModel); } count++; }); if (count > 0) { MainWindow.Instance.FadeOut_MiddlePopup($"{count}{(string)FindResource("msg_download_start")}"); } } } }
private void Button_Click(object sender, RoutedEventArgs e) { var btn = sender as Button; if (btn.Tag.ToString() == "DownloadAll") { try { int count = 0; ArticlePanel.Children.OfType <SearchSimpleElements>().ToList().ForEach(x => { var ha = x.Article as HitomiArticle; ha.Artists = new string[] { Artist }; var prefix = HitomiCommon.MakeDownloadDirectory(ha); Directory.CreateDirectory(prefix); if (!ha.IsUnstable) { DownloadSpace.Instance.RequestDownload(x.Article.Title, ha.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress((x.Article as HitomiArticle).Magic, y, ha.HasWebp[y], ha.HasWebp[y] || ha.Hashs[y].Length > 3 ? ha.Hashs[y] : "")).ToArray(), ha.ImagesLink.Select(y => Path.Combine(prefix, ha.HasWebp[y] ? y + ".webp" : y)).ToArray(), Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, x.Article); } else { DownloaderHelper.ProcessUnstable(ha.UnstableModel); } count++; }); if (count > 0) { MainWindow.Instance.FadeOut_MiddlePopup($"{count}{FindResource("msg_download_start")}"); } MainWindow.Instance.Activate(); MainWindow.Instance.FocusDownload(); Close(); } catch (Exception ex) { Koromo_Copy.Monitor.Instance.Push("[Artist Viewer] " + ex.Message); MessageBox.Show($"{FindResource("msg_wait_fucking_loading")}", "Koromo Copy", MessageBoxButton.OK, MessageBoxImage.Error); } } else if (btn.Tag.ToString() == "Download") { try { int count = 0; ArticlePanel.Children.OfType <SearchSimpleElements>().ToList().Where(x => x.Select).ToList().ForEach(x => { var ha = x.Article as HitomiArticle; ha.Artists = new string[] { Artist }; var prefix = HitomiCommon.MakeDownloadDirectory(ha); Directory.CreateDirectory(prefix); if (!ha.IsUnstable) { DownloadSpace.Instance.RequestDownload(x.Article.Title, ha.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress((x.Article as HitomiArticle).Magic, y, ha.HasWebp[y], ha.HasWebp[y] || ha.Hashs[y].Length > 3 ? ha.Hashs[y] : "")).ToArray(), ha.ImagesLink.Select(y => Path.Combine(prefix, ha.HasWebp[y] ? y + ".webp" : y)).ToArray(), Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, x.Article); } else { DownloaderHelper.ProcessUnstable(ha.UnstableModel); } count++; }); if (count > 0) { MainWindow.Instance.FadeOut_MiddlePopup($"{count}{FindResource("msg_download_start")}"); } MainWindow.Instance.Activate(); MainWindow.Instance.FocusDownload(); } catch (Exception ex) { Koromo_Copy.Monitor.Instance.Push("[Artist Viewer] " + ex.Message); MessageBox.Show($"{FindResource("msg_wait_fucking_all_loading")}", "Koromo Copy", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void Button_Click(object sender, RoutedEventArgs e) { var btn = sender as Button; if (btn.Tag.ToString() == "DownloadAll") { int count = 0; ArticlePanel.Children.OfType <SearchSimpleElements>().ToList().ForEach(x => { var ha = x.Article as HitomiArticle; ha.Artists = new string[] { Artist }; var prefix = HitomiCommon.MakeDownloadDirectory(ha); Directory.CreateDirectory(prefix); if (!ha.IsUnstable) { DownloadSpace.Instance.RequestDownload(x.Article.Title, x.Article.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress((x.Article as HitomiArticle).Magic, y)).ToArray(), x.Article.ImagesLink.Select(y => Path.Combine(prefix, y)).ToArray(), Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, x.Article); } else { DownloaderHelper.ProcessUnstable(ha.UnstableModel); } count++; }); if (count > 0) { MainWindow.Instance.FadeOut_MiddlePopup($"{count}{FindResource("msg_download_start")}"); } MainWindow.Instance.Activate(); MainWindow.Instance.FocusDownload(); Close(); } else if (btn.Tag.ToString() == "Download") { int count = 0; ArticlePanel.Children.OfType <SearchSimpleElements>().ToList().Where(x => x.Select).ToList().ForEach(x => { var ha = x.Article as HitomiArticle; ha.Artists = new string[] { Artist }; var prefix = HitomiCommon.MakeDownloadDirectory(ha); Directory.CreateDirectory(prefix); if (!ha.IsUnstable) { DownloadSpace.Instance.RequestDownload(x.Article.Title, x.Article.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress((x.Article as HitomiArticle).Magic, y)).ToArray(), x.Article.ImagesLink.Select(y => Path.Combine(prefix, y)).ToArray(), Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, x.Article); } else { DownloaderHelper.ProcessUnstable(ha.UnstableModel); } count++; }); if (count > 0) { MainWindow.Instance.FadeOut_MiddlePopup($"{count}{FindResource("msg_download_start")}"); } MainWindow.Instance.Activate(); MainWindow.Instance.FocusDownload(); } }
private void Button_Click(object sender, RoutedEventArgs e) { switch ((sender as Button).Tag.ToString()) { case "Preview": (new PreviewWindow(Article)).Show(); break; case "Artist": { if (Article is HitomiArticle ha) { if (ha.Artists != null) { (new ArtistViewerWindow(ha.Artists[0])).Show(); } } } break; case "Group": { if (Article is HitomiArticle ha) { if (ha.Groups != null) { (new GroupViewerWindow(ha.Groups[0])).Show(); } } } break; case "": case "Hitomi": { if (Article is HitomiArticle ha) { System.Diagnostics.Process.Start($"{HitomiCommon.HitomiAddress}galleries/{ha.Magic}.html"); } } break; case "Exhentai": { if (Article is HitomiArticle ha) { string result = ExHentaiTool.GetAddressFromMagicTitle(ha.Magic, ha.Title); if (result != "") { System.Diagnostics.Process.Start(result); } else { MainWindow.Instance.FadeOut_MiddlePopup("익헨 주소를 찾지 못했습니다 ㅠㅠ", false); } } } break; case "Series": { if (Article is HitomiArticle ha) { if (ha.Series != null) { (new FinderWindow($"series:{ha.Series[0].Replace(' ', '_')}")).Show(); } } } break; case "Character": { if (Article is HitomiArticle ha) { if (ha.Characters != null) { (new FinderWindow($"character:{ha.Characters[0].Replace(' ', '_')}")).Show(); } } } break; case "Comment": { if (Article is HitomiArticle ha) { string result = ExHentaiTool.GetAddressFromMagicTitle(ha.Magic, ha.Title); if (result != "") { (new CommentWindow(result)).Show(); } else { MainWindow.Instance.FadeOut_MiddlePopup("익헨 주소를 찾지 못했습니다 ㅠㅠ", false); } } } break; case "Download": { if (Article is HitomiArticle ha) { var prefix = HitomiCommon.MakeDownloadDirectory(ha); Directory.CreateDirectory(prefix); if (!ha.IsUnstable) { DownloadSpace.Instance.RequestDownload(ha.Title, ha.ImagesLink.Select(y => HitomiCommon.GetDownloadImageAddress(ha.Magic, y)).ToArray(), ha.ImagesLink.Select(y => Path.Combine(prefix, y)).ToArray(), Koromo_Copy.Interface.SemaphoreExtends.Default, prefix, ha); } else { DownloaderHelper.ProcessUnstable(ha.UnstableModel); } MainWindow.Instance.FadeOut_MiddlePopup($"1개 항목 다운로드 시작..."); MainWindow.Instance.Activate(); MainWindow.Instance.FocusDownload(); Close(); } } break; } }