/// <summary> /// Gets the sort order for an artist in an artist string. /// Determines the order the artist appear in the list. /// </summary> /// <param name="artistLink">Artist link. Cannot be null.</param> /// <param name="focus">Album focus.</param> /// <returns>Sort order, 0-based.</returns> private int GetSortOrderForArtistString(IArtistLinkWithRoles artistLink, ContentFocus focus) { var categories = ArtistHelper.GetCategories(artistLink); // Animator appears first for animation discs. if (focus == ContentFocus.Video && categories.HasFlag(ArtistCategories.Animator)) { return(0); } if (focus == ContentFocus.Illustration && categories.HasFlag(ArtistCategories.Illustrator)) { return(0); } // Composer role always appears first if (categories.HasFlag(ArtistCategories.Producer) && artistLink.Roles.HasFlag(ArtistRoles.Composer)) { return(1); } // Other producers appear after composers if (categories.HasFlag(ArtistCategories.Producer)) { return(2); } if (categories.HasFlag(ArtistCategories.Circle) || categories.HasFlag(ArtistCategories.Band)) { return(3); } return(4); }
private static bool IsProducerRole(ArtistCategories categories, ContentFocus focus) { return(categories.HasFlag(ArtistCategories.Producer) || categories.HasFlag(ArtistCategories.Circle) || categories.HasFlag(ArtistCategories.Band) || (focus == ContentFocus.Video && categories.HasFlag(ArtistCategories.Animator)) || (focus == ContentFocus.Illustration && categories.HasFlag(ArtistCategories.Illustrator))); }
/// <summary> /// Gets the main circle from a group of artists, or null if there is no main circle. /// Here main circle is defined as the circle in which all the producers of the album belong to. /// </summary> /// <param name="artists">List of artists. Cannot be null.</param> /// <param name="focus">Determines types of producers to consider.</param> /// <returns>The main circle, or null if there is none.</returns> public static Artist GetMainCircle(IList <IArtistLinkWithRoles> artists, ContentFocus focus) { var producers = GetProducers(artists.Where(a => !a.IsSupport), focus).ToArray(); // Find the circle in which all the producers belong to var circle = artists.FirstOrDefault(a => a.Artist != null && GetCategories(a).HasFlag(ArtistCategories.Circle) && producers.All(p => p.Artist != null && (p.Artist.Equals(a.Artist) || p.Artist.HasGroup(a.Artist)))); return(circle != null ? circle.Artist : null); }
public TranslatedStringWithDefault GetArtistString(IEnumerable <IArtistLinkWithRoles> artists, ContentFocus focus) { ParamIs.NotNull(() => artists); var matched = artists.Where(ArtistHelper.IsValidCreditableArtist).ToArray(); var producers = matched .Where(a => ArtistHelper.IsProducerRole(a, focus)) .OrderBy(a => GetSortOrderForArtistString(a, focus)) .ToArray(); var performers = matched .Where(a => ArtistHelper.GetCategories(a).HasFlag(ArtistCategories.Vocalist) && (!producers.Contains(a) || allowRepeatingProducerAsPerformer)).ToArray(); const string various = ArtistHelper.VariousArtists; if (producers.Length >= 4 || (!producers.Any() && performers.Length >= 4)) { return(new TranslatedStringWithDefault(various, various, various, various)); } var performerNames = performers.Select(ArtistHelper.GetTranslatedName); var producerNames = producers.Select(ArtistHelper.GetTranslatedName); if (producers.Any() && performers.Length > 2 && producers.Length + performers.Length >= 5) { return(TranslatedStringWithDefault.Create(lang => string.Format("{0} feat. various", string.Join(", ", producerNames.Select(p => p[lang]))))); } else if (producers.Any() && performers.Any()) { return(TranslatedStringWithDefault.Create(lang => string.Format("{0} feat. {1}", string.Join(", ", producerNames.Select(p => p[lang])), string.Join(", ", performerNames.Select(p => p[lang]))))); } else { return(TranslatedStringWithDefault.Create(lang => string.Join(", ", (producers.Any() ? producers : performers).Select(a => ArtistHelper.GetTranslatedName(a)[lang])))); } }
public static bool IsProducerRole(IArtistLinkWithRoles link, ContentFocus focus) { return(IsProducerRole(GetCategories(link), focus)); }
private void ChildFocusInEvent(object sender, EventArgs args) { ContentFocus?.Invoke(sender, args); }
public static string[] GetProducerNames(IEnumerable <IArtistLinkWithRoles> artists, ContentFocus focus, ContentLanguagePreference languagePreference) { var matched = artists.Where(IsValidCreditableArtist).ToArray(); var producers = matched.Where(a => IsProducerRole(a, focus)).ToArray(); var names = producers.Select(p => GetTranslatedName(p).GetBestMatch(languagePreference)).ToArray(); return(names); }
public static IEnumerable <IArtistLinkWithRoles> GetProducers(IEnumerable <IArtistLinkWithRoles> artists, ContentFocus focus) { return(artists.Where(a => IsProducerRole(a, focus))); }
public static TranslatedStringWithDefault GetArtistString(IEnumerable <IArtistLinkWithRoles> artists, ContentFocus focus) { return(new ArtistStringFactory().GetArtistString(artists, focus)); }