Example #1
0
        public async Task <PhotoViewModel> AddPhoto(PhotoViewModel photo)
        {
            PhotoViewModel newPhoto = await AddPhoto(photo.ImagePath);

            newPhoto.SetAllPropertiesExceptForKeys(photo);
            return(newPhoto);
        }
Example #2
0
 // Update all properties except for Keys
 internal void SetAllPropertiesExceptForKeys(PhotoViewModel photo)
 {
     StartBatchUpdate();
     {
         Title        = photo.Title;
         Description  = photo.Description;
         Location     = photo.Location;
         Photographer = photo.Photographer;
         CaptureDate  = photo.CaptureDate;
         _characters.Clear();
         photo._characters.ToList().ForEach(c => AddNamedCharacter(c.Name));
     }
     EndBatchUpdate();
 }
Example #3
0
        public async Task <PhotoViewModel> AddPhoto(StorageFile imageFile)
        {
            if (!imageFile.ContentType.Contains("image"))
            {
                throw new ArgumentException("Input file is not an image");
            }

            Photo photo = null;

            try
            {
                photo = await Model.AddPhoto(imageFile);
            }
            catch (DuplicateObjectException)
            {
                var result = await Utils.ShowContentDialog(
                    "Add Photo",
                    $"Image {imageFile.Name} already exists in album.\n" +
                    "What would you like to do?",
                    "Override", "Make a copy", "Cancel");

                switch (result)
                {
                case CustomContentDialogResult.Primary:
                    photo = await Model.AddPhoto(imageFile, NameCollisionOption.ReplaceExisting);

                    break;

                case CustomContentDialogResult.Secondary:
                    photo = await Model.AddPhoto(imageFile, NameCollisionOption.GenerateUniqueName);

                    break;

                default:
                    return(null);
                }
            }

            var newPhoto = new PhotoViewModel(photo);

            SubscribeToPhotoEvents(newPhoto);

            _photos.Add(newPhoto);

            return(newPhoto);
        }
Example #4
0
 private void UnsubscribeFromPhotoEvents(PhotoViewModel photo)
 {
     photo.PropertyChanging -= Photo_PropertyChanging;
     photo.PropertyChanged  -= Photo_PropertyChanged;
 }
Example #5
0
 private void SubscribeToPhotoEvents(PhotoViewModel photo)
 {
     photo.PropertyChanging += Photo_PropertyChanging;
     photo.PropertyChanged  += Photo_PropertyChanged;
 }
Example #6
0
 internal void DeletePhoto(PhotoViewModel photo)
 {
     Model.DeletePhoto(photo.Model);
     UnsubscribeFromPhotoEvents(photo);
     _photos.Remove(photo);
 }
Example #7
0
        public async Task MovePhoto(PhotoViewModel photo, AlbumViewModel targetAlbum)
        {
            await targetAlbum.AddPhoto(photo);

            DeletePhoto(photo);
        }