Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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(Pixeval.Resources.Resources.SearchingSpotlight);

                var tasks = await Tasks <string, Illustration> .Of(await PixivClient.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;
            }
        }