/// <summary> /// Create facade with the artists supplied in the list /// </summary> /// <param name="artistObjectList"></param> private void LoadSearchedArtists(List<DBArtistInfo> artistList, MvSort sortDirection) { // Set View _currentView = MvView.SearchedArtists; addToStack(_currentView, false); GUIPropertyManager.SetProperty("#mvCentral.Hierachy", Localization.Artists); GUIPropertyManager.SetProperty("#itemcount", artistList.Count.ToString()); GUIPropertyManager.SetProperty("#itemtype", Localization.Artists); GUIPropertyManager.Changed = true; // Sort Artists if (sortDirection == MvSort.Ascending) artistList.Sort(delegate(DBArtistInfo p1, DBArtistInfo p2) { return p1.Artist.CompareTo(p2.Artist); }); else artistList.Sort(delegate(DBArtistInfo p1, DBArtistInfo p2) { return p2.Artist.CompareTo(p1.Artist); }); // Clear facade and load tracks if we dont already have them loaded GUIControl.ClearControl(GetID, facadeLayout.GetID); foreach (DBArtistInfo artistData in artistList) { GUIListItem facadeItem = new GUIListItem(); facadeItem.Label = artistData.Artist; if (string.IsNullOrEmpty(artistData.ArtFullPath.Trim())) facadeItem.ThumbnailImage = artistTrackArt(artistData); else facadeItem.ThumbnailImage = artistData.ArtFullPath; facadeItem.TVTag = mvCentralUtils.bioNoiseFilter(artistData.bioContent); facadeItem.AlbumInfoTag = mvCentralUtils.bioNoiseFilter(artistData.bioContent); facadeItem.ItemId = (int)artistData.ID; facadeItem.IsFolder = true; facadeItem.MusicTag = artistData; facadeItem.OnItemSelected += new GUIListItem.ItemSelectedHandler(onArtistSelected); facadeLayout.Add(facadeItem); foreach (string artistTag in artistData.Tag) { if (!artistTags.Contains(artistTag)) { if (artistTag != artistData.Artist) artistTags.Add(artistTag); } } } artistTags.Sort(delegate(string p1, string p2) { return p1.CompareTo(p2); }); // If first time though set properites to first item in facade if (facadeLayout.Count > 0 && !_persisting) { facadeLayout.SelectedListItemIndex = 0; onArtistSelected(facadeLayout.SelectedListItem, facadeLayout); } // Set focus to the facade GUIControl.FocusControl(GetID, facadeLayout.GetID); _persisting = true; GUIPropertyManager.SetProperty("#mvCentral.ArtistView", "true"); GUIPropertyManager.SetProperty("#mvCentral.TrackView", "false"); GUIPropertyManager.SetProperty("#mvCentral.AlbumView", "false"); GUIPropertyManager.SetProperty("#mvCentral.GenreView", "false"); GUIPropertyManager.SetProperty("#mvCentral.DVDView", "false"); clearVideoAudioProps(); GUIPropertyManager.Changed = true; }
/// <summary> /// Load Videos /// </summary> /// <param name="ArtistID"></param> private void loadVideos(int ArtistID, MvSort sortOrder) { DBAlbumInfo db1 = null; _videoSort = sortOrder; GUIPropertyManager.SetProperty("#mvCentral.Hierachy", Localization.Videos + " | " + DBArtistInfo.Get(ArtistID)); GUIPropertyManager.Changed = true; // Load the albums (Not used Currently) if (facadeLayout.SelectedListItem == null) { if (albumID != 0 && !mvCentralCore.Settings.DisableAlbumSupport) { LoadTracksOnAlbum(albumID); GUIPropertyManager.SetProperty("#mvCentral.Hierachy", Localization.Albums + " | " + DBArtistInfo.Get(ArtistID)); return; } } // If we are on an artist - load the album (Not Used Currently) - *** Possible Error *** if (facadeLayout.SelectedListItem != null && !mvCentralCore.Settings.DisableAlbumSupport) { if ((facadeLayout.SelectedListItem.MusicTag != null && facadeLayout.SelectedListItem.MusicTag.GetType() == typeof(DBAlbumInfo))) { if (_layoutChanging) { db1 = DBAlbumInfo.Get(albumID); } else { db1 = (DBAlbumInfo)facadeLayout.SelectedListItem.MusicTag; albumID = db1.ID.Value; } LoadTracksOnAlbum(db1.ID.Value); GUIPropertyManager.SetProperty("#mvCentral.Hierachy", Localization.Albums + " | " + db1.Album); GUIPropertyManager.SetProperty("#mvCentral.ArtistView", "false"); GUIPropertyManager.SetProperty("#mvCentral.TrackView", "false"); GUIPropertyManager.SetProperty("#mvCentral.AlbumView", "true"); GUIPropertyManager.SetProperty("#mvCentral.GenreView", "false"); GUIPropertyManager.SetProperty("#mvCentral.DVDView", "false"); GUIPropertyManager.Changed = true; return; } } //// Grab the info for the currently selected artist //currArtist = DBArtistInfo.Get(ArtistID); //// and store it //currentArtistID = ArtistID; // Load all videos for selected artist List<DBTrackInfo> artistTrackList = DBTrackInfo.GetEntriesByArtist(_currArtist); // And sort if (sortOrder == MvSort.Ascending) artistTrackList.Sort(delegate(DBTrackInfo p1, DBTrackInfo p2) { return p1.Track.CompareTo(p2.Track); }); else artistTrackList.Sort(delegate(DBTrackInfo p1, DBTrackInfo p2) { return p2.Track.CompareTo(p1.Track); }); this.artistID = ArtistID; // Clear facade GUIControl.ClearControl(GetID, facadeLayout.GetID); // and load tracks if we dont already have them loaded foreach (DBTrackInfo trackData in artistTrackList) { // If no Album is associated or Album support is disabled then skip to next track if (trackData.AlbumInfo.Count == 0 || mvCentralCore.Settings.DisableAlbumSupport) continue; //We have an album DBAlbumInfo theAlbum = DBAlbumInfo.Get(trackData); // Check if we already have this album as a facade item bool isPresent = false; for (int i = 0; i <= facadeLayout.Count - 1; i++) { if (facadeLayout[i].Label == trackData.AlbumInfo[0].Album) isPresent = true; } // and skip adding if we do if (isPresent) continue; // Add Album to facade GUIListItem item = new GUIListItem(); item.Label = theAlbum.Album; if (string.IsNullOrEmpty(theAlbum.ArtFullPath.Trim())) item.ThumbnailImage = "defaultVideoBig.png"; else item.ThumbnailImage = theAlbum.ArtFullPath; item.TVTag = mvCentralUtils.bioNoiseFilter(theAlbum.bioContent); _selArtist = _currArtist.Artist; item.IsFolder = true; item.OnItemSelected += new GUIListItem.ItemSelectedHandler(onVideoSelected); item.MusicTag = theAlbum; item.Rating = theAlbum.Rating; facadeLayout.Add(item); } // Load tracks we don't have loaded foreach (DBTrackInfo trackData in artistTrackList) { // if this track is part of an album and we have not disabled Album support then skip the adding track to the facade if (trackData.AlbumInfo.Count > 0 && !mvCentralCore.Settings.DisableAlbumSupport) continue; GUIListItem facadeItem = new GUIListItem(); if (mvCentralCore.Settings.DisplayRawTrackText) { if (Path.GetFileName(trackData.LocalMedia[0].File.FullName).Contains("-")) facadeItem.Label = Regex.Match(Path.GetFileName(trackData.LocalMedia[0].File.FullName), @"(?:[\s-:;]{2,}|(?!.+?[\s-:;]{2,})\-)(?<track>[^\\$]*)\.").Groups["track"].Value; else facadeItem.Label = (Path.GetFileNameWithoutExtension(trackData.LocalMedia[0].File.FullName)); facadeItem.Label = Regex.Replace(facadeItem.Label, @"\s*[{].*?[}]\s*", string.Empty, RegexOptions.IgnoreCase); } else facadeItem.Label = trackData.Track; facadeItem.TVTag = mvCentralUtils.bioNoiseFilter(trackData.bioContent); _selArtist = _currArtist.Artist; facadeItem.Path = trackData.LocalMedia[0].File.FullName; facadeItem.IsFolder = false; facadeItem.OnItemSelected += new GUIListItem.ItemSelectedHandler(onVideoSelected); facadeItem.MusicTag = trackData; facadeItem.Rating = trackData.Rating; // If no thumbnail set a default if (!string.IsNullOrEmpty(trackData.ArtFullPath.Trim())) facadeItem.ThumbnailImage = trackData.ArtFullPath; else facadeItem.ThumbnailImage = "defaultVideoBig.png"; facadeLayout.Add(facadeItem); } //facadeLayout.Sort(new GUIListItemVideoComparer(SortingFields.Artist, SortingDirections.Ascending)); // Set properities to first item in list if (facadeLayout.Count > 0) { if (lastItemVid > 0 && lastItemVid < facadeLayout.Count) facadeLayout.SelectedListItemIndex = lastItemVid; else facadeLayout.SelectedListItemIndex = 0; logger.Debug("(loadVideos) Facade Selected Index set to {0}", facadeLayout.SelectedListItemIndex); onVideoSelected(facadeLayout.SelectedListItem, facadeLayout); } _persisting = true; GUIPropertyManager.SetProperty("#mvCentral.Hierachy", Localization.Albums); GUIPropertyManager.SetProperty("#itemcount", facadeLayout.Count.ToString()); GUIPropertyManager.SetProperty("#itemtype", Localization.Albums); // Set the view GUIPropertyManager.SetProperty("#mvCentral.ArtistView", "false"); GUIPropertyManager.SetProperty("#mvCentral.TrackView", "true"); GUIPropertyManager.SetProperty("#mvCentral.AlbumView", "false"); GUIPropertyManager.SetProperty("#mvCentral.GenreView", "false"); GUIPropertyManager.SetProperty("#mvCentral.DVDView", "false"); clearVideoAudioProps(); GUIPropertyManager.Changed = true; }
/// <summary> /// Load and Display all Videos /// </summary> /// <param name="sortOrder"></param> private void loadAllVideos(MvSort sortOrder) { _videoSort = sortOrder; // Get list of all videos List<DBTrackInfo> artistTrackList = DBTrackInfo.GetAll(); // Sort the tracks if (sortOrder == MvSort.Ascending) artistTrackList.Sort(delegate(DBTrackInfo p1, DBTrackInfo p2) { return p1.Track.CompareTo(p2.Track); }); else artistTrackList.Sort(delegate(DBTrackInfo p1, DBTrackInfo p2) { return p2.Track.CompareTo(p1.Track); }); // Clear the facade GUIControl.ClearControl(GetID, facadeLayout.GetID); // Load tracks into facade foreach (DBTrackInfo trackData in artistTrackList) { GUIListItem facadeItem = new GUIListItem(); if (mvCentralCore.Settings.DisplayRawTrackText) { if (Path.GetFileName(trackData.LocalMedia[0].File.FullName).Contains("-")) facadeItem.Label = Regex.Match(Path.GetFileName(trackData.LocalMedia[0].File.FullName), @"(?:[\s-:;]{2,}|(?!.+?[\s-:;]{2,})\-)(?<track>[^\\$]*)\.").Groups["track"].Value; else facadeItem.Label = (Path.GetFileNameWithoutExtension(trackData.LocalMedia[0].File.FullName)); facadeItem.Label = Regex.Replace(facadeItem.Label, @"\s*[{].*?[}]\s*", string.Empty, RegexOptions.IgnoreCase); } else facadeItem.Label = trackData.Track; facadeItem.Label2 = trackData.ArtistInfo[0].Artist; facadeItem.TVTag = mvCentralUtils.bioNoiseFilter(trackData.bioContent); facadeItem.Path = trackData.LocalMedia[0].File.FullName; facadeItem.IsFolder = false; facadeItem.OnItemSelected += new GUIListItem.ItemSelectedHandler(onVideoSelected); facadeItem.MusicTag = trackData; facadeItem.Rating = trackData.Rating; // If no thumbnail set a default if (!string.IsNullOrEmpty(trackData.ArtFullPath.Trim())) facadeItem.ThumbnailImage = trackData.ArtFullPath; else facadeItem.ThumbnailImage = "defaultVideoBig.png"; facadeLayout.Add(facadeItem); } // Set properities to first item in list if (facadeLayout.Count > 0 && !_persisting) { facadeLayout.SelectedListItemIndex = 0; onVideoSelected(facadeLayout.SelectedListItem, facadeLayout); } _persisting = true; GUIPropertyManager.SetProperty("#itemcount", facadeLayout.Count.ToString()); GUIPropertyManager.SetProperty("#itemtype", Localization.Videos); GUIPropertyManager.SetProperty("#mvCentral.Hierachy", Localization.AllVideos); GUIPropertyManager.SetProperty("#mvCentral.ArtistView", "false"); GUIPropertyManager.SetProperty("#mvCentral.TrackView", "true"); GUIPropertyManager.SetProperty("#mvCentral.AlbumView", "false"); GUIPropertyManager.SetProperty("#mvCentral.GenreView", "false"); GUIPropertyManager.SetProperty("#mvCentral.DVDView", "false"); clearVideoAudioProps(); GUIPropertyManager.Changed = true; // Set properities to first item in list if (facadeLayout.Count > 0) { if (lastItemVid > 0 && lastItemVid < facadeLayout.Count) { facadeLayout.SelectedListItemIndex = lastItemVid; logger.Debug("(loadAllVideos) Facade Selected Index set to {0}", facadeLayout.SelectedListItemIndex); onVideoSelected(facadeLayout.SelectedListItem, facadeLayout); } else { facadeLayout.SelectedListItemIndex = 0; logger.Debug("(loadAllVideos) Facade Selected Index set to {0}", facadeLayout.SelectedListItemIndex); onVideoSelected(facadeLayout.SelectedListItem, facadeLayout); } } }