public void LoadMyImages(string response) { MyImagesContainer.Children.Clear(); JArray responseImages = JArray.Parse(response); for (int i = 0; i < responseImages.Count; i++) { dynamic data = JObject.Parse(responseImages[i].ToString()); Image image = new Image { id = data["id"], ownerId = data["ownerId"], title = data["title"], protectionLevel = data["protectionLevel"], password = data["password"], thumbnailUrl = ServerService.instance.isOffline() ? data["thumbnailUrl"] : Settings.URL_TO_GALLERY_IMAGES + data["id"] + ".png", fullImageUrl = ServerService.instance.isOffline() ? data["thumbnailUrl"] : Settings.URL_TO_GALLERY_IMAGES + data["id"] + ".png", authorName = data["authorName"] }; GalleryCard galleryCard = new GalleryCard(image); galleryCard.ViewButtonClicked += ViewButton_Click; MyImagesContainer.Children.Add(galleryCard); } }
public void LoadPublicImages(IRestResponse response) { if (response.StatusCode == HttpStatusCode.OK) { PublicImagesContainer.Children.Clear(); JArray responseImages = JArray.Parse(response.Content); for (int i = 0; i < responseImages.Count; i++) { dynamic data = JObject.Parse(responseImages[i].ToString()); Image image = new Image { id = data["id"], ownerId = data["ownerId"], title = data["title"], protectionLevel = data["protectionLevel"], password = data["password"], thumbnailUrl = Settings.URL_TO_GALLERY_IMAGES + data["id"] + ".png", fullImageUrl = Settings.URL_TO_GALLERY_IMAGES + data["id"] + ".png", authorName = data["authorName"] }; GalleryCard galleryCard = new GalleryCard(image); galleryCard.ViewButtonClicked += ViewButton_Click; PublicImagesContainer.Children.Add(galleryCard); } } else { MessageBox.Show("Could not load the images", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void CreateImageClick(object sender, RoutedEventArgs e) { string protectionLevel; if ((bool)PrivateProtectionLevel.IsChecked) { protectionLevel = "private"; } else { if (ImagePassword.Password.Length > 0) { protectionLevel = "protected"; } else { protectionLevel = "public"; } } Image newImage = new Image { title = ImageTitle.Text, ownerId = ServerService.instance.isOffline() ? null : ServerService.instance.user.id, id = ServerService.instance.isOffline() ? Guid.NewGuid().ToString() : null, password = ImagePassword.Password, protectionLevel = protectionLevel }; ImageDao.Post(newImage); }