Пример #1
0
 public Pool(E621Api api, int id, bool load = true)
 {
     this.Api = api;
     this.Id  = id;
     if (load)
     {
         this.LoadData();
     }
 }
Пример #2
0
        public static Post Get(E621Api api, int id, XElement data)
        {
            var cache = Cache.FirstOrDefault(x => x.Id == id);

            if (cache != null)
            {
                return(cache);
            }

            return(new Post(api, id, data));
        }
Пример #3
0
 private Post(E621Api api, int id, XElement data)
 {
     this.Api = api;
     this.Id  = id;
     if (data == null)
     {
         this.Data    = this.Api.GetPostData(this.Id);
         this.FileUrl = this.Data.Element("file_url").Value;
     }
     else
     {
         this.Data    = data;
         this.FileUrl = this.Data.Element("file_url").Value;
     }
 }
Пример #4
0
        private async void DownloadPoolListButton_OnClick(object sender, RoutedEventArgs e)
        {
            System.Windows.Application.Current.Dispatcher.Invoke(() =>
            {
                this.PostsDownloadProgress.IsIndeterminate = true;
                this.DownloadPoolListButton.IsEnabled      = false;
                this.PostsDownloadProgress.Value           = 0;
            });

            var directory = this.SelectDirectory();
            var api       = new E621Api();
            var tags      = this.DownloadPoolListUrl.Text;

            void updateMethod(float?percent, string status)
            {
                System.Windows.Application.Current.Dispatcher.Invoke(() =>
                {
                    if (percent.Value != null)
                    {
                        this.PostsDownloadProgress.IsIndeterminate = false;
                        this.PostsDownloadProgress.Value           = percent.Value;
                    }
                    else if (percent.Value == 100)
                    {
                        this.PostsDownloadProgress.IsIndeterminate = true;
                    }

                    this.DownloadPoolsStatus.Content = status;
                });
            };

            if (this.DownloadMethodPools.IsChecked == true)
            {
                await api.DownloadPoolsByTagsAsync(tags, directory, updateMethod);
            }
            if (this.DownloadMethodPosts.IsChecked == true)
            {
                await api.DownloadPostsByTagsAsync(tags, directory, updateMethod);
            }


            System.Windows.Application.Current.Dispatcher.Invoke(() =>
            {
                this.DownloadPoolListButton.IsEnabled = true;
                this.PostsDownloadProgress.Value      = 0;
                MessageBox.Show("Download finished!");
            });
        }
Пример #5
0
 public static Post Get(E621Api api, int id)
 {
     return(Get(api, id, null));
 }