/// <summary> /// New Album Button Action. Opens the New Album Dialogue, receives the album title and description from the user /// Then uses them to create a new Album instance. Saves changes in data.bin with serialization. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NewAlbum_Button_Click(object sender, RoutedEventArgs e) { NewDialog dialog = new NewDialog(); dialog.ShowDialog(); if (dialog.DialogResult == true) { albumManager.AddNewAlbum(new Album(dialog.GetAlbumName(), dialog.GetAlbumDescription())); } }
/// <summary> /// Action method to edit the details of an album. Opens the New Album Dialog with the current title and description. Saves them to Album Manager and serializes them after validation. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditAlbum_Button_Click(object sender, RoutedEventArgs e) { if (AlbumsTv.SelectedItem != null) { int index = AlbumsTv.Items.IndexOf(AlbumsTv.SelectedItem); Album album = albumManager.GetAlbumAtIndex(index); NewDialog dialog = new NewDialog(album.AlbumTitle, album.AlbumDescription); dialog.ShowDialog(); if (dialog.DialogResult == true) { album.AlbumTitle = dialog.GetAlbumName(); album.AlbumDescription = dialog.GetAlbumDescription(); AlbumsTv.Items.Refresh(); //called because observablecollection will notify only when adding/deleting item from list, but not when changing an item's detail. } } }