private void SortByArtistToolStripMenuItem_Click(object sender, EventArgs e) { var SortedList = Music.OrderBy(x => TagFile.GetArtists(x)).ThenBy(x => TagFile.GetAlbum(x)).ThenBy(x => TagFile.GetTrack(x)).ToList(); // The only reason make me keep All this Code bellow on comment, is that i found a better and small way to do it (The Line upove) #region The Comment Code /* // I use the OrderBy function and the Linq, to sort the list on the Album * List<string> MusicListCopy = Music.OrderBy(o => TagFile.Album(o)).ToList(); * List<string> AllAlbumsName = new List<string>(); * * foreach (var item in MusicListCopy) * AllAlbumsName.Add(TagFile.Album(item)); * // Reamove all the rapeated AlbumName on the list * AllAlbumsName = AllAlbumsName.Distinct().ToList(); * * List<string> SortedList = new List<string>(); * List<string> OnlyOneAlbumMusic = new List<string>(); * * foreach (var ItemInAllAlbumsName in AllAlbumsName) * { * foreach (var ItemInMusic in Music) * { * if (TagFile.Album(ItemInMusic) == ItemInAllAlbumsName) * { * OnlyOneAlbumMusic.Add(ItemInMusic); * MusicListCopy.Remove(ItemInMusic); * } * } * * OnlyOneAlbumMusic = OnlyOneAlbumMusic.OrderBy(o => TagFile.Track(o)).ToList(); * * foreach (var item in OnlyOneAlbumMusic) * SortedList.Add(item); * OnlyOneAlbumMusic.Clear(); * } * * SortedList = SortedList.OrderBy(o => TagFile.Artist(o)).ToList(); */ #endregion // Clear the Lists and initialize the index and waveoutevent to null ClearListToolStripMenuItem.PerformClick(); // Initialize the list and Play the first music AddItemsInListToTheMainList(SortedList); LastSortedMethode = SortedMethode.Artist; SortByArtistToolContextMenuStriItem.Checked = true; SortByTitleToolContextMenuStriItem.Checked = false; SortByAlbumToolContextMenuStriItem.Checked = false; ArtistToolStripMenuItem.Checked = true; TitleToolStripMenuItem.Checked = false; AlbumToolStripMenuItem.Checked = false; }
private void Form_FormClosing(object sender, FormClosingEventArgs e) { // Clear the Lists and initialize the index and waveoutevent to null ClearListToolStripMenuItem.PerformClick(); // Delete the Temp Files if (Directory.Exists("TempFiles/")) { Directory.Delete("TempFiles/", true); } }
private void ButtonShuffle_Click(object sender, EventArgs e) { if (Music.Count != 0) { if (ShuffleState == ShuffleState.On) { ShuffleState = ShuffleState.Off; ShuffleToolStripMenuItem.Checked = false; ButtonShuffle.BackgroundImage = Properties.Resources.shuffleOff; // Order the list on the last SortedMethode if (LastSortedMethode == SortedMethode.Title) { SortByTitleToolContextMenuStriItem.PerformClick(); } else if (LastSortedMethode == SortedMethode.Album) { SortByAlbumToolContextMenuStriItem.PerformClick(); } else if (LastSortedMethode == SortedMethode.Artist) { SortByArtistToolContextMenuStriItem.PerformClick(); } } else if (ShuffleState == ShuffleState.Off) { ShuffleState = ShuffleState.On; ShuffleToolStripMenuItem.Checked = true; ButtonShuffle.BackgroundImage = Properties.Resources.shuffleOn; SortByTitleToolContextMenuStriItem.Checked = false; SortByArtistToolContextMenuStriItem.Checked = false; SortByAlbumToolContextMenuStriItem.Checked = false; TitleToolStripMenuItem.Checked = false; ArtistToolStripMenuItem.Checked = false; AlbumToolStripMenuItem.Checked = false; // Shuffle the List List <string> ShuffledList = Music.OrderBy((item) => RandomValue.Next()).ToList(); // Clear the Lists and initialize the index and waveoutevent to null ClearListToolStripMenuItem.PerformClick(); // Initialize the list and Play the first music AddItemsInListToTheMainList(ShuffledList); } } }
private void SortByAlbumToolStripMenuItem_Click(object sender, EventArgs e) { // Sort thelist by the Album then the Track Number var SortedList = Music.OrderBy(x => TagFile.GetAlbum(x)).ThenBy(x => TagFile.GetTrack(x)).ToList(); // Clear the Lists and initialize the index and waveoutevent to null ClearListToolStripMenuItem.PerformClick(); // Initialize the list and Play the first music AddItemsInListToTheMainList(SortedList); LastSortedMethode = SortedMethode.Album; SortByAlbumToolContextMenuStriItem.Checked = true; SortByTitleToolContextMenuStriItem.Checked = false; SortByArtistToolContextMenuStriItem.Checked = false; AlbumToolStripMenuItem.Checked = true; TitleToolStripMenuItem.Checked = false; ArtistToolStripMenuItem.Checked = false; }
private void SortByTitleToolStripMenuItem_Click(object sender, EventArgs e) { // I use the OrderBy function and the Linq, to sort the list on the title List <string> SortedList = Music.OrderBy(o => TagFile.GetTitle(o)).ToList(); // Clear the Lists and initialize the index and waveoutevent to null ClearListToolStripMenuItem.PerformClick(); // Initialize the list and Play the first music AddItemsInListToTheMainList(SortedList); LastSortedMethode = SortedMethode.Title; SortByTitleToolContextMenuStriItem.Checked = true; SortByArtistToolContextMenuStriItem.Checked = false; SortByAlbumToolContextMenuStriItem.Checked = false; TitleToolStripMenuItem.Checked = true; ArtistToolStripMenuItem.Checked = false; AlbumToolStripMenuItem.Checked = false; }