Esempio n. 1
0
        /// <summary>
        /// Cleans up all links to other entries so that this entry can be deleted.
        /// </summary>
        public virtual void DeleteLinks()
        {
            var artistLinks = AllArtists.ToArray();

            foreach (var artist in artistLinks)
            {
                artist.Delete();
            }

            var songLinks = AllSongs.ToArray();

            foreach (var song in songLinks)
            {
                song.Delete();
            }

            var users = UserCollections.ToArray();

            foreach (var user in users)
            {
                user.Delete();
            }

            //ArchivedVersionsManager.Clear();
            //Comments.Clear();
        }
Esempio n. 2
0
        private async Task RefreshArtists(MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
        {
            var artists = AllArtists.Select(i =>
            {
                // This should not be necessary but we're seeing some cases of it
                if (string.IsNullOrWhiteSpace(i))
                {
                    return(null);
                }

                var artist = LibraryManager.GetArtist(i);

                if (!artist.IsAccessedByName)
                {
                    return(null);
                }

                return(artist);
            }).Where(i => i != null).ToList();

            foreach (var artist in artists)
            {
                await artist.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Cleans up all links to other entries so that this entry can be deleted.
        /// </summary>
        public virtual void DeleteLinks()
        {
            var artistLinks = AllArtists.ToArray();

            foreach (var artist in artistLinks)
            {
                artist.Delete();
            }

            var songLinks = AllSongs.ToArray();

            foreach (var song in songLinks)
            {
                song.Delete();
            }

            var users = UserCollections.ToArray();

            foreach (var user in users)
            {
                user.Delete();
            }

            Tags.DeleteUsages();

            // Archived versions and comments are cascaded
        }
Esempio n. 4
0
 public async Task SearchArtists(IEnumerable <Music> source, string keyword, SortBy criterion)
 {
     AllArtists.SetTo(await Task.Run(() => SearchHelper.SearchArtists(source, keyword, criterion)));
     Artists.SetTo(AllArtists.Take(ArtistLimit));
     ArtistsTextBlock.Text           = Settings.settings.ShowCount ? Helper.LocalizeText("ArtistsWithCount", AllArtists.Count) : Helper.LocalizeText("Artists");
     ArtistsViewAllButton.Visibility = AllArtists.Count > ArtistLimit ? Visibility.Visible : Visibility.Collapsed;
     SortArtistsButton.Visibility    = Artists.Count < 2 ? Visibility.Collapsed : Visibility.Visible;
 }
Esempio n. 5
0
        public virtual ArtistForUser AddArtist(Artist artist)
        {
            ParamIs.NotNull(() => artist);

            var link = new ArtistForUser(this, artist);

            AllArtists.Add(link);

            return(link);
        }
Esempio n. 6
0
        public virtual ArtistForSong AddArtist(string name, bool isSupport, ArtistRoles roles)
        {
            ParamIs.NotNullOrEmpty(() => name);

            var link = new ArtistForSong(this, name, isSupport, roles);

            AllArtists.Add(link);

            return(link);
        }
Esempio n. 7
0
 private void SortArtistsButton_Click(object sender, RoutedEventArgs e)
 {
     MenuFlyoutHelper.SetSortByMenu(sender, Settings.settings.SearchArtistsCriterion, ArtistsCriteria,
                                    async item =>
     {
         Settings.settings.SearchArtistsCriterion = item;
         LoadingProgress.Visibility = Visibility.Visible;
         AllArtists.SetTo(await Task.Run(() => SearchHelper.SortArtists(AllArtists, CurrentKeyword.Text, item).ToList()));
         Artists.SetTo(AllArtists.Take(Artists.Count));
         LoadingProgress.Visibility = Visibility.Collapsed;
     });
 }
Esempio n. 8
0
        public void DeleteArtist(int artistId)
        {
            if (artistLookupDictionary.ContainsKey(artistId))
            {
                ArtistModel modelToRemove = artistLookupDictionary[artistId];

                AllArtists.Remove(modelToRemove);

                artistLookupDictionary.Remove(artistId);
            }

            DatabaseManager.Current.DeleteArtist(artistId);
        }
Esempio n. 9
0
        public object Get(AllArtists request)
        {
            List <Artist> result = new List <Artist>();

            using (TagsDBUser user = new TagsDBUser(request.Test))
            {
                foreach (Ares.Tags.Artist artist in user.TagsDB.BrowseInterface.GetAllArtists())
                {
                    result.Add(CreateItemResponse <Artist, Ares.Tags.Artist>(request, artist, user));
                }
                return(CreateHttpResponse(request, CreateItemResponse <AllArtistsResponse, List <Artist> >(request, result, user)));
            }
        }
Esempio n. 10
0
        public virtual void DeleteArtistForAlbum(ArtistForAlbum artistForAlbum)
        {
            if (!artistForAlbum.Album.Equals(this))
            {
                throw new ArgumentException("Artist is not attached to album", "artistForAlbum");
            }

            AllArtists.Remove(artistForAlbum);

            if (artistForAlbum.Artist != null)
            {
                artistForAlbum.Artist.AllAlbums.Remove(artistForAlbum);
            }

            UpdateArtistString();
        }
        private async Task LoadArtistsAndGenres()
        {
            var allArtistsReturned = await _artistService.Get <List <Model.Artist> >(null);

            var allGenres = await _genreService.Get <List <Model.Genre> >(null);

            var allArtistGenre = await _artistGenreService.Get <List <Model.ArtistGenre> >(null);

            foreach (var item in allArtistsReturned)
            {
                var    genres    = allArtistGenre.Where(a => a.ArtistId == item.ArtistId).ToList();
                string genresStr = "Genres: ";
                foreach (var x in genres)
                {
                    genresStr += allGenres.Where(a => a.GenreId == x.GenreId).Select(a => a.GenreName).FirstOrDefault();
                    if (x != genres.ElementAt(genres.Count - 1))
                    {
                        genresStr += ", ";
                    }
                }
                AllArtists.Add(new ArtistHelperVM()
                {
                    ArtistGenresInString = genresStr,
                    ArtistId             = item.ArtistId,
                    ArtistMembers        = item.ArtistMembers,
                    ArtistName           = item.ArtistName,
                    ArtistPhoto          = item.ArtistPhoto
                });
                QueryArtists.Add(new ArtistHelperVM()
                {
                    ArtistGenresInString = genresStr,
                    ArtistId             = item.ArtistId,
                    ArtistMembers        = item.ArtistMembers,
                    ArtistName           = item.ArtistName,
                    ArtistPhoto          = item.ArtistPhoto
                });
            }
            foreach (var item in allGenres)
            {
                AllGenres.Add(item);
                QueryGenres.Add(item);
            }
        }
        private async Task LoadTracks()
        {
            var tracksReturned = await _trackService.Get <List <Model.Track> >(null);

            foreach (var item in tracksReturned)
            {
                TrackHelperVM local = new TrackHelperVM()
                {
                    TrackId   = item.TrackId,
                    TrackName = item.TrackName,
                    AlbumName = AllAlbums.Where(a => a.AlbumId == item.AlbumId).Select(a => a.AlbumName).FirstOrDefault(),
                    AlbumId   = item.AlbumId
                };
                local.ArtistId   = AllAlbums.Where(a => a.AlbumId == local.AlbumId).Select(a => a.ArtistId).FirstOrDefault();
                local.ArtistName = AllArtists.Where(a => a.ArtistId == local.ArtistId).Select(a => a.ArtistName).FirstOrDefault();
                AllTracks.Add(local);
                QueryTracks.Add(local);
            }
        }
        private async Task LoadAlbums()
        {
            var allAlbums = await _albumService.Get <List <Model.Album> >(null);

            foreach (var item in allAlbums)
            {
                AlbumHelperVM local = new AlbumHelperVM()
                {
                    AlbumGeneratedRating = "Rating: " + item.AlbumGeneratedRating.ToString() + "/5",
                    AlbumId      = item.AlbumId,
                    AlbumName    = item.AlbumName,
                    AlbumPhoto   = item.AlbumPhoto,
                    ArtistId     = item.ArtistId,
                    DateReleased = "Released: " + item.DateReleased
                };
                local.ArtistName = AllArtists.Where(a => a.ArtistId == local.ArtistId).Select(a => a.ArtistName).FirstOrDefault();
                AllAlbums.Add(local);
                QueryAlbums.Add(local);
            }
        }
Esempio n. 14
0
        private async Task LoadLibraryAsync(Search search = null)
        {
            lvLibrary.Items.Clear();

            await RunQuery(async (cn) =>
            {
                var sort          = ((cbSort.SelectedItem as ComboBoxItem <AllArtistsSortOptions>)?.Value ?? AllArtistsSortOptions.ArtistName);
                var allArtistsQry = new AllArtists(sort);
                if (!string.IsNullOrEmpty(search?.ArtistStartsWith))
                {
                    allArtistsQry.ArtistStartsWith = search.ArtistStartsWith;
                }
                var allArtists = await allArtistsQry.ExecuteAsync(cn);
                var items      = new AllArtistsListViewBuilder();
                lvLibrary.Items.AddRange(items.GetListViewItems(allArtists));

                if (_letterGroups == null)
                {
                    _letterGroups = allArtists.GroupBy(row => row.GetLetterGroup()).Select(grp => grp.Key).OrderBy(item => item).ToArray();
                }
                alphaFilterStatusStrip1.Load(_letterGroups, search?.ArtistStartsWith);
            });
        }
Esempio n. 15
0
        private void Process(List <File> selection, List <File> allFiles)
        {
            string currAlbum     = null;
            string currArtist    = null;
            string currAA        = null;
            string currGenre     = null;
            string currComposer  = null;
            string currConductor = null;
            string currGrouping  = null;
            string currCopyright = null;

            bool set = false;

            foreach (File f in allFiles)
            {
                if (f.Tags.Title != null && f.Tags.Title.Length > 0)
                {
                    AllTitles.Add(f.Tags.Title);
                }
                string fname = Path.GetFileName(f.FileName);
                Match  match = Regex.Match(fname, @"(?:\d+\.?)?(?:[\s_]?-[\s_]?)?(.*?)\.[^\.]+$");
                if (match.Success)
                {
                    string val = match.Groups[1].Value;
                    val = val.Replace('_', ' ');
                    val = val.Replace('.', ' ');
                    val = Regex.Replace(val, @"\s+", " ");
                    val = val.Trim();
                    if (val.Length > 0)
                    {
                        AllTitles.Add(val);
                    }

                    if (f.Tags.Album != null && f.Tags.Album.Length > 0)
                    {
                        AllAlbums.Add(f.Tags.Album);
                    }
                    if (f.Tags.Artists != null && f.Tags.Artists.Length > 0)
                    {
                        AllArtists.Add(f.Tags.Artists);
                    }
                    if (f.Tags.AlbumArtists != null && f.Tags.AlbumArtists.Length > 0)
                    {
                        AllAlbumArtists.Add(f.Tags.AlbumArtists);
                    }
                    if (f.Tags.Genres != null && f.Tags.Genres.Length > 0)
                    {
                        AllGenres.Add(f.Tags.Genres);
                    }
                    if (f.Tags.Composers != null && f.Tags.Composers.Length > 0)
                    {
                        AllComposers.Add(f.Tags.Composers);
                    }
                    if (f.Tags.Conductor != null && f.Tags.Conductor.Length > 0)
                    {
                        AllConductors.Add(f.Tags.Conductor);
                    }
                    if (f.Tags.Grouping != null && f.Tags.Grouping.Length > 0)
                    {
                        AllGroupings.Add(f.Tags.Grouping);
                    }
                    if (f.Tags.Copyright != null && f.Tags.Copyright.Length > 0)
                    {
                        AllCopyrights.Add(f.Tags.Copyright);
                    }
                }
            }

            foreach (File f in selection)
            {
                if (!set)
                {
                    currAlbum     = f.Tags.Album;
                    currArtist    = f.Tags.Artists;
                    currAA        = f.Tags.AlbumArtists;
                    currGenre     = f.Tags.Genres;
                    currComposer  = f.Tags.Composers;
                    currConductor = f.Tags.Conductor;
                    currGrouping  = f.Tags.Grouping;
                    currCopyright = f.Tags.Copyright;
                }
                else
                {
                    if (SameAlbum && currAlbum != f.Tags.Album)
                    {
                        SameAlbum = false;
                    }
                    else
                    {
                        currAlbum = f.Tags.Album;
                    }

                    if (SameArtists && currArtist != f.Tags.Artists)
                    {
                        SameArtists = false;
                    }
                    else
                    {
                        currArtist = f.Tags.Artists;
                    }

                    if (SameAlbumArtists && currAA != f.Tags.AlbumArtists)
                    {
                        SameAlbumArtists = false;
                    }
                    else
                    {
                        currAA = f.Tags.AlbumArtists;
                    }

                    if (SameGenres && currGenre != f.Tags.Genres)
                    {
                        SameGenres = false;
                    }
                    else
                    {
                        currGenre = f.Tags.Genres;
                    }

                    if (SameComposers && currComposer != f.Tags.Composers)
                    {
                        SameComposers = false;
                    }
                    else
                    {
                        currComposer = f.Tags.Composers;
                    }

                    if (SameConductor && currConductor != f.Tags.Conductor)
                    {
                        SameConductor = false;
                    }
                    else
                    {
                        currConductor = f.Tags.Conductor;
                    }

                    if (SameGrouping && currGrouping != f.Tags.Grouping)
                    {
                        SameGrouping = false;
                    }
                    else
                    {
                        currGrouping = f.Tags.Grouping;
                    }

                    if (SameCopyright && currCopyright != f.Tags.Copyright)
                    {
                        SameCopyright = false;
                    }
                    else
                    {
                        currCopyright = f.Tags.Copyright;
                    }
                }
                set = true;
            }
            SetValues(selection);
        }
Esempio n. 16
0
 /// <summary>
 /// Determines whether the specified name has artist.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <returns><c>true</c> if the specified name has artist; otherwise, <c>false</c>.</returns>
 public bool HasArtist(string name)
 {
     return(AllArtists.Contains(name, StringComparer.OrdinalIgnoreCase));
 }
Esempio n. 17
0
 public void Add(Artist artist)
 {
     AllArtists.Add(artist);
 }