Beispiel #1
0
        /// <summary>
        /// Compare values to the sort method
        /// </summary>
        /// <param name="option">ID for each type of sort</param>
        /// <param name="a">A song</param>
        /// <param name="b">Other song</param>
        /// <returns></returns>
        private int Compare(string option, SongsProperties a, SongsProperties b)
        {
            switch (option)
            {
            case "13":    //parametros para ascendente por nombre
                return(string.Compare(a.nameSong, b.nameSong));

            case "23":    //parametros para descendente por nombre
                return(string.Compare(b.nameSong, a.nameSong));

            case "14":     //parámetros ascendentes por duración
                return(string.Compare(a.duration, b.duration));

            case "24":    //parámetros descendentes por duración
                return(string.Compare(b.duration, a.duration));

            default:
                return(-1);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Method to add songs to a playlist
        /// </summary>
        /// <param name="fileRoute">Song's path </param>
        /// <param name="actualList">Actual playlist</param>
        private void AddToList(string fileRoute, Playlists actualList)
        {
            SongsProperties newSong;
            string          filename = "", duration = "", songTitle = "", artist = "";

            try
            {
                TagLib.File Mp3file = TagLib.File.Create(fileRoute);
                filename  = Mp3file.Name;
                duration  = Mp3file.Properties.Duration.ToString();
                songTitle = Mp3file.Tag.Title;
                artist    = Mp3file.Tag.FirstAlbumArtist;
                newSong   = new SongsProperties(songTitle, artist, duration, filename);
                actualList.playlist.Add(newSong);
                actualList.searching.Add(songTitle.ToLower(), newSong);
                actualList.routes.Add(fileRoute);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }