Inheritance: IFlickrParsable
Exemplo n.º 1
0
        public async void LoadPicture(FlickrNet.Photo photo)
        {
            //imgMain.Source = new Uri(photo.OwnerName);

            try
            {
                var folder = await Windows.Storage.KnownFolders.PicturesLibrary.GetFolderAsync("ModernCSApp");

                var file = await folder.GetFileAsync(photo.PhotoId + "_" + photo.Secret + ".jpg");

                using (var stream = await file.OpenReadAsync())
                {
                    BitmapImage bi = new BitmapImage();
                    bi.SetSource(stream);
                    imgMain.Source = bi;


                    //if (RenderingService.MagicRenderer != null && RenderingService.MagicRenderer is ISpriteRenderer)
                    //{
                    //    var gt = Window.Current.Content.TransformToVisual(imgMain);
                    //    var p = gt.TransformPoint(new Point(0, 0));
                    //    ((ISpriteRenderer)RenderingService.MagicRenderer).AddSprite(p.X, p.Y, 0, 1);
                    //}
                }


                //imgMain.Source = bi;
                if (ChangeViewState != null)
                {
                    ChangeViewState("Normal", null);
                }
            }
            catch {
            }
        }
Exemplo n.º 2
0
		/// <summary>
		/// Creates an instance of the <see cref="PhotoCollection"/> from an array of <see cref="Photo"/>
		/// instances.
		/// </summary>
		/// <param name="photos">An array of <see cref="Photo"/> instances.</param>
		public PhotoCollection(Photo[] photos)
		{
			for (int i=0; i<photos.Length; i++)
			{
				List.Add(photos[i]);
			}
		}
Exemplo n.º 3
0
 void IFlickrParsable.Load(XmlReader reader)
 {
     if (!(reader.LocalName != "photos"))
     ;
       while (reader.MoveToNextAttribute())
       {
     switch (reader.LocalName)
     {
       case "total":
     this.Total = string.IsNullOrEmpty(reader.Value) ? 0 : int.Parse(reader.Value, (IFormatProvider) CultureInfo.InvariantCulture);
     continue;
       case "perpage":
       case "per_page":
     this.PerPage = string.IsNullOrEmpty(reader.Value) ? 0 : int.Parse(reader.Value, (IFormatProvider) CultureInfo.InvariantCulture);
     continue;
       case "page":
     this.Page = string.IsNullOrEmpty(reader.Value) ? 0 : int.Parse(reader.Value, (IFormatProvider) CultureInfo.InvariantCulture);
     continue;
       case "pages":
     this.Pages = string.IsNullOrEmpty(reader.Value) ? 0 : int.Parse(reader.Value, (IFormatProvider) CultureInfo.InvariantCulture);
     continue;
       default:
     continue;
     }
       }
       reader.Read();
       while (reader.LocalName == "photo")
       {
     Photo photo = new Photo();
     photo.Load(reader);
     if (!string.IsNullOrEmpty(photo.PhotoId))
       this.Add(photo);
       }
       reader.Skip();
 }
Exemplo n.º 4
0
        public string GetImageUrl(FlickrNet.Photo p, ImageSize imgsize)
        {
            string url = null;

            switch (imgsize)
            {
            case ImageSize.Thumbnail:
                url = p.ThumbnailUrl;
                break;

            case ImageSize.Small:
                url = p.SmallUrl;
                break;

            case ImageSize.Medium:
                url = p.MediumUrl;
                break;

            case ImageSize.Large:
                url = p.LargeUrl;
                break;
            }

            return(url);
        }
Exemplo n.º 5
0
		/// <summary>
		/// Creates an instance of the <see cref="PhotoCollection"/> from an array of <see cref="Photo"/>
		/// instances.
		/// </summary>
		/// <param name="photos">An array of <see cref="Photo"/> instances.</param>
		public PhotoCollection(Photo[] photos)
		{
			if (photos == null) return;

			for (int i=0; i<photos.Length; i++)
			{
				List.Add(photos[i]);
			}
		}
Exemplo n.º 6
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "photoset")
                UtilityMethods.CheckParsingException(reader);

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "id":
                        PhotosetId = reader.Value;
                        break;
                    case "primary":
                        PrimaryPhotoId = reader.Value;
                        break;
                    case "owner":
                        OwnerId = reader.Value;
                        break;
                    case "ownername":
                        OwnerName = reader.Value;
                        break;
                    case "page":
                        Page = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                        break;
                    case "total":
                        Total = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                        break;
                    case "pages":
                        Pages = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                        break;
                    case "perpage":
                    case "per_page":
                        PerPage = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

            while (reader.LocalName == "photo")
            {
                Photo photo = new Photo();
                ((IFlickrParsable)photo).Load(reader);
                if (String.IsNullOrEmpty(photo.UserId)) photo.UserId = OwnerId;
                Add(photo);
            }

            reader.Skip();
        }
Exemplo n.º 7
0
        public async void LoadInfo(FlickrNet.Photo photo, FlickrNet.ExifTagCollection exifInfo)
        {
            try
            {
                lbInfo.ItemsSource = exifInfo;

                if (ChangeViewState != null)
                {
                    ChangeViewState("Normal", null);
                }
            }
            catch {
            }
        }
Exemplo n.º 8
0
        internal static string GenerateFlickrHtml(FlickrNet.Photo selectedPhoto, string imageUrl, string cssClass, string border, string vSpace, string hSpace, string alignment, bool hyperLink, string userId)
        {
            StringBuilder imageTag  = new StringBuilder();
            string        imageHtml = string.Empty;

            imageTag.Append("<img ");                                                                     // begin tag
            imageTag.Append(string.Format("src=\"{0}\" ", HtmlServices.HtmlEncode(imageUrl)));
            imageTag.Append(string.Format("alt=\"{0}\" ", HtmlServices.HtmlEncode(selectedPhoto.Title))); // alt required for XHTML
            imageTag.Append(string.Format("border=\"{0}\" ", HtmlServices.HtmlEncode(border)));

            if (cssClass.Trim().Length > 0)
            {
                imageTag.Append(string.Format("class=\"{0}\" ", cssClass));
            }

            if (hSpace.Trim().Length > 0 && hSpace != "0")
            {
                imageTag.Append(string.Format("hspace=\"{0}\" ", hSpace));
            }

            if (vSpace.Trim().Length > 0 && vSpace != "0")
            {
                imageTag.Append(string.Format("vspace=\"{0}\" ", vSpace));
            }

            if (alignment.Trim().Length > 0 && alignment.ToLower() != "none")
            {
                imageTag.Append(string.Format("align=\"{0}\" ", alignment.ToLower()));
            }

            imageTag.Append("/>"); // end tag XHTML

            imageHtml = imageTag.ToString();

            if (hyperLink)
            {
                imageHtml = string.Format("<a href=\"{0}\" title=\"{2}\">{1}</a>", HtmlServices.HtmlEncode(selectedPhoto.WebUrl), imageHtml, HtmlServices.HtmlEncode(selectedPhoto.Title));
                // TODO: Fix this temp hack in FlicrkNet library -- photoset photos array in FlickrAPI does not include owner attribute
                // thus the serialization lacks the Userid attribute to properly input the WebUrl
                // THIS IS A TEMP HACK TO FIX PHOTOSET ONLY
                imageHtml = FixPhotosetWebUrl(imageHtml, userId);
            }

            return(imageHtml);
        }
Exemplo n.º 9
0
        internal static string GenerateFlickrHtml(Photo selectedPhoto, string imageUrl, string cssClass, string border, string vSpace, string hSpace, string alignment, bool hyperLink, string userId)
        {
            StringBuilder imageTag = new StringBuilder();

            imageTag.Append("<img "); // begin tag
            imageTag.Append(string.Format("src=\"{0}\" ", HtmlServices.HtmlEncode(imageUrl)));
            imageTag.Append(string.Format("alt=\"{0}\" ", HtmlServices.HtmlEncode(selectedPhoto.Title))); // alt required for XHTML
            imageTag.Append(string.Format("border=\"{0}\" ", HtmlServices.HtmlEncode(border)));

            if (cssClass.Trim().Length > 0)
            {
                imageTag.Append(string.Format("class=\"{0}\" ", cssClass));
            }

            if (hSpace.Trim().Length > 0 && hSpace != "0")
            {
                imageTag.Append(string.Format("hspace=\"{0}\" ", hSpace));
            }

            if (vSpace.Trim().Length > 0 && vSpace != "0")
            {
                imageTag.Append(string.Format("vspace=\"{0}\" ", vSpace));
            }

            if (alignment.Trim().Length > 0 && alignment.ToLower() != "none")
            {
                imageTag.Append(string.Format("align=\"{0}\" ", alignment.ToLower()));
            }

            imageTag.Append("/>"); // end tag XHTML

            string imageHtml = imageTag.ToString();

            if (hyperLink)
            {
                imageHtml = string.Format("<a href=\"{0}\" title=\"{2}\">{1}</a>", HtmlServices.HtmlEncode(selectedPhoto.WebUrl), imageHtml, HtmlServices.HtmlEncode(selectedPhoto.Title));
                // TODO: Fix this temp hack in FlicrkNet library -- photoset photos array in FlickrAPI does not include owner attribute
                // thus the serialization lacks the Userid attribute to properly input the WebUrl
                // THIS IS A TEMP HACK TO FIX PHOTOSET ONLY
                imageHtml = FixPhotosetWebUrl(imageHtml, userId);

            }

            return imageHtml;
        }
Exemplo n.º 10
0
 public Favourite ConvertPhotoToFavourite(FlickrNet.Photo photo, PhotoInfo photoInfo, string userAvatarUri)
 {
     return(new Favourite()
     {
         MediaLicense = getLicenseTypeName(photo.License),
         AggregateId = Guid.NewGuid().ToString(),
         MediaDescription = photo.Description == null ? string.Empty : photo.Description,
         MediaTitle = photo.Title == null ? string.Empty : photo.Title,
         MediaUrlSmall = photo.SmallUrl == null ? string.Empty : photo.SmallUrl,
         MediaUrlMedium = photo.MediumUrl == null ? string.Empty : photo.MediumUrl,
         MediaUserAvatar = photoInfo.OwnerBuddyIcon,
         MediaUserName = photoInfo.OwnerUserName,
         UserAvatar = userAvatarUri,
         UserName = FlickrPerson.UserName,
         UserRealName = FlickrPerson.RealName,
         TimeStamp = DateTime.Now.ToUniversalTime(),
         EntityId = photo.PhotoId
     });
 }
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "photos")
                UtilityMethods.CheckParsingException(reader);

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "total":
                        if (reader.Value == "")
                            Total = -1;
                        else
                            Total = int.Parse(reader.Value, CultureInfo.InvariantCulture);
                        break;
                    case "perpage":
                    case "per_page":
                        PerPage = int.Parse(reader.Value, CultureInfo.InvariantCulture);
                        break;
                    case "page":
                        Page = int.Parse(reader.Value, CultureInfo.InvariantCulture);
                        break;
                    case "pages":
                        Pages = int.Parse(reader.Value, CultureInfo.InvariantCulture);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

            while (reader.LocalName == "photo")
            {
                var p = new Photo();
                ((IFlickrParsable) p).Load(reader);
                if (!String.IsNullOrEmpty(p.PhotoId)) Add(p);
            }

            // Skip to next element (if any)
            reader.Skip();
        }
Exemplo n.º 12
0
        private void AddPhotoToList(FlickrNet.Flickr f, FlickrNet.Photo flickrPhoto, Photoset photoset)
        {
            // Filter by date, if filter option enabled and date taken is known.
            if (!Settings.FilterByDate ||
                flickrPhoto.DateTakenUnknown ||
                (flickrPhoto.DateTaken.Date >= Settings.StartDate && flickrPhoto.DateTaken.Date <= Settings.StopDate))
            {
                Photo photo = new Photo(flickrPhoto, photoset);
                PhotoList.Add(photo);

                // Get the photo info to get the raw tags, and put them into the photo object.
                // The raw tags are as uploaded or entered -- with spaces, punctuation, and
                // upper/lower case.
                FlickrNet.PhotoInfo info = f.PhotosGetInfo(flickrPhoto.PhotoId);
                photo.Tags.Clear();
                for (int i = 0; i < info.Tags.Count; i++)
                {
                    photo.Tags.Add(info.Tags[i].Raw);
                }
            }
        }
Exemplo n.º 13
0
        bool IsFileInSet(String filename, Photo[] photo_set)
        {
            DateTime date_taken = GetPicture(filename).getTimeTakenOriginal();
            String pic_basename = Path.GetFileNameWithoutExtension(filename).ToLower();

            foreach (Photo photo in photo_set)
            {
                String lower_title = photo.Title.ToLower();
                if ((date_taken == photo.DateTaken) && (photo.Title.ToLower() == pic_basename))
                    return true;
                else if (lower_title == pic_basename)
                {
                    Trace.WriteLine("Pictures with same titles but different timestamps: " + lower_title, "WARNING");
                    return true; //don't upload for safety
                }
                else if (date_taken == photo.DateTaken)
                    Trace.WriteLine("Picture with same time taken but seems to have different name: " + pic_basename + " - Flickr name: " + photo.Title);
            }

            return false;
        }
Exemplo n.º 14
0
		/// <summary>
		/// Removes a photo from the collection.
		/// </summary>
		/// <param name="photo">The <see cref="Photo"/> instance to remove from the collection.</param>
		public void Remove(Photo photo)
		{
			List.Remove(photo);
		}
Exemplo n.º 15
0
		/// <summary>
		/// Returns true if the collection contains the photo.
		/// </summary>
		/// <param name="photo">The <see cref="Photo"/> instance to try to find.</param>
		/// <returns>True of False, depending on if the <see cref="Photo"/> is found in the collection.</returns>
		public bool Contains(Photo photo)
		{
			return List.Contains(photo);
		}
Exemplo n.º 16
0
		/// <summary>
		/// Copies the elements of the collection to an array of <see cref="Photo"/>, starting at a
		/// particular index.
		/// </summary>
		/// <param name="array">The array to copy to.</param>
		/// <param name="index">The index in the collection to start copying from.</param>
		public void CopyTo(Photo[] array, int index)
		{
			List.CopyTo(array, index);
		}
Exemplo n.º 17
0
		/// <summary>
		/// Inserts a <see cref="Photo"/> into the collection at the given index.
		/// </summary>
		/// <param name="index">The index to insert the <see cref="Photo"/> into.
		/// Subsequent photos will be moved up.</param>
		/// <param name="photo">The <see cref="Photo"/> to insert.</param>
		public void Insert(int index, Photo photo)
		{
			List.Insert(index, photo);
		}
Exemplo n.º 18
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "collection")
                UtilityMethods.CheckParsingException(reader);

            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                    case "id":
                        CollectionId = reader.Value;
                        break;
                    case "child_count":
                        ChildCount = int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                        break;
                    case "datecreate":
                        DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    case "iconlarge":
                        IconLarge = reader.Value;
                        break;
                    case "iconsmall":
                        IconSmall = reader.Value;
                        break;
                    case "server":
                        Server = reader.Value;
                        break;
                    case "secret":
                        Secret = reader.Value;
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

            while (reader.LocalName != "collection")
            {
                switch (reader.Name)
                {
                    case "title":
                        Title = reader.ReadElementContentAsString();
                        break;
                    case "description":
                        Description = reader.ReadElementContentAsString();
                        break;
                    case "iconphotos":
                        reader.Read();

                        while (reader.LocalName == "photo")
                        {
                            var p = new Photo();
                            ((IFlickrParsable)p).Load(reader);

                            _iconPhotos.Add(p);
                        }
                        reader.Read();
                        return;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Skip();
        }
Exemplo n.º 19
0
        public async void PromotePhoto(Photo photo, PhotoInfo photoInfo, string userAvatarUri)
        {
            
            DownloadService.Current.DownloadCount++;

            //ADD TO PUBLIC AZURE PROMOTIONS
            AzureMobileService.Current.SavePromoteToCloud(new Promote()
            {
                MediaLicense = getLicenseTypeName(photo.License),
                AggregateId = Guid.NewGuid().ToString(),
                MediaDescription = photo.Description == null ? string.Empty : photo.Description,
                MediaTitle = photo.Title == null ? string.Empty : photo.Title,
                MediaUrlSmall = photo.SmallUrl == null ? string.Empty : photo.SmallUrl,
                MediaUrlMedium = photo.MediumUrl == null ? string.Empty : photo.MediumUrl,
                MediaUserAvatar = photoInfo.OwnerBuddyIcon,
                MediaUserName = photoInfo.OwnerUserName,
                UserAvatar = userAvatarUri,
                UserName = FlickrPerson.UserName,
                UserRealName = FlickrPerson.RealName,
                TimeStamp = DateTime.Now.ToUniversalTime(),
                EntityId = photo.PhotoId
            });

            //UPDATE UI THAT FAVOURITE HAS BEEN ADDED
            await _dispatcher.RunAsync(
                Windows.UI.Core.CoreDispatcherPriority.High,
                new Windows.UI.Core.DispatchedHandler(() =>
                {
                    DownloadService.Current.DownloadCount--;

                    if (ChangeState != null) ChangeState("PhotoPromoted", new CustomEventArgs() { Photo = photo });
                })
            );

        }
Exemplo n.º 20
0
		/// <summary>
		/// Gets the index of a photo in this collection.
		/// </summary>
		/// <param name="photo">The photo to find.</param>
		/// <returns>The index of the photo, -1 if it is not in the collection.</returns>
		public int IndexOf(Photo photo)
		{
			return List.IndexOf(photo);
		}
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "collection")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case "id":
                    CollectionId = reader.Value;
                    break;

                case "child_count":
                    ChildCount = int.Parse(reader.Value, CultureInfo.InvariantCulture);
                    break;

                case "datecreate":
                    DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "iconlarge":
                    IconLarge = reader.Value;
                    break;

                case "iconsmall":
                    IconSmall = reader.Value;
                    break;

                case "server":
                    Server = reader.Value;
                    break;

                case "secret":
                    Secret = reader.Value;
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            while (reader.LocalName != "collection")
            {
                switch (reader.Name)
                {
                case "title":
                    Title = reader.ReadElementContentAsString();
                    break;

                case "description":
                    Description = reader.ReadElementContentAsString();
                    break;

                case "iconphotos":
                    reader.Read();

                    while (reader.LocalName == "photo")
                    {
                        var p = new Photo();
                        ((IFlickrParsable)p).Load(reader);

                        iconPhotos.Add(p);
                    }
                    reader.Read();
                    return;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Skip();
        }
Exemplo n.º 22
0
 void IFlickrParsable.Load(XmlReader reader)
 {
     if (!(reader.LocalName != "photoset"))
     ;
       while (reader.MoveToNextAttribute())
       {
     switch (reader.LocalName)
     {
       case "id":
     this.PhotosetId = reader.Value;
     continue;
       case "primary":
     this.PrimaryPhotoId = reader.Value;
     continue;
       case "owner":
     this.OwnerId = reader.Value;
     continue;
       case "ownername":
     this.OwnerName = reader.Value;
     continue;
       case "page":
     this.Page = int.Parse(reader.Value, (IFormatProvider) NumberFormatInfo.InvariantInfo);
     continue;
       case "total":
     this.Total = int.Parse(reader.Value, (IFormatProvider) NumberFormatInfo.InvariantInfo);
     continue;
       case "pages":
     this.Pages = int.Parse(reader.Value, (IFormatProvider) NumberFormatInfo.InvariantInfo);
     continue;
       case "perpage":
       case "per_page":
     this.PerPage = int.Parse(reader.Value, (IFormatProvider) NumberFormatInfo.InvariantInfo);
     continue;
       case "title":
     this.Title = reader.Value;
     continue;
       default:
     continue;
     }
       }
       reader.Read();
       while (reader.LocalName == "photo")
       {
     Photo photo = new Photo();
     photo.Load(reader);
     if (string.IsNullOrEmpty(photo.UserId))
       photo.UserId = this.OwnerId;
     this.Add(photo);
       }
       reader.Skip();
 }
Exemplo n.º 23
0
		/// <summary>
		/// Creates a <see cref="PhotoCollection"/> from an array of <see cref="Photo"/> objects.
		/// </summary>
		/// <param name="photos">An array of <see cref="Photo"/> objects.</param>
		/// <returns>A new <see cref="PhotoCollection"/> containing all the objects from the array.</returns>
		public static PhotoCollection FromPhotoArray(Photo[] photos)
		{
			return (PhotoCollection)photos;
		}
Exemplo n.º 24
0
        public void GetPhotoComments(Photo photo)
        {
            DownloadService.Current.DownloadCount++;
            _flickr.PhotosCommentsGetListAsync(photo.PhotoId, async (pc) =>
            {
                DownloadService.Current.DownloadCount--;
                if (!pc.HasError)
                {
                    SelectedPhotoComments = pc.Result;

                    await _dispatcher.RunAsync(
                        Windows.UI.Core.CoreDispatcherPriority.High,
                        new Windows.UI.Core.DispatchedHandler(() =>
                        {
                            if (ChangeState != null) ChangeState("PhotoCommentsRetrieved", EventArgs.Empty);
                        })
                    );


                }
                else
                {
                    _raiseError(pc.ErrorMessage);
                }
            });
        }
Exemplo n.º 25
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "photoset")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                    PhotosetId = reader.Value;
                    break;

                case "url":
                    Url = reader.Value;
                    break;

                case "owner_id":
                case "owner":
                    OwnerId = reader.Value;
                    break;

                case "username":
                    OwnerName = reader.Value;
                    break;

                case "primary":
                    PrimaryPhotoId = reader.Value;
                    break;

                case "secret":
                    Secret = reader.Value;
                    break;

                case "farm":
                    Farm = reader.Value;
                    break;

                case "server":
                    Server = reader.Value;
                    break;

                case "total":
                    break;

                case "photos":
                case "count_photos":
                    NumberOfPhotos = reader.ReadContentAsInt();
                    break;

                case "videos":
                case "count_videos":
                    NumberOfVideos = reader.ReadContentAsInt();
                    break;

                case "needs_interstitial":
                    // Who knows what this is for.
                    break;

                case "visibility_can_see_set":
                    // Who knows what this is for.
                    break;

                case "date_create":
                    DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "date_update":
                    DateUpdated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "view_count":
                case "count_views":
                    ViewCount = reader.ReadContentAsInt();
                    break;

                case "comment_count":
                case "count_comments":
                    CommentCount = reader.ReadContentAsInt();
                    break;

                case "can_comment":
                    CanComment = reader.Value == "1";
                    break;

                case "coverphoto_server":
                case "coverphoto_farm":
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            PrimaryPhoto = new Photo
            {
                PhotoId = PrimaryPhotoId,
                Secret  = Secret,
                Server  = Server,
                Farm    = Farm
            };

            while (reader.LocalName != "photoset" && reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                case "title":
                    Title = reader.ReadElementContentAsString();
                    break;

                case "description":
                    Description = reader.ReadElementContentAsString();
                    break;

                case "primary_photo_extras":
                    ((IFlickrParsable)PrimaryPhoto).Load(reader);
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    reader.Skip();
                    break;
                }
            }

            reader.Read();
        }
Exemplo n.º 26
0
        public async void UnfavouritePhoto(Photo photo, PhotoInfo photoInfo, string userAvatarUri)
        {
            //if (ChangeState != null) ChangeState("PhotoFavourited", new CustomEventArgs() { Photo = photo });
            //return;
            DownloadService.Current.DownloadCount++;


             _flickr.FavoritesRemoveAsync(photo.PhotoId, async (nr) =>
            {
                
                DownloadService.Current.DownloadCount--;

                //UPDATE UI THAT FAVOURITE HAS BEEN REMOVED
                if (!nr.HasError)
                {
                    await _dispatcher.RunAsync(
                        Windows.UI.Core.CoreDispatcherPriority.High,
                        new Windows.UI.Core.DispatchedHandler(() =>
                        {
                            if (ChangeState != null) ChangeState("PhotoUnfavourited", new CustomEventArgs() { Photo = photo });
                        })
                    );
                }
                else
                {
                    await _dispatcher.RunAsync(
                        Windows.UI.Core.CoreDispatcherPriority.High,
                        new Windows.UI.Core.DispatchedHandler(() =>
                        {
                            _raiseError(nr.ErrorMessage);
                        })
                    );

                }

            });
        }
Exemplo n.º 27
0
		/// <summary>
		/// Adds a <see cref="Photo"/> to the collection.
		/// </summary>
		/// <param name="photo">The <see cref="Photo"/> instance to add to the collection.</param>
		/// <returns>The index that the photo was added at.</returns>
		public int Add(Photo photo)
		{
			return List.Add(photo);
		}
Exemplo n.º 28
0
        public string GetImageUrl(Photo p, ImageSize imgsize)
        {
            string url = null;

            switch (imgsize)
            {
                case ImageSize.Thumbnail:
                    url = p.ThumbnailUrl;
                    break;

                case ImageSize.Small:
                    url = p.SmallUrl;
                    break;

                case ImageSize.Medium:
                    url = p.MediumUrl;
                    break;

                case ImageSize.Large:
                    url = p.LargeUrl;
                    break;

                case ImageSize.Original:
                    url = p.OriginalUrl;
                    break;
            }

            return url;
        }
Exemplo n.º 29
0
		/// <summary>
		/// Adds an array of <see cref="Photo"/> instances to this collection.
		/// </summary>
		/// <param name="photos">An array of <see cref="Photo"/> instances.</param>
		public void AddRange(Photo[] photos)
		{
			foreach(Photo photo in photos)
				List.Add(photo);
		}
Exemplo n.º 30
0
        public void GetPhotoExif(Photo photo)
        {
            if (_GetPhotoExif_IsRunning) return;

            _GetPhotoExif_IsRunning = true;
            DownloadService.Current.DownloadCount++;

            _flickr.PhotosGetExifAsync(photo.PhotoId, async (pc) =>
            {
                _GetPhotoExif_IsRunning = false;
                DownloadService.Current.DownloadCount--;

                if (!pc.HasError)
                {
                    SelectedExifInfo = pc.Result;

                    await _dispatcher.RunAsync(
                        Windows.UI.Core.CoreDispatcherPriority.High,
                        new Windows.UI.Core.DispatchedHandler(() =>
                        {
                            if (ChangeState != null) ChangeState("PhotoExifRetrieved", EventArgs.Empty);
                        })
                    );
                }
                else
                {
                    await _dispatcher.RunAsync(
                        Windows.UI.Core.CoreDispatcherPriority.High,
                        new Windows.UI.Core.DispatchedHandler(() =>
                        {
                            _raiseError(pc.ErrorMessage);
                        })
                    );
                    
                }
            });
        }
Exemplo n.º 31
0
 void IFlickrParsable.Load(XmlReader reader)
 {
     if (!(reader.LocalName != "collection"))
     ;
       while (reader.MoveToNextAttribute())
       {
     switch (reader.Name)
     {
       case "id":
     this.CollectionId = reader.Value;
     continue;
       case "child_count":
     this.ChildCount = int.Parse(reader.Value, (IFormatProvider) CultureInfo.InvariantCulture);
     continue;
       case "datecreate":
     this.DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
     continue;
       case "iconlarge":
     this.IconLarge = reader.Value;
     continue;
       case "iconsmall":
     this.IconSmall = reader.Value;
     continue;
       case "server":
     this.Server = reader.Value;
     continue;
       case "secret":
     this.Secret = reader.Value;
     continue;
       default:
     continue;
     }
       }
       reader.Read();
       while (reader.LocalName != "collection")
       {
     switch (reader.Name)
     {
       case "title":
     this.Title = reader.ReadElementContentAsString();
     continue;
       case "description":
     this.Description = reader.ReadElementContentAsString();
     continue;
       case "iconphotos":
     reader.Read();
     while (reader.LocalName == "photo")
     {
       Photo photo = new Photo();
       photo.Load(reader);
       this.iconPhotos.Add(photo);
     }
     reader.Read();
     return;
       default:
     continue;
     }
       }
       reader.Skip();
 }
Exemplo n.º 32
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "photoset")
                UtilityMethods.CheckParsingException(reader);

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "id":
                        PhotosetId = reader.Value;
                        break;
                    case "url":
                        Url = reader.Value;
                        break;
                    case "owner_id":
                    case "owner":
                        OwnerId = reader.Value;
                        break;
                    case "username":
                        OwnerName = reader.Value;
                        break;
                    case "primary":
                        PrimaryPhotoId = reader.Value;
                        break;
                    case "secret":
                        Secret = reader.Value;
                        break;
                    case "farm":
                        Farm = reader.Value;
                        break;
                    case "server":
                        Server = reader.Value;
                        break;
                    case "total":
                        break;
                    case "photos":
                    case "count_photos":
                        NumberOfPhotos = reader.ReadContentAsInt();
                        break;
                    case "videos":
                    case "count_videos":
                        NumberOfVideos = reader.ReadContentAsInt();
                        break;
                    case "needs_interstitial":
                        // Who knows what this is for.
                        break;
                    case "visibility_can_see_set":
                        // Who knows what this is for.
                        break;
                    case "date_create":
                        DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    case "date_update":
                        DateUpdated = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    case "view_count":
                    case "count_views":
                        ViewCount = reader.ReadContentAsInt();
                        break;
                    case "comment_count":
                    case "count_comments":
                        CommentCount = reader.ReadContentAsInt();
                        break;
                    case "can_comment":
                        CanComment = reader.Value == "1";
                        break;
                    case "coverphoto_server":
                    case "coverphoto_farm":
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

            PrimaryPhoto = new Photo
            {
                PhotoId = PrimaryPhotoId,
                Secret = Secret,
                Server = Server,
                Farm = Farm
            };

            while (reader.LocalName != "photoset" && reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                    case "title":
                        Title = reader.ReadElementContentAsString();
                        break;
                    case "description":
                        Description = reader.ReadElementContentAsString();
                        break;
                    case "primary_photo_extras":
                        ((IFlickrParsable)PrimaryPhoto).Load(reader);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        reader.Skip();
                        break;
                }
            }

            reader.Read();
        }
Exemplo n.º 33
0
		internal static string UrlFormat(Photo p, string size, string format)
		{
			if( size == "_o" )
				return UrlFormat(photoUrl, p.Farm, p.Server, p.PhotoId, p.OriginalSecret, size, format);
			else
				return UrlFormat(photoUrl, p.Farm, p.Server, p.PhotoId, p.Secret, size, format);
		}
Exemplo n.º 34
0
        private bool IsLicensed(Photo photo)
        {
            var userId = photo.UserId;
            var optinUserIds = _userService.GetOptinUserIds();

            return CreativeCommonsLicenses.Contains(photo.License) || optinUserIds.Contains(userId);
        }
Exemplo n.º 35
0
        private static string GetImageDescription(Photo image)
        {
            try
            {
                initializeFlickr();

                PhotoInfo photoInfo = flickr.PhotosGetInfo(image.PhotoId);
                return photoInfo.Description;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return null;
        }
Exemplo n.º 36
0
 public FlickrMatch(string localImageFilePath, Photo flickrPhoto)
 {
     _localPhotoFilePath = localImageFilePath;
     _flickrPhoto = flickrPhoto;
 }
Exemplo n.º 37
0
 internal static string UrlFormat(Photo p, string size, string extension)
 {
     if (size == "_o" || size == "original")
         return UrlFormat(p.Farm, p.Server, p.PhotoId, p.OriginalSecret, size, extension);
     else
         return UrlFormat(p.Farm, p.Server, p.PhotoId, p.Secret, size, extension);
 }
Exemplo n.º 38
0
        public async void FavouritePhoto(Photo photo, PhotoInfo photoInfo, string userAvatarUri)
        {
            //if (ChangeState != null) ChangeState("PhotoFavourited", new CustomEventArgs() { Photo = photo });
            //return;
            DownloadService.Current.DownloadCount++;

            _flickr.FavoritesAddAsync(photo.PhotoId, async (nr) =>
            {
                
                DownloadService.Current.DownloadCount--;

                if (FlickrPerson != null) { 
                    //ADD TO PUBLIC AZURE FAVOURTES
                    AzureMobileService.Current.SaveFavouriteToCloud(ConvertPhotoToFavourite(photo, photoInfo, userAvatarUri));
                }

                //UPDATE UI THAT FAVOURITE HAS BEEN ADDED
                if (!nr.HasError)
                {
                    await _dispatcher.RunAsync(
                        Windows.UI.Core.CoreDispatcherPriority.High,
                        new Windows.UI.Core.DispatchedHandler(() =>
                        {
                            if (ChangeState != null) ChangeState("PhotoFavourited", new CustomEventArgs() { Photo = photo });
                        })
                    );
                }
                else
                {
                    await _dispatcher.RunAsync(
                        Windows.UI.Core.CoreDispatcherPriority.High,
                        new Windows.UI.Core.DispatchedHandler(() =>
                        {
                            _raiseError(nr.ErrorMessage);
                        })
                    );

                }
            });
        }