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(); }
private void btnSubmit_Click(object sender, EventArgs e) { //frmChild frmChildNewAA = new frmChild(); //frmChildNewAA.MdiParent = _frmMain; //if (!string.IsNullOrEmpty(txtArtist.Text) && !string.IsNullOrEmpty(txtAlbum.Text)) //{ // frmChildNewAA.Text = txtArtist.Text + " - " + txtAlbum.Text; // frmChildNewAA.Show(); // //Program.openChildren.Add(frmChildNewAA); // if (!Program.openArtists.Contains(txtArtist.Text)) // { // Program.openArtists.Add(txtArtist.Text); // } // Program.openAlbums.Add(txtAlbum.Text); // this.Close(); // Program.openChildren = new frmChild[_frmMain.MdiChildren.Count()]; // Program.openChildren = _frmMain.MdiChildren.ToArray(); //} //else if (!string.IsNullOrEmpty(txtArtist.Text) && string.IsNullOrEmpty(txtAlbum.Text)) //{ // frmChildNewAA.Text = txtArtist.Text + " - " + "Unknown Album"; // frmChildNewAA.Show(); // //Program.openChildren.Add(frmChildNewAA); // Program.openArtists.Add(txtArtist.Text); // this.Close(); // Program.openChildren = new frmChild[_frmMain.MdiChildren.Count()]; // Program.openChildren = _frmMain.MdiChildren.ToArray(); //} //else //{ // MessageBox.Show("Please enter an artist"); //} bool albumArtistExist = false; if (!string.IsNullOrEmpty(txtArtist.Text)) { if (string.IsNullOrEmpty(txtAlbum.Text)) { txtAlbum.Text = "Unknown Album"; } if (!Program.openArtists.Contains(txtArtist.Text)) { Program.openArtists.Add(txtArtist.Text); frmChild newChild = new frmChild { Text = txtArtist.Text }; newChild.trvOutput.BeginUpdate(); newChild.trvOutput.Nodes.Add(txtAlbum.Text); newChild.trvOutput.EndUpdate(); newChild.MdiParent = _frmMain; newChild._frmMain = _frmMain; newChild.Show(); } else if (Program.openArtists.Contains(txtArtist.Text)) { foreach (SmallClasses.AlbumsByArtist tempAlbumArtist in Program.albumsByArtists) { if (tempAlbumArtist.album == txtAlbum.Text && tempAlbumArtist.artist == txtArtist.Text) { MessageBox.Show("Artist and album combo already exists"); albumArtistExist = true; break; } else { albumArtistExist = false; } } if (!albumArtistExist) { //MessageBox.Show("New album from artist detected"); frmChild currentArtist = new frmChild(); foreach (frmChild currentChild in Program.openChildren) { if (currentChild.Text == txtArtist.Text) { currentArtist = currentChild; break; } } //currentArtist.Focus(); //var currentNodes = currentArtist.trvOutput.Nodes; currentArtist.trvOutput.BeginUpdate(); currentArtist.trvOutput.Nodes.Add(txtAlbum.Text); currentArtist.trvOutput.EndUpdate(); } } this.Close(); //frmChildNewAA.Text = txtArtist.Text + " - " + txtAlbum.Text; //frmChildNewAA.Show(); //Program.openChildren.Add(frmChildNewAA); //Program.openAlbums.Add(txtAlbum.Text); //Program.openChildren = new frmChild[_frmMain.MdiChildren.Count()]; //Program.openChildren = _frmMain.MdiChildren.ToArray(); } //else if (!string.IsNullOrEmpty(txtArtist.Text) && string.IsNullOrEmpty(txtAlbum.Text)) //{ // txtAlbum.Text = "Unknown Album"; // if (!Program.openArtists.Contains(txtArtist.Text)) // { // Program.openArtists.Add(txtArtist.Text); // frmChild newChild = new frmChild(); // newChild.Text = txtArtist.Text; // newChild.trvOutput.BeginUpdate(); // newChild.trvOutput.Nodes.Add(txtAlbum.Text); // newChild.trvOutput.EndUpdate(); // newChild.MdiParent = _frmMain; // newChild.Show(); // } // else if (Program.openArtists.Contains(txtArtist.Text)) // { // foreach (SmallClasses.AlbumsByArtist tempAlbumArtist in Program.albumsByArtists) // { // if (tempAlbumArtist.album == txtAlbum.Text && tempAlbumArtist.artist == txtArtist.Text) // { // MessageBox.Show("Artist and album combo already exists"); // albumArtistExist = true; // break; // } // else // { // albumArtistExist = false; // } // } // if (!albumArtistExist) // { // //MessageBox.Show("New album from artist detected"); // frmChild currentArtist = new frmChild(); // foreach (frmChild currentChild in Program.openChildren) // { // if (currentChild.Text == txtArtist.Text) // { // currentArtist = currentChild; // break; // } // } // //currentArtist.Focus(); // //var currentNodes = currentArtist.trvOutput.Nodes; // currentArtist.trvOutput.BeginUpdate(); // currentArtist.trvOutput.Nodes.Add(txtAlbum.Text); // currentArtist.trvOutput.EndUpdate(); // } // } // this.Close(); //} }