public async Task <ImageSource> Resolve( Unsplasharp.Models.Photo source, Models.Photo destination, Task <ImageSource> destMember, ResolutionContext context) { var bitmapSource = await GenerateBlurHash(source.BlurHash ?? "LEHV6nWB2yk8pyo0adR*.7kCMdnj", source.Width, source.Height); return(bitmapSource); }
public static Photo ToPhoto(this Unsplasharp.Models.Photo photo) { return(new Photo { Id = photo.Id, Description = photo.Description, DownloadLink = photo.Links.Download, Location = photo.Location != null?photo.Location.ToLocation() : new Location(), User = new UserInfo { Name = photo.User != null ? photo.User.Name : String.Empty } }); }
static void Main(string[] args) { string apikey = ""; if (args.Length == 0) { Console.WriteLine("Please set Unsplash API Key in first arg."); return; } else { apikey = args[0]; } var client = new UnsplasharpClient(apikey); Unsplasharp.Models.Photo randomPhoto = null; string imagePath = ""; Task task = Task.Factory.StartNew(async() => { randomPhoto = await client.GetRandomPhoto(); }).Unwrap(); task.Wait(); // %TEMP%に保存 // imagePath = Path.GetTempPath() + randomPhoto.Id + ".jpg"; // jpg決め打ちでいいのかな・・・ WebClient wc = new WebClient(); wc.DownloadFile(randomPhoto.Links.Download, imagePath); Wallpaper.SetWallpaper(imagePath, WallpaperStyle.ResizeFill); // Wallpaper.UnsetWallpaper(); Console.WriteLine("Set Wallpaper."); }