상속: IFlickrParsable
예제 #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 {
            }
        }
예제 #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]);
			}
		}
예제 #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();
 }
예제 #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);
        }
예제 #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]);
			}
		}
예제 #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();
        }
예제 #7
0
        public async void LoadInfo(FlickrNet.Photo photo, FlickrNet.ExifTagCollection exifInfo)
        {
            try
            {
                lbInfo.ItemsSource = exifInfo;

                if (ChangeViewState != null)
                {
                    ChangeViewState("Normal", null);
                }
            }
            catch {
            }
        }
예제 #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);
        }
예제 #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;
        }
예제 #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();
        }
예제 #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);
                }
            }
        }
예제 #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;
        }
예제 #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);
		}
예제 #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);
		}
예제 #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);
		}
예제 #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);
		}
예제 #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();
        }
예제 #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 });
                })
            );

        }
예제 #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();
        }
예제 #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();
 }
예제 #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;
		}
예제 #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);
                }
            });
        }
예제 #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();
        }
예제 #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);
                        })
                    );

                }

            });
        }
예제 #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);
		}
예제 #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;
        }
예제 #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);
		}
예제 #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);
                        })
                    );
                    
                }
            });
        }
예제 #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();
 }
예제 #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();
        }
예제 #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);
		}
예제 #34
0
        private bool IsLicensed(Photo photo)
        {
            var userId = photo.UserId;
            var optinUserIds = _userService.GetOptinUserIds();

            return CreativeCommonsLicenses.Contains(photo.License) || optinUserIds.Contains(userId);
        }
예제 #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;
        }
예제 #36
0
 public FlickrMatch(string localImageFilePath, Photo flickrPhoto)
 {
     _localPhotoFilePath = localImageFilePath;
     _flickrPhoto = flickrPhoto;
 }
예제 #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);
 }
예제 #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);
                        })
                    );

                }
            });
        }