public TreeBrowserResults() { InitializeComponent(); Albums = new ObservableAlbumCollection(); //Have one by default CommandBindings.Add(new CommandBinding(CommonCommands.Save, new ExecutedRoutedEventHandler(SaveExec))); CreateArtFileSearchThread(); }
/// <summary> /// Method will go through all added albums, convert them into tree item hierarchy /// and display them /// /// </summary> /// <param name="addedAlbums"></param> private void ConvertIntoTreeItems(ObservableAlbumCollection addedAlbums) { // hash map od disc and its tracks Dictionary <String, List <TagLib.File> > discs = new Dictionary <String, List <TagLib.File> >(); // go through all given albums foreach (Album album in addedAlbums) { if (album == null) { continue; } String albumName = album.Name; List <TagLib.File> values; // check if there is entry for given key bool contains = discs.ContainsKey(albumName); // there is no entry for current key - create one // and insert empty list of files if (!contains) { values = new List <TagLib.File>(); discs.Add(albumName, values); } else { // TODO: some check for null pointer etc bool success = discs.TryGetValue(albumName, out values); } foreach (TagLib.File item in album.Tracks) { values.Add(item); } } // prepare dataprovider for the treeview component discList = new List <DiscViewModel>(); // go through hashmap of albums and add them all into // treeview item model with all its children foreach (KeyValuePair <string, List <TagLib.File> > pair in discs) { TagLib.File[] tagLibFiles = pair.Value.ToArray(); DiscViewModel disc = new DiscViewModel(pair.Key, tagLibFiles); discList.Add(disc); } base.DataContext = discList.ToArray(); }
public BrowserResults() { InitializeComponent(); Albums = new ObservableAlbumCollection(); //Have one by default CommandBindings.Add(new CommandBinding(ApplicationCommands.SelectAll, new ExecutedRoutedEventHandler(SelectAllExec))); CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, new ExecutedRoutedEventHandler(DeleteExec))); CommandBindings.Add(new CommandBinding(Commands.SelectMissing, new ExecutedRoutedEventHandler(SelectMissingExec))); CommandBindings.Add(new CommandBinding(Commands.GetArtwork, new ExecutedRoutedEventHandler(GetArtworkExec), new CanExecuteRoutedEventHandler(GetArtworkCanExec))); CommandBindings.Add(new CommandBinding(CommonCommands.Delete, new ExecutedRoutedEventHandler(DeleteArtFileExec), new CanExecuteRoutedEventHandler(CommonCommands.DeleteFileCanExec))); CommandBindings.Add(new CommandBinding(CommonCommands.Rename, new ExecutedRoutedEventHandler(RenameArtFileExec), new CanExecuteRoutedEventHandler(CommonCommands.RenameArtFileCanExec))); CreateArtFileSearchThread(); }