/// <summary>
        /// Constructeur prenant en entree un fichier xml contenant les pistes stockes
        /// </summary>
        /// <param name="file"></param>
        public LocalPlaylist(string file)
        {
            LocalPlaylist playList = Read(file);

            Name         = playList.Name;
            Tracks       = playList.Tracks;
            CurrentIndex = 0;
        }
        private void OnClickCreatePlaylist(object sender, RoutedEventArgs e)
        {
            LocalPlaylist playlist = new LocalPlaylist()
            {
                Name = m_playListTextBox.Text
            };

            playlist.Save(System.IO.Path.Combine(PLAYLISTS_DIRECTORY, playlist.Name + ".xml"));
            Playlists.Add(playlist.Name);
        }
        /// <summary>
        /// permet de lire un  fichier xml contenant des pistes stockes
        /// </summary>
        /// <param name="file"></param>
        /// <returns>LocalPlaylist</returns>
        public static LocalPlaylist Read(string file)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(LocalPlaylist));
            LocalPlaylist playList   = new LocalPlaylist();

            using (StreamReader reader = new StreamReader(file))
            {
                playList = (LocalPlaylist)serializer.Deserialize(reader);
            }
            return(playList);
        }
        private void OnPlayPlaylist(object sender, RoutedEventArgs e)
        {
            Button    play      = sender as Button;
            TextBlock textBlock = VisualTreeHelper.GetChild(VisualTreeHelper.GetParent(play), 1) as TextBlock;
            string    name      = textBlock?.Text;

            if (name != null)
            {
                CurrentPlaylist = new LocalPlaylist(System.IO.Path.Combine(PLAYLISTS_DIRECTORY, name + ".xml"));
                PlayNextTrackInCurrentPlaylist();
            }
        }
 private void OnClickAddToPlaylist(object sender, RoutedEventArgs e)
 {
     if (CurrentTrack != null)
     {
         string        file     = System.IO.Path.Combine(PLAYLISTS_DIRECTORY, (string)m_playlistsComboBox.SelectedItem + ".xml");
         LocalPlaylist playlist = new LocalPlaylist(file);
         bool          added    = playlist.Add(CurrentTrack);
         playlist.Save(file);
         if (added)
         {
             MessageBox.Show("Track added");
         }
         else
         {
             MessageBox.Show("Track exists already");
         }
     }
 }