public override bool SetSource(ISource source) { ITrackModelSource track_source = source as ITrackModelSource; IFilterableSource filterable_source = source as IFilterableSource; if (track_source == null) { return(false); } this.source = source; SetModel(track_view, track_source.TrackModel); if (filterable_source != null && filterable_source.CurrentFilters != null) { foreach (IListModel model in filterable_source.CurrentFilters) { if (model is IListModel <ArtistInfo> ) { SetModel(artist_view, (model as IListModel <ArtistInfo>)); } else if (model is IListModel <AlbumInfo> ) { SetModel(album_view, (model as IListModel <AlbumInfo>)); } } } return(true); }
public override bool SetSource(ISource source) { ITrackModelSource track_source = source as ITrackModelSource; IFilterableSource filterable_source = source as IFilterableSource; if (track_source == null) { return(false); } base.SetSource(source); SetModel(track_view, track_source.TrackModel); bool genre_view_model_set = false; if (filterable_source != null && filterable_source.CurrentFilters != null) { foreach (IListModel model in filterable_source.CurrentFilters) { if (model is IListModel <ArtistInfo> && model is DatabaseArtistListModel) { SetModel(artist_view, (model as IListModel <ArtistInfo>)); } else if (model is IListModel <ArtistInfo> && model is DatabaseAlbumArtistListModel) { SetModel(albumartist_view, (model as IListModel <ArtistInfo>)); } else if (model is IListModel <AlbumInfo> ) { SetModel(album_view, (model as IListModel <AlbumInfo>)); } else if (model is IListModel <QueryFilterInfo <string> > && !genre_view_model_set) { SetModel(genre_view, (model as IListModel <QueryFilterInfo <string> >)); genre_view_model_set = true; } else if (model is DatabaseYearListModel) { SetModel(year_view, model as IListModel <YearInfo>); } else { Hyena.Log.DebugFormat("CompositeTrackSourceContents got non-album/artist filter model: {0}", model); } } } ClearFilterSelections(); track_view.HeaderVisible = true; return(true); }
private void UpdateActions(bool force) { Source source = ActionSource; if ((force || source != last_source) && source != null) { IUnmapableSource unmapable = (source as IUnmapableSource); IImportSource import_source = (source as IImportSource); SmartPlaylistSource smart_playlist = (source as SmartPlaylistSource); PrimarySource primary_source = (source as PrimarySource) ?? (source.Parent as PrimarySource); UpdateAction("UnmapSourceAction", unmapable != null, unmapable != null && unmapable.CanUnmap, source); UpdateAction("RenameSourceAction", source.CanRename, true, null); UpdateAction("ImportSourceAction", import_source != null, import_source != null && import_source.CanImport, source); UpdateAction("ExportPlaylistAction", source is AbstractPlaylistSource, true, source); UpdateAction("SourcePropertiesAction", source.HasProperties, true, source); UpdateAction("SourcePreferencesAction", source.PreferencesPageId != null, true, source); UpdateAction("RefreshSmartPlaylistAction", smart_playlist != null && smart_playlist.CanRefresh, true, source); this["OpenSourceSwitcher"].Visible = false; bool playlists_writable = primary_source != null && primary_source.SupportsPlaylists && !primary_source.PlaylistsReadOnly; UpdateAction("NewPlaylistAction", playlists_writable, true, source); UpdateAction("NewSmartPlaylistAction", playlists_writable, true, source); /*UpdateAction ("NewSmartPlaylistFromSearchAction", (source is LibrarySource || source.Parent is LibrarySource), * !String.IsNullOrEmpty (source.FilterQuery), source);*/ ActionGroup browser_actions = Actions.FindActionGroup("BrowserView"); if (browser_actions != null) { IFilterableSource filterable_source = source as IFilterableSource; bool has_browser = filterable_source != null && filterable_source.AvailableFilters.Count > 0; UpdateAction(browser_actions["BrowserTopAction"], has_browser); UpdateAction(browser_actions["BrowserLeftAction"], has_browser); UpdateAction(browser_actions["BrowserVisibleAction"], has_browser); } last_source = source; } if (source != null) { UpdateAction("SortChildrenAction", source.ChildSortTypes.Length > 0 && source.Children.Count > 1, true, source); } Action <Source> handler = Updated; if (handler != null) { handler(source); } }
public override bool SetSource(ISource source) { ITrackModelSource track_source = source as ITrackModelSource; IFilterableSource filterable_source = source as IFilterableSource; if (track_source == null) { return(false); } this.source = source; SetModel(track_view, track_source.TrackModel); if (filterable_source != null && filterable_source.CurrentFilters != null) { foreach (IListModel model in filterable_source.CurrentFilters) { if (model is IListModel <ArtistInfo> ) { SetModel(artist_view, (model as IListModel <ArtistInfo>)); } else if (model is IListModel <AlbumInfo> ) { SetModel(album_view, (model as IListModel <AlbumInfo>)); } // else if (model is IListModel<QueryFilterInfo<string>>) // SetModel (genre_view, (model as IListModel<QueryFilterInfo<string>>)); // else // Hyena.Log.DebugFormat ("CompositeTrackSourceContents got non-album/artist filter model: {0}", model); } } track_view.HeaderVisible = true; return(true); }