private void ChangePictureButton_Click(object sender, RoutedEventArgs e) { try { if (track != null) { var dialog = new System.Windows.Forms.OpenFileDialog(); dialog.Filter = "Image Files (*.jpg,*.jpeg,*.png,*.gif)|*.jpg;*.jpeg;*.png;*.gif|All Files (*.*)|*.*"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (track.Path.EndsWith(".mp3")) { tagController.AddPicture(track, dialog.FileName); } else { track.ImagePath = dialog.FileName; trackController.Save(track); } } } } catch (Exception ex) { log.Error("MediaPropertyView.ChangePictureButton_Click", ex); MessageBox.Show("There was an error trying to add a picture to this track.\n\n" + ex.Message, "Could Not Add Picture To Track"); } }
public void LoadDirectories(ISource source) { if (source.Children.Count() == 1) { //var proxy = source.Children.FirstOrDefault() as ProxySource; //if (proxy != null) // source.RemoveChild(proxy); if (Directory.Exists(source.Path)) { var directory = new DirectoryInfo(source.Path); foreach (var subDirectory in directory.GetDirectories()) { var child = source.Children.Where(x => x.Path == subDirectory.FullName).FirstOrDefault(); if (child == null) { child = new DirectorySource() { Name = subDirectory.Name, Path = subDirectory.FullName, Parent = source }; source.AddChild(child); } //LoadDirectories(child); } foreach (var file in directory.GetFiles("*.mp3")) { try { var track = trackController.Search(new Dictionary <string, object> { { "Path", file.FullName } }).FirstOrDefault(); if (track == null) { track = trackController.ReadFromTag(file.FullName); trackController.Save(track); } var item = GetPlaylistItem(source, track); source.AddChild(item); } catch (Exception ex) { log.Error("SourceController.LoadDirectories: Could not load MP3 file. path=" + file.FullName, ex); } } foreach (var file in directory.GetFiles("*.wav")) { try { var track = trackController.Search(new Dictionary <string, object> { { "Path", file.FullName } }).FirstOrDefault(); if (track == null) { track = new OldTrack { Path = file.FullName, Title = file.Name }; trackController.Save(track); } var item = GetPlaylistItem(source, track); source.AddChild(item); } catch (Exception ex) { log.Error("SourceController.LoadDirectories: Could not load WAV file. path=" + file.FullName, ex); } } } } }