public void PhotosSerializationSkipBlankPhotoRowTest() { const string xml = @"<photos page=""1"" pages=""1"" perpage=""500"" total=""500""> <photo id=""3662960087"" owner=""18499405@N00"" secret=""9f8fcf9269"" server=""3379"" farm=""4"" title=""gecko closeup"" ispublic=""1"" isfriend=""0"" isfamily=""0"" dateupload=""1246050291"" tags=""reptile jinaacom geckocloseup geckoanatomy jinaajinahibrahim"" latitude=""1.45"" /> <photo id="""" owner="""" secret="""" server="""" farm=""0"" title="""" ispublic="""" isfriend="""" isfamily="""" dateupload="""" tags="""" latitude="""" /> <photo id=""3662960087"" owner=""18499405@N00"" secret=""9f8fcf9269"" server=""3379"" farm=""4"" title=""gecko closeup"" ispublic=""1"" isfriend=""0"" isfamily=""0"" dateupload=""1246050291"" tags=""reptile jinaacom geckocloseup geckoanatomy jinaajinahibrahim"" latitude=""1.45"" /> </photos>"; var photos = new PhotoCollection(); var sr = new StringReader(xml); var reader = new XmlTextReader(sr) {WhitespaceHandling = WhitespaceHandling.Significant}; reader.ReadToDescendant("photos"); ((IFlickrParsable) photos).Load(reader); Assert.IsNotNull(photos, "Photos should not be null"); Assert.AreEqual(500, photos.Total, "Total photos should be 500"); Assert.AreEqual(2, photos.Count, "Should only contain 2 photo"); }
private async void handleResults(PhotoCollection results, ObservableCollection<ThumbnailImage> List) { foreach (var res in results) { Geopoint point = null; if (res.Longitude != 0 && res.Latitude != 0) { var position = new BasicGeoposition() { Latitude = res.Latitude, Longitude = res.Longitude }; point = new Geopoint(position); } else if (res.Tags.Contains("cars")) { var position = new BasicGeoposition() { Longitude = 13.416350, Latitude = 52.526105 }; point = new Geopoint(position); } List.Add(new ThumbnailImage() { ImagePath = new Uri(res.ThumbnailUrl), ImageTitle = res.Title, BigImage = new Uri(res.LargeUrl), GeoLocation = point }); } }
private async void CheckAlreadyExists() { var data = StorageService.Instance.Storage.RetrieveList<PassportDataModel>(); if (data != null && data.Count > 0) { var dm = data[0]; var apis = StorageService.Instance.Storage.RetrieveList<APIKeyDataModel>(); if (apis != null && apis.Count > 0) apiKey = apis.Where(x => x.Id == dm.APIKeyFKID).FirstOrDefault(); RequestToken = new OAuthRequestToken() { Token = dm.Token, TokenSecret = dm.TokenSecret }; AccessToken = new OAuthAccessToken() { Username = dm.UserName, FullName = dm.FullName, ScreenName = dm.ScreenName, Token = dm.Token, TokenSecret = dm.TokenSecret, UserId = dm.UserId, }; IsLoggedIn = true; _flickr.OAuthAccessToken = AccessToken.Token; _flickr.OAuthAccessTokenSecret = AccessToken.TokenSecret; _flickr.ApiKey = apiKey.APIKey; _flickr.ApiSecret = apiKey.APISecret; var p = await _flickr.PeopleGetInfoAsync(AccessToken.UserId); if(!p.HasError) LoggedInUser = p.Result; var favs = await _flickr.FavoritesGetListAsync(AccessToken.UserId); if (!favs.HasError) Favourites = favs.Result; } }
public void LoadPhotoStream(PhotoCollection photos) { if (this.DataContext is PhotoInfo) { PhotoInfo dc = (PhotoInfo)this.DataContext; picsPhotoStream.LoadPictures(photos, dc.OwnerRealName + " photostream"); } }
public void LoadPictures(FlickrNet.PhotoCollection col, string title) { tbTitle.Text = title; gvMain.ItemsSource = col; if (ChangeViewState != null) { ChangeViewState("Normal", null); } }
private void search_Click(object sender, EventArgs e) { string str = text.Text; if (str != "") { PhotoSearchOptions opt = new PhotoSearchOptions(null, null, FlickrNet.TagMode.AnyTag, str); result = flickr.PhotosSearch(opt); this.DialogResult = System.Windows.Forms.DialogResult.OK; name = str; } }
public DomainPhotos Convert(PhotoCollection photoCollection) { if (photoCollection == null) return null; var domainPhotos = photoCollection .Select(photo => Mapper.Map<DomainPhoto>(photo)) .ToList(); return new DomainPhotos(domainPhotos, photoCollection.Page, photoCollection.Pages); }
public void doBackup(PhotoCollection photos) { foreach (var photo in photos) { flickr.PhotosSetMeta(photo.PhotoId, photo.Title, null); PhotosetCollection sets = flickr.PhotosetsGetList(); var set = sets[0]; flickr.PhotosetsAddPhoto(set.PhotosetId, set.Title); } }
public DomainPhotos Convert(PhotoCollection photoCollection) { if (photoCollection == null) return null; var domainPhotos = photoCollection .Select(photo => new DomainPhoto( photo.PhotoId, photo.UserId, photo.OwnerName, string.IsNullOrEmpty(photo.PathAlias) ? photo.UserId : photo.PathAlias, photo.Title, photo.WebUrl, photo.SmallUrl, photo.SmallWidth ?? 240, photo.SmallHeight ?? 240, IsLicensed(photo))) .ToList(); return new DomainPhotos(domainPhotos, photoCollection.Page, photoCollection.Pages); }
private void UpdatePhotos(FlickrNet.PhotoCollection photos, ref ArrayList serverphotoids) { foreach (FlickrNet.Photo p in photos) { DelegateIncrementProgressBar(); if (!PersistentInformation.GetInstance().HasLatestPhoto( p.PhotoId, p.lastupdate_raw)) { Photo photo = RetrievePhoto(p.PhotoId); if (photo == null) { continue; } PersistentInformation.GetInstance().UpdatePhoto(photo); } serverphotoids.Add(p.PhotoId); } }
private void populateGrid(PhotoCollection photos) { RowNow = 0; ColumnNow = 0; int results = ResultsPerSearch; foreach (var image in photos) { results--; if (results == 0) break; WebClient wc = new WebClient(); int cs = currentSearch; wc.OpenReadCompleted += (s, args) => { wc_OpenReadCompleted(s, args, cs); }; wc.OpenReadAsync(new Uri(image.MediumUrl), wc); } }
public Map SetRepositories(PhotoCollection photos) { List<Location> locations = new List<Location>(); Location loc = new Location(); for (int i = 0; i < photos.Count; i++) { loc.Image = photos[i].ThumbnailUrl; loc.LatLng = new LatLng { Latitude = photos[i].Latitude, Longitude = photos[i].Longitude }; loc.Name = photos[i].Title; locations.Add(loc); loc = new Location(); } return new Map { Name = "", Zoom = 2, center = new LatLng { Latitude = photos[0].Latitude, Longitude = photos[0].Longitude }, LatLng = new LatLng { Latitude = photos[0].Latitude, Longitude = photos[0].Longitude }, Locations = locations }; }
private void UpdatePhotosForAlbum(Album album) { // Don't update photos if the album is dirty, we need to flush our // changes first. if (PersistentInformation.GetInstance().IsAlbumDirty(album.SetId)) { return; } Gtk.Application.Invoke(delegate { DeskFlickrUI.GetInstance().SetStatusLabel( String.Format("Retrieving photos for set: {0}", album.Title)); DeskFlickrUI.GetInstance().SetProgressBarText(""); }); // Step 1: Get list of photos. FlickrNet.PhotoCollection photos = SafelyGetPhotos(album); if (photos == null) { UpdateUIAboutConnection(); return; } Gtk.Application.Invoke(delegate { DeskFlickrUI.GetInstance().SetLimitsProgressBar(photos.Length); }); // Step 2: Link the photos to the set, in the database. PersistentInformation.GetInstance().DeleteAllPhotosFromAlbum(album.SetId); foreach (FlickrNet.Photo p in photos) { DelegateIncrementProgressBar(); if (!PersistentInformation.GetInstance().HasPhoto(p.PhotoId)) { continue; } PersistentInformation.GetInstance().AddPhotoToAlbum(p.PhotoId, album.SetId); } }
public MainPage() { key1 = "plzzzzzzzzzzzzzzzzzzzzzz enter ur key here"; Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; if (localSettings.Values.ContainsKey("userName")) { username = localSettings.Values["userName"].ToString(); } flickr = new Flickr(key1); this.InitializeComponent(); try { obj = flickr.PeopleFindByUserName(username); userid.Text =obj.UserId; photos=flickr.PeopleGetPublicPhotos(obj.UserId); userid.Text=" "+photos.PerPage; userid.Text = flickr.UrlsGetUserPhotos(obj.UserId); total = photos.Count; if (total > 1) { userid.Text = photos.ElementAt(0).SmallUrl; image1.Source = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(image1.BaseUri, photos.ElementAt(0).SmallUrl)); present = 0; } else userid.Text = "You Dont Have any Public Photos"; //userid.Text = k; } catch (Exception) { userid.Text = "Exception catched"; } this.InitializeComponent(); }
private void GenerateItemsFromFlickrPhotos(PhotoCollection photos) { this.CurrentPhotoCollection = photos; ObservableCollection<Photo> photosCollection = new ObservableCollection<Photo>(); for (int i = 0; i < photos.Count; i++) { var photo = photos[i]; photosCollection.Add(photo); } if (this.PhotosLoaded != null) { this.PhotosLoaded(photosCollection); } if (this.CurrentPhotoCollection != null && this.CurrentPhotoCollection.Pages != this.CurrentPage) { this.CurrentPage++; } else { this.CurrentPage = 1; } }
private IList<Point> PointsFromPhotoCollection(PhotoCollection photos) { IList<Point> points = new List<Point>(); foreach (Photo p in photos) { Point point = new Point(this.DataSource); point.Id = p.PhotoId; point.Title = p.Title; point.Latitude = p.Latitude; point.Longitude = p.Longitude; point.Properties.Add("desc",p.Description); point.Properties.Add("owner",p.OwnerName); point.Properties.Add("taken",p.DateTaken.ToString("MMM d, yyyy @h:mtt")); point.Properties.Add("likes",p.CountFaves); point.Properties.Add("thumbnail",p.LargeSquareThumbnailUrl); //point.Properties.Add("thumbnail", p.SquareThumbnailUrl); if (!string.IsNullOrEmpty(p.LargeUrl)) point.Properties.Add("image",p.LargeUrl); else if (!string.IsNullOrEmpty(p.MediumUrl)) point.Properties.Add("image",p.MediumUrl); else point.Properties.Add("image",p.SmallUrl); point.AddTags(p.Tags); points.Add(point); } return points; }
public bool UpdateComments() { flickr_tablesEntities1 dbo = new flickr_tablesEntities1(); int contor = 0; try { var friends = dbo.friends.ToList(); var users = dbo.users.ToList(); Flickr f = GetInstance(); var commentsAll = dbo.commentsusers.ToList(); foreach (var item in commentsAll) { dbo.commentsusers.Remove(item); } dbo.SaveChanges(); Console.WriteLine("All cleared"); foreach (var item in friends) { Console.WriteLine("Added " + contor + " friend"); FlickrNet.PhotoCollection items = f.PeopleGetPublicPhotos(item.IdFriend); foreach (var itemx in items) { FlickrNet.PhotoCommentCollection comments = f.PhotosCommentsGetList(itemx.PhotoId); foreach (var comm in comments) { commentsuser commu = new commentsuser() { CommentatorId = comm.AuthorUserId, Comment = comm.AuthorRealName, PhotoId = itemx.PhotoId, UserId = item.IdFriend }; dbo.commentsusers.Add(commu); } } contor++; } foreach (var item in users) { Console.WriteLine("Added " + contor + " friend"); FlickrNet.PhotoCollection items = f.PeopleGetPublicPhotos(item.UserId); foreach (var itemx in items) { FlickrNet.PhotoCommentCollection comments = f.PhotosCommentsGetList(itemx.PhotoId); foreach (var comm in comments) { commentsuser commu = new commentsuser() { CommentatorId = comm.AuthorUserId, Comment = comm.AuthorRealName, PhotoId = itemx.PhotoId, UserId = item.UserId }; dbo.commentsusers.Add(commu); dbo.SaveChanges(); } } contor++; } dbo.SaveChanges(); Console.WriteLine("Data saved..."); } catch (Exception) { } return(true); }
private void GetLoggedInUserDetails(string userid) { //GET LOGGED IN USER DETAILS _flickr.PeopleGetInfoAsync(userid, new Action<FlickrResult<Person>>(p => { if (!p.HasError) { flickr_Person = p.Result; Dispatcher.RunAsync( Windows.UI.Core.CoreDispatcherPriority.High, new Windows.UI.Core.DispatchedHandler(() => { //imgUser.Source = new BitmapImage(new Uri(p.Result.BuddyIconUrl)); //brdAvatar.Opacity = 1; //lblName.Text = p.Result.UserName; //spLogin.Visibility = Visibility.Collapsed; //spLoggedIn.Visibility = Visibility.Visible; //lblProject.Visibility = Visibility.Visible; }) ); } })); //GET LOGGED IN USERS PUBLIC PICTURES _flickr.PeopleGetPublicPhotosAsync(userid, new Action<FlickrResult<PhotoCollection>>(pc => { if (!pc.HasError) { PersonPhotos = pc.Result; Dispatcher.RunAsync( Windows.UI.Core.CoreDispatcherPriority.High, new Windows.UI.Core.DispatchedHandler(() => { //lbPhotos.ItemsSource = PersonPhotos; }) ); } })); }
private void searchForm_FormClosed(object sender, FormClosedEventArgs e) { result = null; }
static void Main(string[] args) { StringBuilder errorLog = new StringBuilder(); errorLog.AppendFormat("Starting Run at {0}\n", DateTime.Now.ToString()); string baseDir = ConfigurationSettings.AppSettings["LocalDir"].ToString(); Flickr flickr = new Flickr(ConfigurationSettings.AppSettings["APIKey"].ToString(), ConfigurationSettings.AppSettings["APISecret"].ToString()); flickr.AuthToken = ""; Auth auth = flickr.AuthCheckToken(""); PhotoSearchOptions searchOptions = new PhotoSearchOptions(); searchOptions.PrivacyFilter = PrivacyFilter.None; searchOptions.UserId = auth.User.UserId; searchOptions.PerPage = 500; PhotoCollection pics = new PhotoCollection(); WebClient wget = new WebClient(); searchOptions.Extras |= PhotoSearchExtras.DateTaken | PhotoSearchExtras.OriginalFormat | PhotoSearchExtras.OriginalUrl | PhotoSearchExtras.Description | PhotoSearchExtras.Tags; PhotoCollection rev = flickr.PhotosSearch(searchOptions); while (rev.Pages >= searchOptions.Page) { foreach(Photo pic in rev){ //We have a picture. string year = pic.DateTaken.Year.ToString("0000"); string month = pic.DateTaken.Month.ToString("00"); string day = pic.DateTaken.Day.ToString("00"); // Does the directory Exist // No string directory = String.Format("{0}{1}\\{2}\\{3}\\", baseDir, year, month, day); try { if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } string fileName = string.Format("{0}.{1}", pic.PhotoId, pic.OriginalFormat); string finalDestination = String.Format("{0}{1}", directory, fileName); if (!File.Exists(finalDestination)) { wget.DownloadFile(pic.OriginalUrl, finalDestination); FileInfo fi = new FileInfo(finalDestination); if (fi.Length < 10000) { //This shoudl catch file unavailable throw new Exception("File size is too small"); } StreamWriter dataFile = new StreamWriter(String.Format("{0}{1}.xml", directory, fileName)); StringBuilder meta = new StringBuilder(); meta.AppendFormat("<xml>\n\t<file>{0}</file>\n\t<title>{1}</title>\n\t<description>{2}</description>\n\t<dateTaken>{3}</dateTaken>\n\t<tags>", fileName, pic.Title, pic.Description, pic.DateTaken.ToString()); foreach(String tag in pic.Tags){ meta.AppendFormat("\n\t\t<tag>{0}</tag>", tag); } meta.Append("\n\t</tags>\n</xml>"); dataFile.Write(meta.ToString()); dataFile.Close(); } } catch (System.Exception ex) { errorLog.AppendFormat("{0}:{1}:{2}\n", directory, pic.PhotoId, ex.Message); } } searchOptions.Page = rev.Page + 1; rev = flickr.PhotosSearch(searchOptions); } errorLog.AppendFormat("Finished Run at {0}\n", DateTime.Now.ToString()); StreamWriter file = new StreamWriter(ConfigurationSettings.AppSettings["LocalDir"].ToString() + "/errors.log"); file.Write(errorLog.ToString()); file.Close(); }
public ActionResult Create(Destino Destino,string Button, Map map) { var idViaje = Convert.ToInt32(Request["idViaje"]); if (Button == "Agregar Destino") { IRepositorio<Destino> repo = new DestinoRepositorio(); IRepositorio<Viaje> repoViaje = new ViajeRepositorio(); Destino.Viaje = repoViaje.GetById(idViaje); PhotoSearchOptions options = new PhotoSearchOptions(); options.Extras |= PhotoSearchExtras.Geo; options.Tags = map.Name; options.HasGeo = true; options.PerPage = 24; Flickr flickr = new Flickr("3de826e278b4988011ef0227585a7838", "81a96df44a82b16c"); photos = flickr.PhotosSearch(options); foreach (Photo photo in photos) { if (Destino.Url != null) { if (Destino.Url.CompareTo(photo.SmallUrl) == 0) { Destino.Latitud = photo.Latitude; Destino.Longitud = photo.Longitude; Destino.Nombre = photo.Title; } }else { ModelState.AddModelError(string.Empty,"Es Necesario que escoja una foto!"); return View(); } } repo.Save(Destino); int id2 = idViaje; ViewData["idViaje"] = id2; return RedirectToAction("Index", "Destino", new { idViaje = id2 }); } else { int i = 0; PhotoSearchOptions options = new PhotoSearchOptions(); //options.BoundaryBox = new BoundaryBox(-1.7, 54.9, -1.4, 55.2); // Roughly Newcastle upon Type, England //options.BoundaryBox = BoundaryBox.World; options.Extras |= PhotoSearchExtras.Geo; options.Tags = map.Name; options.HasGeo = true; options.PerPage = 24; Flickr flickr = new Flickr("18ead65365e9b505cc7f97abd38a33fe", "1b0f7df21b450da8"); photos = flickr.PhotosSearch(options); foreach (Photo photo in photos) { ViewData["Message"] = String.Format("Lugares de \"{0}\".", map.Name); ViewData.Add(("Message" + i), photo.SmallUrl); i++; } int id2 = idViaje; ViewData["idViaje"] = id2; return View(); } }
public ActionResult Map() { var mapRepository = new MapRepository(); Map map; if (photos.Count == 0) map = mapRepository.SetRepositories(); else map = mapRepository.SetRepositories(photos); photos = new PhotoCollection(); return Json(map, "1",JsonRequestBehavior.AllowGet); }
public void IsCommonsMultiplePages() { var options = new PhotoSearchOptions { IsCommons = true, Text = "photochrom", SortOrder = PhotoSearchSortOrder.DatePostedDescending, PerPage = 10, Page = 1, Extras = PhotoSearchExtras.DateUploaded }; var allPhotos = new PhotoCollection(); for(var i = 0; i < 10; i++) { options.Page = i + 1; var photos = Instance.PhotosSearch(options); var ids = photos.Select(p => p.PhotoId).ToArray(); var photo = allPhotos.FirstOrDefault(p => ids.Contains(p.PhotoId)); if( photo != null) { Assert.Fail("Duplicate photo {0} found on page {1}", photo.PhotoId, i + 1); } Console.WriteLine(Instance.LastRequest); Console.WriteLine(Instance.LastResponse); foreach (var p in photos) { allPhotos.Add(p); } } }
public void LoadPictures(FlickrNet.PhotoCollection col, string title) { tbTitle.Text = title; gvMain.ItemsSource = col; }
/// <summary> /// Adds all of the photos in another <see cref="PhotoCollection"/> to this collection. /// </summary> /// <param name="collection">The <see cref="PhotoCollection"/> containing the photos to add /// to this collection.</param> public void AddRange(PhotoCollection collection) { foreach(Photo photo in collection) List.Add(photo); }
private void showPhoto(PhotoCollection pc) { clean(); int i = 0; foreach (Photo p in pc) { PictureBox pb = new PictureBox(); Point location = new Point(20 + i % 4 * 320 + i % 4 * 10, 50 + i / 4 * 320 + i / 4 * 10); pb.Location = location; pb.Width = 320; pb.Height = 320; pb.SizeMode = PictureBoxSizeMode.CenterImage; pb.ImageLocation = p.Small320Url; pb.Parent = photoDisplayPanel; pb.ContextMenuStrip = photoContext; pb.Tag = p; pb.MouseHover += photo_Hover; pb.MouseLeave += photo_unHover; listPB.Add(pb); i++; } }
public static void UpdateFlickrImageCache() { initializeFlickr(); if (flickr != null) { PhotoSearchOptions options = new PhotoSearchOptions(); options.UserId = DefaultSettings.FlickrUserID; options.PerPage = 1000; options.Page = 1; PhotoCollection = flickr.PhotosSearch(options); if (PhotoCollection != null) { ImageDescriptions = new List<KeyValuePair<string, string>>(); foreach (Photo photo in PhotoCollection) { KeyValuePair<string, string> pair = new KeyValuePair<string, string>(photo.PhotoId, GetImageDescription(photo)); ImageDescriptions.Add(pair); } } } }
private async void PopulatePassportData() { if (apiKey == null) { IsLoginVisible = Visibility.Visible; return; } var data = StorageService.Instance.Storage.RetrieveList<PassportDataModel>(); if (data != null && data.Count > 0) { IsLoginVisible = Visibility.Visible; IsTabsVisible = Visibility.Collapsed; var dm = data.Where(x => x.PassType == GroupingType).FirstOrDefault(); if (dm != null) { IsLoginVisible = Visibility.Collapsed; IsTabsVisible = Visibility.Visible; RequestToken = new OAuthRequestToken() { Token = dm.Token, TokenSecret = dm.TokenSecret }; AccessToken = new OAuthAccessToken() { Username = dm.UserName, FullName = dm.FullName, ScreenName = dm.ScreenName, Token = dm.Token, TokenSecret = dm.TokenSecret, UserId = dm.UserId, }; //IsLoggedIn = true; _flickr.OAuthAccessToken = AccessToken.Token; _flickr.OAuthAccessTokenSecret = AccessToken.TokenSecret; _flickr.ApiKey = apiKey.APIKey; _flickr.ApiSecret = apiKey.APISecret; var p = await _flickr.PeopleGetInfoAsync(AccessToken.UserId); if (!p.HasError) LoggedInUser = p.Result; var favs = await _flickr.FavoritesGetListAsync(AccessToken.UserId); if (!favs.HasError) { var temp = new PhotoCollection(); foreach (var fav in favs.Result) { //fav.MachineTags = "https://c1.staticflickr.com/1/523/buddyicons/118877287@N03_l.jpg?1437204284#118877287@N03"; fav.MachineTags = $"https://c1.staticflickr.com/{fav.IconFarm}/{fav.IconServer}/buddyicons/{fav.UserId}.jpg?"; temp.Add(fav); } FavouritePhotos = temp; } } } else { //no passport so show login button IsLoginVisible = Visibility.Visible; IsTabsVisible = Visibility.Collapsed; } }