internal static void AddAlbum(string documenPath, AlbumViewModel album) { var root = XDocument.Load(documenPath).Root; root.Add(new XElement("album", new XElement("name", album.Name), new XElement("images", GetImages(album)))); root.Document.Save(documenPath); }
/// <summary> /// Gets the images. /// </summary> /// <param name="album">The album.</param> /// <returns></returns> private static object[] GetImages(AlbumViewModel album) { var images = new List<XElement>(); foreach (var image in album.Images) { images.Add(new XElement("image", new XElement("title", image.Title), new XElement("source", image.ImageSource))); } return images.ToArray(); }
/// <summary> /// Handles the add image command. /// </summary> /// <param name="obj">The obj.</param> private void HandleAddImageCommand(object obj) { if (this.newAlbum == null) { this.newAlbum = new AlbumViewModel(); } IList<ImageViewModel> currentImmages = new List<ImageViewModel>(); foreach (var image in this.NewAlbum.Images) { currentImmages.Add(image); } currentImmages.Add(this.NewImage); this.NewAlbum.Images = currentImmages; this.NewImage = new ImageViewModel(); this.OnPropertyChanged("NewAlbum"); }