private void UpdateIllustTab_OnSelected(object sender, RoutedEventArgs e) { QueryStartUp(); MessageQueue.Enqueue("正在获取关注用户的最新作品..."); PixivHelper.Iterate(new UserUpdateAsyncEnumerable(), NewItemsSource <Illustration>(ImageListView)); }
private void UpdateIllustTab_OnSelected(object sender, RoutedEventArgs e) { QueryStartUp(); MessageQueue.Enqueue("正在获取关注用户的最新作品..."); PixivHelper.DoIterate(new UserUpdateIterator(), ImageListViewNewItemSource()); }
private void RankingTab_OnSelected(object sender, RoutedEventArgs e) { QueryStartUp(); MessageQueue.Enqueue("正在获取每日推荐的作品..."); PixivHelper.DoIterate(new RankingIterator(), ImageListViewNewItemSource(), true); }
private async void IllustBrowserDialogHost_OnDialogOpened(object sender, DialogOpenedEventArgs e) { var context = sender.GetDataContext <Illustration>(); var list = new ObservableCollection <TransitionerSlide>(); var template = new IllustTransitioner(list); IllustBrowserContainer.Children.Insert(1, template); if (context.IsManga) { if (context.MangaMetadata.IsNullOrEmpty()) { context = await PixivHelper.IllustrationInfo(context.Id); } var tasks = await Tasks <Illustration, (BitmapImage image, Illustration illust)> .Of(context.MangaMetadata) .Mapping(illustration => Task.Run(async() => (await PixivEx.FromUrl(illustration.Large), illustration))) .Construct() .WhenAll(); list.AddRange(tasks.Select(i => InitTransitionerSlide(i.image, i.illust))); } else { list.Add(InitTransitionerSlide(await PixivEx.FromUrl(context.Large), context)); } }
public async void OpenIllustBrowser(Illustration illustration, bool record = true) { if (!illustration.FromSpotlight && record) { PixivHelper.RecordTimelineInternal(new BrowsingHistory { BrowseObjectId = illustration.Id, BrowseObjectState = illustration.Title, BrowseObjectThumbnail = illustration.Thumbnail, IllustratorName = illustration.UserName, IsReferToIllust = true, Type = "illust" }); } IllustBrowserDialogHost.DataContext = illustration; await Task.Delay(100); IllustBrowserDialogHost.OpenControl(); var userInfo = await HttpClientFactory.AppApiService() .GetUserInformation(new UserInformationRequest { Id = illustration.UserId }); if (await PixivIO.FromUrl(userInfo.UserEntity.ProfileImageUrls.Medium) is { } avatar) { SetImageSource(IllustBrowserUserAvatar, avatar); } }
private void FollowingTab_OnSelected(object sender, RoutedEventArgs e) { QueryStartUp(); MessageQueue.Enqueue("正在获取关注列表..."); PixivHelper.DoIterate(new UserFollowingIterator(Identity.Global.Id), NewItemsSource <User>(UserPreviewListView)); }
public async void SetUserBrowserContext(User user) { var usr = await HttpClientFactory.AppApiService() .GetUserInformation(new UserInformationRequest { Id = $"{user.Id}" }); var usrEntity = new User { Avatar = usr.UserEntity.ProfileImageUrls.Medium, Background = usr.UserEntity.ProfileImageUrls.Medium, Follows = (int)usr.UserProfile.TotalFollowUsers, Id = usr.UserEntity.Id.ToString(), Introduction = usr.UserEntity.Comment, IsFollowed = usr.UserEntity.IsFollowed, IsPremium = usr.UserProfile.IsPremium, Name = usr.UserEntity.Name, Thumbnails = user.Thumbnails }; PixivHelper.RecordTimelineInternal(new BrowsingHistory { BrowseObjectId = usrEntity.Id, BrowseObjectState = usrEntity.Name, BrowseObjectThumbnail = usrEntity.Avatar, IsReferToUser = true, Type = "user" }); UserBrowserPageScrollViewer.DataContext = usrEntity; SetUserBanner(usrEntity.Id); SetImageSource(UserBrowserUserAvatar, await PixivIO.FromUrl(usrEntity.Avatar)); SetupUserUploads(usrEntity.Id); }
private async void SauceNaoPage_OnDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { if (e.Data.GetData(DataFormats.FileDrop) is string[] fs) { if (fs.Length > 1) { MainWindow.MessageQueue.Enqueue(AkaI18N.SauceNaoFileCountLimit); } else { try { UploadFileAndQueryButton.IsEnabled = false; Searching.Visibility = Visibility.Visible; UploadFileTextBox.Text = fs[0]; if ((await DoQuery(fs[0])).ToList() is { } sauceResults&& sauceResults.Any()) { MainWindow.Instance.OpenIllustBrowser( await PixivHelper.IllustrationInfo(sauceResults[0])); } else { MainWindow.MessageQueue.Enqueue(AkaI18N.CannotFindResult); } }
private async void SpotlightContainer_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { MessageQueue.Enqueue(AkaI18N.SearchingSpotlight); var article = sender.GetDataContext <SpotlightArticle>(); var tasks = await Tasks <string, Illustration> .Of(await PixivClient.Instance.GetArticleWorks(article.Id.ToString())) .Mapping(PixivHelper.IllustrationInfo) .Construct() .WhenAll(); var result = tasks.Peek(i => { i.IsManga = true; i.FromSpotlight = true; i.SpotlightTitle = article.Title; }).ToArray(); PixivHelper.RecordTimelineInternal(new BrowsingHistory { BrowseObjectId = article.Id.ToString(), BrowseObjectState = article.Title, BrowseObjectThumbnail = article.Thumbnail, IsReferToSpotlight = true, Type = "spotlight" }); OpenIllustBrowser(result[0].Apply(r => r.MangaMetadata = result.ToArray())); }
private void RecommendTab_OnSelected(object sender, RoutedEventArgs e) { QueryStartUp(); MessageQueue.Enqueue(AkaI18N.SearchingRecommend); PixivHelper.Enumerate(Settings.Global.SortOnInserting ? (AbstractRecommendAsyncEnumerable) new PopularityRecommendAsyncEnumerable() : new PublishDateRecommendAsyncEnumerable(), NewItemsSource <Illustration>(ImageListView), 10); }
private async void TryQuerySingle(string illustId) { if (!int.TryParse(illustId, out _)) { MessageQueue.Enqueue(AkaI18N.IdIllegal); return; } try { OpenIllustBrowser(await PixivHelper.IllustrationInfo(illustId)); } catch (ApiException exception) { if (exception.StatusCode == HttpStatusCode.NotFound || exception.StatusCode == HttpStatusCode.BadRequest) { MessageQueue.Enqueue(AkaI18N.IdDoNotExists); } else { throw; } } }
public async void Download() { var result = await Tasks <string, Illustration> .Of(await PixivClient.GetArticleWorks(Id.ToString())).Mapping(async i => { var res = await PixivHelper.IllustrationInfo(i); if (res == null) { return(null); } res.SpotlightTitle = Title; res.SpotlightArticleId = Id.ToString(); res.FromSpotlight = true; res.MangaMetadata?.Peek(m => { m.FromSpotlight = true; m.SpotlightTitle = Title; m.SpotlightArticleId = Id.ToString(); }); return(res); }).Construct().WhenAll(); foreach (var illustration in result.Where(i => i != null)) { DownloadManager.EnqueueDownloadItem(illustration); } }
private void UpdateIllustTab_OnSelected(object sender, RoutedEventArgs e) { QueryStartUp(); MessageQueue.Enqueue(AkaI18N.SearchingUserUpdates); PixivHelper.Enumerate(new UserUpdateAsyncEnumerable(), NewItemsSource <Illustration>(ImageListView)); }
private async void UploadFileAndQueryButton_OnClick(object sender, RoutedEventArgs e) { using var fileDialog = new CommonOpenFileDialog("选择文件") { Multiselect = false }; try { if (fileDialog.ShowDialog() == CommonFileDialogResult.Ok) { Searching.Visibility = Visibility.Visible; UploadFileTextBox.Text = fileDialog.FileName; await using var memoryStream = new MemoryStream(await File.ReadAllBytesAsync(UploadFileTextBox.Text), false); var sauceResponse = await RestService.For <ISauceNAOProtocol>(ProtocolBase.SauceNAOUrl) .GetSauce(new StreamPart(memoryStream, Path.GetFileName(fileDialog.FileName), Texts.AssumeImageContentType(fileDialog.FileName))); var content = await sauceResponse.Content.ReadAsStringAsync(); if ((await ParseSauce(content)).ToList() is { } sauceResults&& sauceResults.Any()) { MainWindow.Instance.OpenIllustBrowser(await PixivHelper.IllustrationInfo(sauceResults[0])); } else { MainWindow.MessageQueue.Enqueue("找不到结果TAT"); } } }
private void RankingTab_OnSelected(object sender, RoutedEventArgs e) { QueryStartUp(); MessageQueue.Enqueue("正在获取每日推荐的作品..."); PixivHelper.Iterate(new RankingAsyncEnumerable(Settings.Global.SortOnInserting ? SortOption.Popularity : SortOption.PublishDate), ImageListViewNewItemSource(), 10); }
public Illustration Parse() { return(new Illustration { Bookmark = (int)(Stats.FavoritedCount.Public + Stats.FavoritedCount.Private), Id = Id.ToString(), IsLiked = FavoriteId != 0, IsUgoira = Type == "ugoira", IsManga = IsManga, Origin = ImageUrls.Large, Large = ImageUrls.Large, Tags = Tags.Select(t => new Tag { Name = t }), Thumbnail = ImageUrls.Px480Mw.IsNullOrEmpty() ? ImageUrls.Px128X128 : ImageUrls.Px480Mw, Title = Title, UserId = User.Id.ToString(), UserName = User.Name, Resolution = $"{Width}x{Height}", ViewCount = (int)Stats.ViewsCount, PublishDate = CreatedTime }.Apply(async i => { if (i.IsManga) { i.MangaMetadata = (await PixivHelper.IllustrationInfo(i.Id)).MangaMetadata; } })); }
private void TrendsTab_OnSelected(object sender, RoutedEventArgs e) { QueryStartUp(); MessageQueue.Enqueue(AkaI18N.SearchingTrends); PixivHelper.Enumerate(new TrendsAsyncEnumerable(), NewItemsSource <Trends>(TrendsListView), 20); }
private void GalleryTab_OnSelected(object sender, RoutedEventArgs e) { QueryStartUp(); MessageQueue.Enqueue("正在获取收藏夹..."); PixivHelper.DoIterate(new GalleryIterator(Identity.Global.Id), ImageListViewNewItemSource()); }
private void SpotlightTab_OnSelected(object sender, RoutedEventArgs e) { QueryStartUp(); var iterator = new SpotlightQueryIterator(Settings.Global.SpotlightQueryStart, Settings.Global.QueryPages); PixivHelper.DoIterate(iterator, NewItemsSource <SpotlightArticle>(SpotlightListView), true); }
private void SpotlightTab_OnSelected(object sender, RoutedEventArgs e) { QueryStartUp(); var iterator = new SpotlightQueryAsyncEnumerable(Settings.Global.SpotlightQueryStart); PixivHelper.Enumerate(iterator, NewItemsSource <SpotlightArticle>(SpotlightListView), 10); }
private void QueryWorks(string keyword) { QueryStartUp(); SearchingHistoryManager.EnqueueSearchHistory(keyword); PixivHelper.Enumerate(Settings.Global.SortOnInserting ? (AbstractQueryAsyncEnumerable) new PopularityQueryAsyncEnumerable(keyword, Settings.Global.TagMatchOption, Session.Current.IsPremium, Settings.Global.QueryStart) : new PublishDateQueryAsyncEnumerable(keyword, Settings.Global.TagMatchOption, Session.Current.IsPremium, Settings.Global.QueryStart), NewItemsSource <Illustration>(ImageListView), Settings.Global.QueryPages); }
public async void Download() { var result = await Tasks <string, Illustration> .Of(await PixivClient.Instance.GetArticleWorks(Id.ToString())).Mapping(async i => { var res = await PixivHelper.IllustrationInfo(i); res.SpotlightTitle = Title; res.FromSpotlight = true; return(res); }).Construct().WhenAll(); foreach (var illustration in result) { DownloadManager.EnqueueDownloadItem(illustration); } }
private void PublicRestrictPolicy_OnChecked(object sender, RoutedEventArgs e) { if (!IsLoaded) { return; } if (Navigating(GalleryTab)) { MessageQueue.Enqueue("正在获取收藏夹..."); PixivHelper.Iterate(AbstractGalleryAsyncEnumerable.Of(Identity.Global.Id, RestrictPolicy.Public), NewItemsSource <Illustration>(ImageListView)); } else if (Navigating(FollowingTab)) { MessageQueue.Enqueue("正在获取关注列表..."); PixivHelper.Iterate(AbstractUserFollowingAsyncEnumerable.Of(Identity.Global.Id, RestrictPolicy.Public), NewItemsSource <User>(UserPreviewListView)); } }
private void PublicRestrictPolicy_OnChecked(object sender, RoutedEventArgs e) { if (!IsLoaded) { return; } if (Navigating(GalleryTab)) { MessageQueue.Enqueue(AkaI18N.SearchingGallery); PixivHelper.Enumerate(AbstractGalleryAsyncEnumerable.Of(Session.Current.Id, RestrictPolicy.Public), NewItemsSource <Illustration>(ImageListView)); } else if (Navigating(FollowingTab)) { MessageQueue.Enqueue(AkaI18N.SearchingFollower); PixivHelper.Enumerate(AbstractUserFollowingAsyncEnumerable.Of(Session.Current.Id, RestrictPolicy.Public), NewItemsSource <User>(UserPreviewListView)); } }
private void GetRanking() { var option = RankOptionPicker.SelectedItem.GetDataContext <RankOptionModel[]>().First(p => p.IsSelected); var dateTime = RankDatePicker.SelectedDate; if (option.Corresponding.AttributeAttached <ForR18Only>() && Settings.Global.ExcludeTag.Any(t => t.ToUpper() == "R-18" || t.ToUpper() == "R-18G")) { MessageQueue.Enqueue(AkaI18N.RankNeedR18On); NewItemsSource <Illustration>(ImageListView); return; } if (dateTime is { } time) { PixivHelper.Enumerate(new RankingAsyncEnumerable(option.Corresponding, time), NewItemsSource <Illustration>(ImageListView)); return; } MessageQueue.Enqueue(AkaI18N.RankDateCannotBeNull); }
public static async Task DownloadSpotlight(SpotlightArticle article) { var root = TextBuffer.GetOrCreateDirectory(Path.Combine(Settings.Global.DownloadLocation, "Spotlight", article.Title)); var illusts = await PixivClient.Instance.GetArticleWorks(article.Id.ToString()); var list = new List <Task>(); foreach (var illust in illusts) { var illustration = await PixivHelper.IllustrationInfo(illust); if (illustration != null) { list.Add(DownloadIllust(illustration, root)); } } await Task.WhenAll(list); }
private async void BrowsingHistoryMainImage_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { MainWindow.Instance.DownloadQueueDialogHost.CurrentSession.Close(); var ctx = sender.GetDataContext <BrowsingHistory>(); switch (ctx.Type) { case "spotlight": MainWindow.MessageQueue.Enqueue(AkaI18N.SearchingSpotlight); var tasks = await Tasks <string, Illustration> .Of(await PixivClient.Instance.GetArticleWorks(ctx.BrowseObjectId)) .Mapping(PixivHelper.IllustrationInfo) .Construct() .WhenAll(); var result = tasks.Peek(i => { i.IsManga = true; i.FromSpotlight = true; i.SpotlightTitle = ctx.BrowseObjectState; }).ToArray(); PixivHelper.RecordTimelineInternal(new BrowsingHistory { BrowseObjectId = ctx.BrowseObjectId, BrowseObjectState = ctx.BrowseObjectState, BrowseObjectThumbnail = ctx.BrowseObjectThumbnail, IsReferToSpotlight = true, Type = "spotlight" }); MainWindow.Instance.OpenIllustBrowser(result[0].Apply(r => r.MangaMetadata = result.ToArray())); break; case "illust": MainWindow.Instance.OpenIllustBrowser(await PixivHelper.IllustrationInfo(ctx.BrowseObjectId)); break; } }
private async void IllustBrowserDialogHost_OnDialogOpened(object sender, DialogOpenedEventArgs e) { var context = sender.GetDataContext <Illustration>(); var list = new ObservableCollection <TransitionerSlide>(); var template = new IllustTransitioner(list); IllustBrowserContainer.Children.Insert(1, template); if (context.IsManga) { if (context.MangaMetadata.IsNullOrEmpty()) { context = await PixivHelper.IllustrationInfo(context.Id); } list.AddRange(context.MangaMetadata.Select(InitTransitionerSlide)); } else { list.Add(InitTransitionerSlide(context)); } }
private async void TryQuerySingle(string illustId) { if (!int.TryParse(illustId, out _)) { Notice(Externally.InputIllegal("单个作品")); return; } try { IllustViewer.Show(await PixivHelper.IllustrationInfo(illustId)); } catch (ApiException exception) { if (exception.StatusCode == HttpStatusCode.NotFound || exception.StatusCode == HttpStatusCode.BadRequest) { Notice(Externally.IdDoNotExists); } else { throw; } } }
private void SetupUserGallery(string id) { PixivHelper.Enumerate(AbstractGalleryAsyncEnumerable.Of(id, RestrictPolicy.Public), NewItemsSource <Illustration>(UserIllustsImageListView)); }