Пример #1
0
        private void TrackRemoved(TrackCollection collection, TrackEventArgs e)
        {
            if (collection != Tracks)
                throw new InvalidOperationException("Album attempted to alter wrong trackcollection.");

            Artist temp = null;
            for (int i = 0; i < collection.Count; i++)
                if (temp == null)
                    temp = collection[i].Artist;
                else if (collection[i].Artist != null && collection[i].Artist != temp)
                {
                    if (Artist != null)
                        Artist.Albums.Remove(this);
                    Artist = null;
                    return;
                }

            // All track artist are the same (or null)
            if (Artist != null)
                Artist.Albums.Remove(this);

            Artist = temp;

            if (temp != null)
                Artist.Albums.Add(this);
        }
Пример #2
0
        private void TrackAdded(TrackCollection collection, TrackEventArgs e)
        {
            if (collection != Tracks)
                throw new InvalidOperationException("Album attempted to alter wrong trackcollection.");

            if (collection.Count == 1)
            {
                Artist = e.Track.Artist;
                Artist.Albums.Add(this);
            }
            //TODO: investigate maybe needed for some reason
            //else if (e.Track.Artist != null && e.Track.Artist != Artist)
            //{
            //    if (Artist != null)
            //        Artist.Albums.Remove(this);
            //    Artist = null;
            //}
        }