Inheritance: MediaAttachment
Esempio n. 1
0
 /// Возращает URL самой большой фотографиии из существующих
 public static string GetUrlOfBigPhoto(VkNet.Model.Attachments.Photo photo)
 {
     if (photo == null)
         return null;
     if (photo.Photo2560 != null)
         return photo.Photo2560.AbsoluteUri;
     if (photo.Photo1280 != null)
         return photo.Photo1280.AbsoluteUri;
     if (photo.Photo807 != null)
         return photo.Photo807.AbsoluteUri;
     if (photo.Photo604 != null)
         return photo.Photo604.AbsoluteUri;
     if (photo.Photo130 != null)
         return photo.Photo130.AbsoluteUri;
     if (photo.Photo75 != null)
         return photo.Photo75.AbsoluteUri;
     if (photo.Sizes?.Count > 0)
     {
         var bigSize = photo.Sizes[0];
         for (int i = 0; i < photo.Sizes.Count; i++)
         {
             var photoSize = photo.Sizes[i];
             if (photoSize.Height > bigSize.Height && photoSize.Width > bigSize.Width)
                 bigSize = photoSize;
         }
         return bigSize.Src.AbsoluteUri;
     }
     return null;
 }
Esempio n. 2
0
        private static Uri getUrlOfBigPhoto(VkNet.Model.Attachments.Photo photo)
        {
            if (photo == null)
            {
                return(null);
            }
            if (photo.Photo2560 != null)
            {
                return(photo.Photo2560);
            }
            if (photo.Photo1280 != null)
            {
                return(photo.Photo1280);
            }
            if (photo.Photo807 != null)
            {
                return(photo.Photo807);
            }
            if (photo.Photo604 != null)
            {
                return(photo.Photo604);
            }
            if (photo.Photo130 != null)
            {
                return(photo.Photo130);
            }
            if (photo.Photo75 != null)
            {
                return(photo.Photo75);
            }
            if (photo.Sizes?.Count > 0)
            {
                var bigSize = photo.Sizes[0];
                for (int i = 0; i < photo.Sizes.Count; i++)
                {
                    var photoSize = photo.Sizes[i];
                    if (photoSize.Height > bigSize.Height && photoSize.Width > bigSize.Width)
                    {
                        bigSize = photoSize;
                    }
                }
                return(bigSize.Url);
            }

            return(null);
        }
Esempio n. 3
0
File: Photo.cs Progetto: Olegasdf/vk
 /// <summary>
 /// Разобрать из json.
 /// </summary>
 /// <param name="response">Ответ сервера.</param>
 /// <returns></returns>
 internal static Photo FromJson(VkResponse response)
 {
     var photo = new Photo
     {
         Id = response["pid"] ?? response["id"],
         AlbumId = response["album_id"] ?? response["aid"],
         OwnerId = response["owner_id"],
         Photo75 = response["photo_75"] ?? response["src_small"],
         Photo130 = response["photo_130"] ?? response["src"],
         Photo604 = response["photo_604"] ?? response["src_big"],
         Photo807 = response["photo_807"] ?? response["src_xbig"],
         Photo1280 = response["photo_1280"] ?? response["src_xxbig"],
         Photo2560 = response["photo_2560"] ?? response["src_xxxbig"],
         Width = response["width"],
         Height = response["height"],
         Text = response["text"],
         CreateTime = response["date"] ?? response["created"],
         UserId = Utilities.GetNullableLongId(response["user_id"]),
         PostId = Utilities.GetNullableLongId(response["post_id"]),
         AccessKey = response["access_key"],
         PlacerId = Utilities.GetNullableLongId(response["placer_id"]),
         TagCreated = response["tag_created"],
         TagId = response["tag_id"],
         Likes = response["likes"],
         Comments = response["comments"],
         CanComment = response["can_comment"],
         Tags = response["tags"],
         PhotoSrc = response["photo_src"],
         PhotoHash = response["photo_hash"],
         SmallPhotoSrc = response["src_small"],
         Latitude = response["lat"],
         Longitude = response["long"],
         Sizes = response["sizes"].ToReadOnlyCollectionOf<PhotoSize>(x => x)
     };
     return photo;
 }
Esempio n. 4
0
File: Photo.cs Progetto: justloot/vk
        internal static Photo FromJson(VkResponse response)
        {
            var photo = new Photo();

            photo.Id = response["id"];
            photo.AlbumId = response["album_id"];
            photo.OwnerId = response["owner_id"];
            photo.Photo75 = response["photo_75"];
            photo.Photo130 = response["photo_130"];
            photo.Photo604 = response["photo_604"];
            photo.Photo807 = response["photo_807"];
            photo.Photo1280 = response["photo_1280"];
            photo.Photo2560 = response["photo_2560"];
            photo.Width = response["width"];
            photo.Height = response["height"];
            photo.Text = response["text"];
            photo.CreateTime = response["date"];

            photo.UserId = Utilities.GetNullableLongId(response["user_id"]);
            photo.PostId = Utilities.GetNullableLongId(response["post_id"]);

            // из описания альбом с фотографиями
            photo.AccessKey = response["access_key"];

            return photo;
        }
Esempio n. 5
0
        internal static Photo FromJson(VkResponse response)
        {
            var photo = new Photo();

            photo.Id = response["id"];
            photo.AlbumId = response["album_id"] ?? response["aid"];
            photo.OwnerId = response["owner_id"];
            photo.Photo75 = response["photo_75"];
            photo.Photo130 = response["photo_130"];
            photo.Photo604 = response["photo_604"];
            photo.Photo807 = response["photo_807"];
            photo.Photo1280 = response["photo_1280"];
            photo.Photo2560 = response["photo_2560"];
            photo.Width = response["width"];
            photo.Height = response["height"];
            photo.Text = response["text"];
            photo.CreateTime = response["date"];

            photo.UserId = Utilities.GetNullableLongId(response["user_id"]);
            photo.PostId = Utilities.GetNullableLongId(response["post_id"]);

            // из описания альбом с фотографиями
            photo.AccessKey = response["access_key"];

            photo.PlacerId = Utilities.GetNullableLongId(response["placer_id"]);
            photo.TagCreated = response["tag_created"];
            photo.TagId = response["tag_id"];

            photo.Likes = response["likes"];
            photo.Comments = response["comments"];
            photo.CanComment = response["can_comment"];
            photo.Tags = response["tags"];

            photo.PhotoSrc = response["photo_src"];
            photo.PhotoHash = response["photo_hash"];

            photo.Latitude = response["lat"];
            photo.Longitude = response["long"];

            return photo;
        }