Example #1
0
        public Imgur(Twitter tw, TwitterConfiguration twitterConfig)
        {
            this.twitter = tw;
            this.twitterConfig = twitterConfig;

            this.imgurApi = new ImgurApi();
        }
        /// <summary>
        ///     Load the complete history of the imgur uploads, with the corresponding information
        /// </summary>
        private async Task LoadHistory(CancellationToken cancellationToken = default)
        {
            // Load the ImUr history
            foreach (var hash in ImgurConfiguration.ImgurUploadHistory.Keys)
            {
                if (ImgurHistory.Any(imgurInfo => imgurInfo.Data.Id == hash))
                {
                    continue;
                }
                if (ImgurConfiguration.RuntimeImgurHistory.ContainsKey(hash))
                {
                    // Already loaded, only add it to the view
                    ImgurHistory.Add(ImgurConfiguration.RuntimeImgurHistory[hash]);
                    continue;
                }
                try
                {
                    var imgurInfo = await ImgurApi.RetrieveImgurInfoAsync(hash, ImgurConfiguration.ImgurUploadHistory[hash], cancellationToken).ConfigureAwait(true);

                    if (imgurInfo != null)
                    {
                        await ImgurApi.RetrieveImgurThumbnailAsync(imgurInfo, cancellationToken).ConfigureAwait(true);

                        ImgurConfiguration.RuntimeImgurHistory.Add(hash, imgurInfo);
                        // Already loaded, only add it to the view
                        ImgurHistory.Add(imgurInfo);
                    }
                    else
                    {
                        Log.Debug().WriteLine("Deleting not found ImgUr {0} from config.", hash);
                        ImgurConfiguration.ImgurUploadHistory.Remove(hash);
                    }
                }
                catch (Exception e)
                {
                    Log.Error().WriteLine(e, "Problem loading ImgUr history for hash {0}", hash);
                }
            }
        }
 /// <summary>
 /// Used from the View
 /// </summary>
 public async Task Delete()
 {
     await ImgurApi.DeleteImgurImageAsync(SelectedImgur).ConfigureAwait(true);
 }
 /// <summary>
 ///     Sets up an instance of our ImgurAuthorize object that will be used
 ///     to get a pin from the user, and then verify it.
 /// </summary>
 /// <param name="imgurApi">A reference to the ImgurApi Object</param>
 public ImgurAuthorize(ImgurApi imgurApi)
 {
     _imgurApi = imgurApi;
     InitializeComponent();
 }
Example #5
0
        public Imgur(TwitterConfiguration twitterConfig)
        {
            this.twitterConfig = twitterConfig;

            this.imgurApi = new ImgurApi();
        }
Example #6
0
 public UploadConfirmationDialog(ImgurApi api, Image image)
 {
     InitializeComponent();
     mApi = api;
     pictureBox1.Image = image;
 }