public List <Photo> GetListFor(string albumId) { var service = new PicasaService("GPhotoSync"); service.SetAuthenticationToken(_credentials.AccessToken); var query = new PhotoQuery(PicasaQuery.CreatePicasaUri(_credentials.User, albumId)); query.ExtraParameters = "imgmax=d"; var feed = service.Query(query); if (feed != null) { var list = feed.Entries .OfType <PicasaEntry>() .Select(x => { var accessor = new PhotoAccessor(x); return(new Photo { Id = accessor.Id, Title = accessor.PhotoTitle, Path = x.Media.Content.Url }); }); return(list.OfType <Photo>().ToList()); } else { return(new List <Photo>()); } }
public List <Album> GetList() { var service = new PicasaService("GPhotoSync"); service.SetAuthenticationToken(_credentials.AccessToken); var query = new AlbumQuery(); query.Thumbsize = "180"; query.Uri = new Uri(PicasaQuery.CreatePicasaUri(_credentials.User)); var feed = service.Query(query); if (feed != null) { var list = feed.Entries .OfType <PicasaEntry>() .Where(x => !IsPostEntry(x)) .OrderBy(x => x.Title.Text) .Select(x => { var accessor = new AlbumAccessor(x); var thumb = x.Media.Thumbnails[0]; using (var stream = service.Query(new Uri(thumb.Attributes["url"] as string))) { var ms = new MemoryStream(); stream.CopyTo(ms); ms.Seek(0, SeekOrigin.Begin); return(new Album { Id = accessor.Id, Title = accessor.AlbumTitle, ImageStream = ms, PhotoCount = (int)accessor.NumPhotos }); } }) .ToList(); return(list); } else { return(new List <Album>()); } }
public void UploadPhotoTo(string albumId, string filename) { var service = new PicasaService("GPhotoSync"); service.SetAuthenticationToken(_credentials.AccessToken); var query = new PhotoQuery(PicasaQuery.CreatePicasaUri(_credentials.User, albumId)); var feed = service.Query(query); var media = new MediaFileSource(filename, MimeTypes.GetMimeType(Path.GetExtension(filename))); var photo = new PhotoEntry(); photo.Title = new AtomTextConstruct { Text = Path.GetFileNameWithoutExtension(filename) }; photo.MediaSource = media; service.Insert(feed, photo); }
private void OnLoad(object sender, System.EventArgs e) { if (this.googleAuthToken == null) { GoogleClientLogin loginDialog = new GoogleClientLogin(new PicasaService("PhotoBrowser"), "*****@*****.**"); loginDialog.ShowDialog(); this.googleAuthToken = loginDialog.AuthenticationToken; this.user = loginDialog.User; if (this.googleAuthToken != null) { picasaService.SetAuthenticationToken(loginDialog.AuthenticationToken); UpdateAlbumFeed(); } else { this.Close(); } } }