Example #1
0
        private void openFileMenu_Click(object sender, EventArgs e)
        {
            OpenFileDialog          openFileDia       = frmMainOpenFile;
            List <string>           filePaths         = new List <string>();
            List <SmallClasses.MP3> tempSelectedFiles = new List <SmallClasses.MP3>();
            bool artistInFile = false;

            if (Program.pcName == "DESKTOP-5M1CJVH")
            {
                //E:\\TestAlbum
                //openFileDia.InitialDirectory = "D:\\";
                openFileDia.InitialDirectory = "E:\\TestAlbum";
            }
            else
            {
                //openFileDia.InitialDirectory = "D:\\Downloads\\MP3\\TestAlbum";
                openFileDia.InitialDirectory = "D:\\Downloads\\MP3";
            }
            openFileDia.Filter   = "(*.mp3)|*.mp3";
            openFileDia.FileName = "";
            openFileDia.ShowDialog();
            foreach (string individualPaths in openFileDia.FileNames)
            {
                filePaths.Add(individualPaths);
            }
            if (filePaths.Count > 0 && !string.IsNullOrEmpty(filePaths[0]))
            {
                tempSelectedFiles = digestFilePaths(filePaths, true);
                if (tempSelectedFiles == null)
                {
                    artistInFile = false;
                }
                else
                {
                    artistInFile = true;
                }
                if (artistInFile)
                {
                    frmChild newChild = new frmChild();
                    SmallClasses.SortTracks sorting = new SmallClasses.SortTracks();
                    setUpFrmChild(newChild, tempSelectedFiles, sorting);
                }
                else
                {
                    MessageBox.Show("Create new artist...");
                }
            }
        }
Example #2
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();
        }