コード例 #1
0
ファイル: PhotoTests.cs プロジェクト: rootasjey/unsplasharp
        public async Task ListPhotosTest()
        {
            var client     = new UnsplasharpClient(Credentials.ApplicationId);
            var listPhotos = await client.ListPhotos();

            var listPhotosPaged = await client.ListPhotos(page : 2, perPage : 15, orderBy : OrderBy.Popular);

            Assert.IsTrue(listPhotos.Count > 0);
            Assert.IsTrue(listPhotosPaged.Count > 0);
        }
コード例 #2
0
        private async void GetPhotos(int page)
        {
            EnableControls(false);
            _photos = await _client.ListPhotos(page, 4);

            DisplayPhotos();
        }
コード例 #3
0
        private static async Task GetPhotos()
        {
            try
            {
                var photos = await _client.ListPhotos(1, 4);

                var images = new List <Image>();
                await Task.Run(() =>
                {
                    for (var i = 0; i < 4; i++)
                    {
                        images.Add(Task.Run(() => HttpUtil.StreamUrlToImage(photos[i].Urls.Small)).Result);
                    }

                    var appMainThread = new Thread(() => new MainForm(photos, images).ShowDialog());
                    appMainThread.SetApartmentState(ApartmentState.STA);
                    appMainThread.Start();
                    Application.Exit();
                });
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message,
                                $"—{Application.ProductName}—", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
        }
コード例 #4
0
        public async Task <IEnumerable <Models.Photo> > ListPhotos(int page, int pageSize)
        {
            // var ii = await GeneralProfile.GenerateBlurHash("LXKKsLxv?^ozOZNGMxnhE1RjM_t7", 5419, 3613);
            var listPhotosPaged = await _client.ListPhotos(page, pageSize);

            var items = _mapper.Map <IEnumerable <Unsplasharp.Models.Photo>, IEnumerable <Models.Photo> >(listPhotosPaged);

            return(items);
        }
コード例 #5
0
ファイル: PhotoTests.cs プロジェクト: rootasjey/unsplasharp
        public async Task GetPhotoDownloadLinkTest()
        {
            var client     = new UnsplasharpClient(Credentials.ApplicationId);
            var listPhotos = await client.ListPhotos();

            var downloadLink = await client.GetPhotoDownloadLink(listPhotos[0].Id);

            Assert.IsNotNull(downloadLink);
        }
コード例 #6
0
ファイル: PhotoTests.cs プロジェクト: rootasjey/unsplasharp
        public async Task GetPhotoStatsTest()
        {
            var client     = new UnsplasharpClient(Credentials.ApplicationId);
            var listPhotos = await client.ListPhotos();

            var statsPhoto = await client.GetPhotoStats(listPhotos[0].Id);

            Assert.IsNotNull(statsPhoto);
        }
コード例 #7
0
        public async Task <IEnumerable <SplashPhotoEntity> > ListPhotos(int page, int pageSize)
        {
            var items = await _client.ListPhotos(page, pageSize);

            var entities = new List <SplashPhotoEntity>();

            items.ForEach(item =>
            {
                entities.Add(new SplashPhotoEntity
                {
                    Blurhash    = item.BlurHash,
                    ImageAuthor = item.User?.Username,
                    Color       = item.Color,
                    ImageUri    = item.Urls.Small,
                    Width       = item.Width,
                    Height      = item.Height
                });
            });
            return(entities);
        }