public EditAlbumViewModel(Common.Database.Entities.Album album, IMetadataService metadataService, IDialogService dialogService, ICacheService cacheService) { this.Album = album; this.metadataService = metadataService; this.dialogService = dialogService; this.cacheService = cacheService; this.artwork = new MetadataArtworkValue(); this.LoadedCommand = new DelegateCommand(async() => await this.GetAlbumArtworkAsync()); this.ExportArtworkCommand = new DelegateCommand(async() => { if (HasArtwork) { await SaveFileUtils.SaveImageFileAsync("cover", this.Artwork.Value); } }); this.ChangeArtworkCommand = new DelegateCommand(async() => { if (!await OpenFileUtils.OpenImageFileAsync(new Action <byte[]>(this.UpdateArtwork))) { this.dialogService.ShowNotification(0xe711, 16, ResourceUtils.GetString("Language_Error"), ResourceUtils.GetString("Language_Error_Changing_Image"), ResourceUtils.GetString("Language_Ok"), true, ResourceUtils.GetString("Language_Log_File")); } }); this.RemoveArtworkCommand = new DelegateCommand(() => this.UpdateArtwork(null)); this.DownloadArtworkCommand = new DelegateCommand(() => this.DownloadArtworkAsync(), () => this.album.AlbumArtist != Defaults.UnknownArtistText && this.Album.AlbumTitle != Defaults.UnknownAlbumText); }
private async Task ExportArtworkAsync() { if (this.HasArtwork) { await SaveFileUtils.SaveImageFileAsync("cover", this.Artwork.Value); } }
public EditTrackViewModel(IList <string> paths, IMetadataService metadataService, IDialogService dialogService) { this.multipleValuesText = "<" + ResourceUtils.GetString("Language_Multiple_Values") + ">"; this.artists = new MetadataValue(); this.title = new MetadataValue(); this.album = new MetadataValue(); this.albumArtists = new MetadataValue(); this.year = new MetadataValue(); this.trackNumber = new MetadataValue(); this.trackCount = new MetadataValue(); this.discNumber = new MetadataValue(); this.discCount = new MetadataValue(); this.genres = new MetadataValue(); this.grouping = new MetadataValue(); this.comment = new MetadataValue(); this.lyrics = new MetadataValue(); this.artwork = new MetadataArtworkValue(); this.paths = paths; this.metadataService = metadataService; this.dialogService = dialogService; this.HasMultipleArtwork = false; this.UpdateAlbumArtwork = false; this.LoadedCommand = new DelegateCommand(async() => await this.GetFilesMetadataAsync()); this.NavigateCommand = new DelegateCommand <string>((index) => Navigate(index)); this.ExportArtworkCommand = new DelegateCommand(async() => { if (HasArtwork) { await SaveFileUtils.SaveImageFileAsync("cover", this.Artwork.Value); } }); this.ChangeArtworkCommand = new DelegateCommand(async() => { if (!await OpenFileUtils.OpenImageFileAsync(new Action <byte[]>(this.UpdateArtwork))) { this.dialogService.ShowNotification( 0xe711, 16, ResourceUtils.GetString("Language_Error"), ResourceUtils.GetString("Language_Error_Changing_Image"), ResourceUtils.GetString("Language_Ok"), true, ResourceUtils.GetString("Language_Log_File")); } }); this.RemoveArtworkCommand = new DelegateCommand(() => this.UpdateArtwork(null)); this.Navigate("1"); // Make sure something is displayed when the screen is shown }