public MainWindowController() { GLib.ExceptionManager.UnhandledException += args => { Console.Write(args.ToString()); }; _collection = new Collection(); AudioPlayer audioPlayer = new AudioPlayer(); _filteredTrackListViewController = new FilteredTrackListViewController(_collection, audioPlayer); _sourceTreeViewController = new SourceTreeViewController(_filteredTrackListViewController, _collection); _playerControlPanelController = new PlayerControlPanelController(audioPlayer); _nowPlayingPanelController = new NowPlayingPanelController(audioPlayer, _filteredTrackListViewController); _menuBarController = new MenuBarController(); _window = new MainWindow(); _window.DeleteEvent += (o, args) => Application.Quit(); _window.AddWest(_sourceTreeViewController.View); _window.AddCenter(_filteredTrackListViewController.View); _window.AddEast(_nowPlayingPanelController.View); _window.AddSouth(_playerControlPanelController.View); _window.AddNorth(_menuBarController.View); _window.QueueResize(); _window.ShowAll(); }
public FilteredTrackListViewController(Collection collection, AudioPlayer audioPlayer) : base(new FilteredTrackListModel(collection), new BaseTrackListViewControllerSettings("FilteredTrackListView", DefaultColumnPropertyArray, DefaultColumnWidths), audioPlayer) { TrackListViewColumn column; if (PropertiesToColumns.TryGetValue(TrackProperty.Artist, out column)) ((TreeModelSort) TrackListView.Model).SetSortColumnId(column.SortColumnId, SortType.Ascending); }
private static TreeStore CreateSourceTreeStore(Collection collection) { TreeStore store = new TreeStore(typeof(SourceTreeStoreValue)); SourceTreeStoreValue musicRow = new SourceTreeStoreValue { DisplayString = "Music", TrackFilter = track => true }; TreeIter musicIter = store.AppendValues(musicRow); SourceTreeStoreValue artistAndAlbumArtistRow = new SourceTreeStoreValue { DisplayString = "Artist & Album Artist", TrackFilter = track => true }; TreeIter artistAndAlbumArtistIter = store.AppendValues(musicIter, artistAndAlbumArtistRow); foreach (Artist artist in collection.GetTrackArtistsAndAlbumArtists()) { Artist someArtist = artist; SourceTreeStoreValue someArtistRow = new SourceTreeStoreValue { DisplayString = artist.Name, TrackFilter = track => track.Album.Artists.Any(a => a.Id == someArtist.Id) || track.Artists.Any(a => a.Id == someArtist.Id) }; TreeIter someArtistIter = store.AppendValues(artistAndAlbumArtistIter, someArtistRow); foreach (Album album in someArtist.Albums) { Album someAlbum = album; SourceTreeStoreValue someAlbumRow = new SourceTreeStoreValue { DisplayString = album.Title, TrackFilter = track => string.Compare(track.Album.Title, someAlbum.Title, StringComparison.Ordinal) == 0 }; store.AppendValues(someArtistIter, someAlbumRow); } } return store; }
public SourceTreeViewController(FilteredTrackListViewController filteredTrackListViewController, Collection collection) { _filteredTrackListViewController = filteredTrackListViewController; _sourceTreeView = new SourceTreeView(); _sourceTreeView.Model = CreateSourceTreeStore(collection); SourceTreeViewColumn sourceColumn = new SourceTreeViewColumn(); SourceCellRenderer sourceCellRenderer = new SourceCellRenderer(); sourceColumn.PackStart(sourceCellRenderer, true); sourceColumn.SetCellDataFunc(sourceCellRenderer, (TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) => { SourceTreeStoreValue value = (SourceTreeStoreValue)model.GetValue(iter, 0); ((CellRendererText)cell).Text = value.DisplayString; }); _sourceTreeView.AppendColumn(sourceColumn); _sourceTreeView.Selection.Changed += SelectionOnChanged; View = new ScrolledWindow {_sourceTreeView}; View.SetSizeRequest(200, -1); }
private static Tuple<ListStore, Dictionary<Track, TreeIter>> CreateListStoreAndDictionaryTuple(Collection collection) { return CreateListStoreAndDictionaryTuple(collection.GetTracks()); }
public FilteredTrackListModel(Collection collection) : this(CreateListStoreAndDictionaryTuple(collection)) { }