public static ImageUploadManager UploadImage(ImageWallServiceClient client, ImageModel model, IEnumerable<string> tags, string author, double latitude, double longitude) { try { // Gets image buffer var buffer = ImageUploadHelper.GetBuffer(model.ImageStream); // Create hash for image string hash = ImageUploadHelper.GetHash(buffer); // Build image details var details = new ImageDetails() { Name = System.IO.Path.GetFileName(model.Name), Hash = hash, Tags = new ObservableCollection<string>(tags), UserId = author, Created = DateTime.Now, Latitude = latitude, Longitude = longitude, Size = buffer.Length, Extension = System.IO.Path.GetExtension(model.Name) }; // Begin upload with upload manager var manager = new ImageUploadManager(buffer, details); manager.BeginUploadAsync(); return manager; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); return null; } }
public void AssignModel(ImageModel model) { if (model.Picture != null) { var bitmap = new BitmapImage(); bitmap.SetSource(model.Picture.GetImage()); model.ImageStream = model.Picture.GetImage(); model.ImageSource = bitmap; } this.Model = model; }
public void AssignImageModel(ImageModel model) { this.viewModel.AssignModel(model); }
/// <summary> /// Loads image page that contains four rows and four columns and can contain up to 16 images /// </summary> /// <param name="isPopular">If this is set to true, page will be marked as popular</param> public void LoadNextPage(bool isPopular = false) { // Work around for known _bug in the media framework. Hits the static constructors // so the user does not need to go to the picture hub first. // ReSharper disable ReturnValueOfPureMethodIsNotUsed MediaPlayer.Queue.ToString(); // ReSharper restore ReturnValueOfPureMethodIsNotUsed var mediaLib = new MediaLibrary(); var models = new List<ImageModel>(); var pictures = mediaLib.Pictures .OrderByDescending(p => p.Date) .Skip(this.imagesLoaded) .Take(isPopular ? ImagesPerPagePopular : ImagesPerPage); // Go through all pictures foreach (var picture in pictures) { // Create image model var model = new ImageModel() { Name = picture.Name, Picture = picture }; // Create bitmap image and set source to thumbnail stream var bitmap = new BitmapImage(); bitmap.SetSource(picture.GetThumbnail()); model.ImageSource = bitmap; // Add mdoel to current list models.Add(model); } if (models.Count > 0) { // Increase loaded images number to match real count and add model to the pages list this.imagesLoaded += isPopular ? ImagesPerPagePopular : ImagesPerPage; var imagesPage = new ImagesPage(models, isPopular); imagesPage.OnImageTap += ImagesPageImageTap; this.Pages.Add(imagesPage); } }