Beispiel #1
0
        private async void buttonInstagram_Click(object sender, EventArgs e)
        {
            AutoScrollPositionDefault();

            await Task.Run(() => BlockElement(false));

            await Task.Run(() => OutputProgress("Loading"));

            _bitmapList.Clear();
            _colorImage.Clear();
            panelImage.Controls.Clear();
            var index = 0;

            var userMediaList = await _instagramClient.GetUserMedia(UserName.Text, (int)numericImage.Value / 18);

            if (userMediaList.Value != null && userMediaList.Value.Any())
            {
                foreach (var instaMedia in userMediaList.Value)
                {
                    index += 1;
                    string requestUriString = null;

                    if (instaMedia.Images != null && instaMedia.Images.Any())
                    {
                        requestUriString = instaMedia.Images.First().URI;
                    }
                    else if (instaMedia.Carousel != null && instaMedia.Carousel.Any())
                    {
                        requestUriString = instaMedia.Carousel.First().Images.First().URI;
                    }

                    await Task.Run(() => _bitmapList.Add(DownloadFile.DownloadImage(requestUriString)));

                    await Task.Run(() => GetImage(panelImage, _bitmapList.Last(), _bitmapList.Count - 1, 0));

                    await Task.Run(() => OutputProgress($"Uploaded {index} of {userMediaList.Value.Count}"));
                }
            }

            await Task.Run(() => BlockElement(true));

            CalculateColors();
        }