private void AddAlbummToCollection(AlbumDirectory albumDirectory) { AlbumDirectory album = null; if (this.albumCollection.Count == 0) { albumDirectory.AlbumNo = "0001"; this.albumCollection.Add(albumDirectory); do { albumCollection.Add(album); } while (albumCollection.Count < 12); } else { int currentIndex = 0; for (int i = 0; i < this.albumCollection.Count; i++) { var albumD = this.albumCollection[i]; if (albumD == null) { albumDirectory.AlbumNo = string.Format("{0:0000}", i + 1); albumCollection.Insert(currentIndex, albumDirectory); break; } currentIndex++; } } }
private void OpenAlbumDirectoryMethod() { VistaFolderBrowserDialog folderBrowserDialog = new VistaFolderBrowserDialog(); folderBrowserDialog.Description = @"Please select a root folder."; folderBrowserDialog.UseDescriptionForTitle = true; if ((bool)folderBrowserDialog.ShowDialog()) { this.albumDirectory = folderBrowserDialog.SelectedPath; int numAlbums = 0; DirectoryInfo d = new DirectoryInfo(this.albumDirectory); foreach (DirectoryInfo subd in d.GetDirectories()) { var attributes = subd.Attributes; AlbumDirectory album = new AlbumDirectory(subd.FullName); if (album.SongCollection.Count > 0 && subd.FullName.Contains("-") && string.IsNullOrEmpty(subd.Extension)) { numAlbums++; album.DefaultAlbumArt = subd.FullName + @"\portada.jpg"; album.AlbumName = subd.FullName.Substring(subd.FullName.IndexOf("-") + 1); var artistAndAlbumName = subd.FullName.Substring(subd.FullName.LastIndexOf("\\")).Replace("\\", string.Empty); album.ArtistName = artistAndAlbumName.Replace(album.AlbumName, string.Empty).Replace("-", string.Empty); album.SongCollection = new ObservableCollection<Song>(album.SongCollection.OrderBy(x => x.Track)); this.AddAlbummToCollection(album); } ////else ////{ //// MessageBox.Show(string.Format("Cannot find any music file on directory {0} or this is a occult folder.", subd.FullName), "SK Jukebox WPF", //// MessageBoxButton.OK, MessageBoxImage.Warning); ////} } this.SaveToXml(); MessageBox.Show(string.Format("Found {0} albums.", numAlbums), "SK Jukebox WPF", MessageBoxButton.OK, MessageBoxImage.Warning); this.MusicListBox.ItemsSource = this.albumCollection.Take(count); } }
private void NavigateToSelectedAlbum(AlbumDirectory albumDirectory) { if (albumDirectory != null) { int index = this.albumCollection.IndexOf(albumDirectory); int mul = index / this.count; if (mul == 0) { this.MusicListBox.ItemsSource = this.albumCollection.Take(this.count); } else { this.MusicListBox.ItemsSource = this.albumCollection.Skip(mul * this.count).Take(this.count); } ////this.BindingToAlbumSelected(albumDirectory); ////if (this.MusicListBox.SelectedItem == null) ////{ ////this.MusicListBox.SelectedItem = albumDirectory; ////} } }
private void NavigateToSelectedAlbumAndSong(AlbumDirectory albumDirectory) { if (albumDirectory != null) { int index = this.albumCollection.IndexOf(albumDirectory); int mul = index / this.count; if (mul == 0) { this.MusicListBox.ItemsSource = this.albumCollection.Take(this.count); } else { this.MusicListBox.ItemsSource = this.albumCollection.Skip(mul * this.count).Take(this.count); } ////this.BindingToAlbumSelected(albumDirectory); ////if (this.MusicListBox.SelectedItem == null) ////{ ////this.MusicListBox.SelectedItem = albumDirectory; ////} var song = albumDirectory.SongCollection.SingleOrDefault( x => x.Track == Int32.Parse(StringHelper.Right(this.currentTrack.TrackNo, 2))); this.MyMediaElement.Source = new Uri(song.FileName); this.PlayingSongTextBlock.Text = song.Title; this.MyMediaElement.Play(); ////foreach (var directory in this.albumCollection) ////{ //// if (directory != null) //// { //// directory.IsPlaying = false; //// } ////} ////(this.MusicListBox.SelectedItem as AlbumDirectory).IsPlaying = true; this.MusicListBox.Items.Refresh(); } }
private void BindingToAlbumSelected(AlbumDirectory albumDirectory) { this.PlayGrid.DataContext = albumDirectory; this.RatingAlbum.Value = albumDirectory.Rating; this.SongListBox.ItemsSource = albumDirectory.SongCollection; if (!string.IsNullOrEmpty(albumDirectory.Genre)) { this.AddToCollectionTopAlbumByGenre(albumDirectory.Genre); } }