示例#1
0
        public void setUpFrmChild(frmChild newChild, List <SmallClasses.MP3> tempSelectedFiles, SmallClasses.SortTracks sorting)
        {
            int    rowCount    = -1;
            string tempArtists = "";

            newChild.trvOutput.BeginUpdate();
            newChild.trvOutput.Nodes.Clear();

            tempSelectedFiles.Sort(sorting);
            var groupByAlbum = tempSelectedFiles.GroupBy(selectedFile => selectedFile.Album);

            rowCount = -1;
            string tempAlbum    = "";
            int    albumCounter = -1;

            foreach (var individualAlbum in groupByAlbum)
            {
                List <SmallClasses.MP3> individualAlbumTracks = new List <SmallClasses.MP3>();
                if (string.IsNullOrEmpty(individualAlbum.Key))
                {
                    tempAlbum = "Unknown Album";
                }
                else
                {
                    tempAlbum = individualAlbum.Key;
                }
                albumCounter++;
                newChild.trvOutput.Nodes.Add(new TreeNode(tempAlbum));

                foreach (var tempFile in individualAlbum)
                {
                    rowCount++;
                    var tempMP3 = new SmallClasses.MP3()
                    {
                        OriginalRow = rowCount,
                        FilePath    = tempFile.FilePath,
                        FileName    = tempFile.FileName,
                        TrackNumber = tempFile.TrackNumber,
                        SongTitle   = tempFile.SongTitle,
                        Album       = tempAlbum,
                        Artists     = tempFile.Artists
                    };
                    individualAlbumTracks.Add(tempMP3);
                    Program.openTracks.Add(tempMP3);
                    if (string.IsNullOrEmpty(tempFile.Artists))
                    {
                        tempArtists = "Unknown Artist";
                    }
                    else
                    {
                        tempArtists = tempFile.Artists;
                    }
                    newChild.trvOutput.Nodes[albumCounter].Nodes.Add(new TreeNode(tempMP3.TracksToString()));
                }
                Program.openChildren.Add(newChild);
                var tempAlbumByArtist = new SmallClasses.AlbumsByArtist()
                {
                    artist = tempArtists,
                    album  = tempAlbum
                };
                Program.albumsByArtists.Add(tempAlbumByArtist);
            }

            newChild.trvOutput.EndUpdate();
            newChild.MdiParent = this;
            newChild._frmMain  = this;
            newChild.Text      = tempArtists;
            Program.openChildren.Add(newChild);
            newChild.Show();
        }
示例#2
0
        public static List <SmallClasses.MP3> digestFilePaths(List <string> filePaths, bool checkArtist)
        {
            List <SmallClasses.MP3> tempSelectedFiles = new List <SmallClasses.MP3>();
            string tempArtists  = "";
            bool   artistInFile = false;

            int rowCount = -1;

            foreach (string individualPaths in filePaths)
            {
                var      tempTagLibFile = TagLib.File.Create(individualPaths);
                string[] splitPaths     = individualPaths.Split('\\');
                int      count          = splitPaths.Length;
                string   tempFileName   = splitPaths[count - 1];
                string   tempNameOfFile = tempFileName.Split('.')[0];
                int      artistCount    = tempTagLibFile.Tag.Performers.Length;
                tempArtists = "";
                for (int counter = 0; counter < artistCount; counter++)
                {
                    if (counter + 1 != artistCount)
                    {
                        tempArtists += tempTagLibFile.Tag.Performers[counter] + ", ";
                    }
                    else
                    {
                        tempArtists += tempTagLibFile.Tag.Performers[counter];
                    }
                }
                if (checkArtist)
                {
                    if (string.IsNullOrEmpty(tempArtists))
                    {
                        artistInFile = false;
                        break;
                    }
                    else
                    {
                        artistInFile = true;
                    }
                }
                rowCount++;
                var tempMP3 = new SmallClasses.MP3()
                {
                    OriginalRow = rowCount,
                    FilePath    = individualPaths,
                    FileName    = tempNameOfFile,
                    TrackNumber = Convert.ToInt16(tempTagLibFile.Tag.Track),
                    SongTitle   = tempTagLibFile.Tag.Title,
                    Album       = tempTagLibFile.Tag.Album,
                    Artists     = tempArtists
                };
                tempSelectedFiles.Add(tempMP3);
                if (!Program.openArtists.Contains(tempArtists))
                {
                    Program.openArtists.Add(tempArtists);
                }
            }
            if (checkArtist)
            {
                if (artistInFile)
                {
                    return(tempSelectedFiles);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(tempSelectedFiles);
            }
        }