Exemplo n.º 1
0
        public static ObservableCollection <UnsplashImage> ParseListFromJson(string json)
        {
            var list  = new ObservableCollection <UnsplashImage>();
            var array = JsonArray.Parse(json);

            foreach (var item in array)
            {
                var image = new UnsplashImage();
                image.ParseObjectFromJson(item.ToString());
                list.Add(image);
            }
            return(list);
        }
Exemplo n.º 2
0
        private static UnsplashImage ParseObjectFromJson(string json)
        {
            var obj             = JsonObject.Parse(json);
            var urls            = JsonParser.GetJsonObjFromJsonObj(obj, "urls");
            var smallImageUrl   = JsonParser.GetStringFromJsonObj(urls, "small");
            var fullImageUrl    = JsonParser.GetStringFromJsonObj(urls, "full");
            var regularImageUrl = JsonParser.GetStringFromJsonObj(urls, "regular");
            var thumbImageUrl   = JsonParser.GetStringFromJsonObj(urls, "thumb");
            var rawImageUrl     = JsonParser.GetStringFromJsonObj(urls, "raw");
            var color           = JsonParser.GetStringFromJsonObj(obj, "color");
            var width           = JsonParser.GetNumberFromJsonObj(obj, "width");
            var height          = JsonParser.GetNumberFromJsonObj(obj, "height");
            var userObj         = JsonParser.GetJsonObjFromJsonObj(obj, "user");
            var userName        = JsonParser.GetStringFromJsonObj(userObj, "name");
            var id    = JsonParser.GetStringFromJsonObj(obj, "id");
            var likes = JsonParser.GetNumberFromJsonObj(obj, "likes");
            var time  = JsonParser.GetStringFromJsonObj(obj, "created_at");

            var img = new UnsplashImage();

            img.SmallImageUrl   = smallImageUrl;
            img.FullImageUrl    = fullImageUrl;
            img.RegularImageUrl = regularImageUrl;
            img.ThumbImageUrl   = thumbImageUrl;
            img.RawImageUrl     = rawImageUrl;
            img.ColorValue      = color;
            img.Width           = width;
            img.Height          = height;
            img.Owner           = new UnsplashUser()
            {
                Name = userName
            };
            img.ID         = id;
            img.Likes      = (int)likes;
            img.CreateTime = DateTime.Parse(time);

            return(img);
        }
Exemplo n.º 3
0
 public ImageItem(UnsplashImage image)
 {
     Image        = image;
     BitmapSource = new CachedBitmapSource();
 }
Exemplo n.º 4
0
 public ImageItem(UnsplashImage image)
 {
     Image           = image;
     ListImageBitmap = new CachedBitmapSource();
     LargeBitmap     = new CachedBitmapSource();
 }