コード例 #1
0
        /// <summary>
        /// Default constructor that takes an instance of the album manager and the index of the selected album.
        /// </summary>
        /// <param name="index"></param>
        /// <param name="manager"></param>
        public SingleAlbumPage(int index, AlbumManager manager)
        {
            InitializeComponent();
            albumManager = manager;

            album = albumManager.GetAlbumAtIndex(index);

            AlbumNameTextBlock.Text = album.AlbumTitle;

            ListViewImages.ItemsSource = albumManager.GetAlbumAtIndex(index).MediaFiles;
        }
コード例 #2
0
        /// <summary>
        /// Method to edit the information of a single album from the "open" option in the context menu. It sends the chosen album to the edit window for editing.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEdit_onClick(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = sender as MenuItem;

            int             index           = ListViewAlbums.Items.IndexOf(menuItem.DataContext);
            NewEditDialogue newEditDialogue = new NewEditDialogue(albumManager.GetAlbumAtIndex(index));

            newEditDialogue.ShowDialog();
            if (newEditDialogue.DialogResult == true)
            {
                albumManager.GetAlbumAtIndex(index).AlbumTitle       = newEditDialogue.Album.AlbumTitle;
                albumManager.GetAlbumAtIndex(index).AlbumDescription = newEditDialogue.Album.AlbumDescription;

                ListViewAlbums.Items.Refresh(); //refresh GUI

                SerializationHelper.Serialize(albumManager);
            }
        }
コード例 #3
0
        /// <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.
                }
            }
        }