MediaEditor/MainWindow.xaml.cs
/// <summary>
/// Update the selected media info as user wish
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
Update the selected media info as user wish
Update the selected media info as user wish
private void updateButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                foreach (var item in FileList.SelectedItems)
                {
                    var mediaItem = item as MediaInfo;
                    var path = mediaItem.Path;
                    var tFile = TagLib.File.Create(path);
                    var artistName = tFile.Tag.Performers;
                    var genre = tFile.Tag.Genres;
                    var title = tFile.Tag.Title;
                    var album = tFile.Tag.Album;
                    var newArtistName = artistTextBox.Text;
                    var newGenre = genreTextBox.Text;
                    var newTitle = titleTextBox.Text;
                    var newAlbum = albumTextBox.Text;
                    if (artistTextBox.Text == "{ALBUM}")
                    {
                        newArtistName = album;
                    }
                    if (albumTextBox.Text == "{ARTIST}")
                    {
                        newAlbum = artistName.First();
                    }
                    if (albumTextBox.Text == "{TITLE}")
                    {
                        newAlbum = title;
                    }
                    if (newArtistName != null && newArtistName != "")
                    {
                        var tempList = new List<string>() { newArtistName };
                        tFile.Tag.Performers = tempList.ToArray();
                    }
                    if (newGenre != null && newGenre != "")
                    {
                        var tempList2 = new List<string>() { newGenre };
                        tFile.Tag.Genres = tempList2.ToArray();
                    }
                    if (newAlbum != null && newAlbum != "")
                        tFile.Tag.Album = newAlbum;
                    if (newTitle != null && newTitle != "")
                        tFile.Tag.Title = newTitle;
                    tFile.Save();
                }
                FileList.Items.Clear();
                updateTheList(selectedFiles);
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("There is no selected media file in the list", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("There is no selected media file in the list", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
private void updateButton_Click ( object sender , RoutedEventArgs e ) { try { foreach ( var item in FileList . SelectedItems ) { var mediaItem = item as MediaInfo ; var path = mediaItem . Path ; var tFile = TagLib . File . Create ( path ) ; var artistName = tFile . Tag . Performers ; var genre = tFile . Tag . Genres ; var title = tFile . Tag . Title ; var album = tFile . Tag . Album ; var newArtistName = artistTextBox . Text ; var newGenre = genreTextBox . Text ; var newTitle = titleTextBox . Text ; var newAlbum = albumTextBox . Text ; if ( artistTextBox . Text == " " ) { newArtistName = album ; } if ( albumTextBox . Text == " " ) { newAlbum = artistName . First ( ) ; } if ( albumTextBox . Text == " " ) { newAlbum = title ; } if ( newArtistName != null && newArtistName != " " ) { var tempList = new List < string > ( ) { newArtistName } ; tFile . Tag . Performers = tempList . ToArray ( ) ; } if ( newGenre != null && newGenre != " " ) { var tempList2 = new List < string > ( ) { newGenre } ; tFile . Tag . Genres = tempList2 . ToArray ( ) ; } if ( newAlbum != null && newAlbum != " " ) tFile . Tag . Album = newAlbum ; if ( newTitle != null && newTitle != " " ) tFile . Tag . Title = newTitle ; tFile . Save ( ) ; } FileList . Items . Clear ( ) ; updateTheList ( selectedFiles ) ; } catch ( NullReferenceException ) { MessageBox . Show ( " " , " " , MessageBoxButtons . OK , MessageBoxIcon . Error ) ; } catch ( ArgumentNullException ) { MessageBox . Show ( " " , " " , MessageBoxButtons . OK , MessageBoxIcon . Error ) ; } }
Update the selected media info as user wish
Update the selected media info as user wish
// Old infos of medias
sender
object
None
e
RoutedEventArgs
None