private void OnSongsCollectionChanged(object sender, SongCollectionChangedEventArgs e) { MobileDebug.Service.WriteEvent("PlaylistSubscribtionHandler.OnSongsCollectionChanged", (sender as ISongCollection)?.Parent?.Name); Unsubscribe(e.GetRemoved()); Subscribe(e.GetAdded()); SongCollectionChanged?.Invoke(this, new SubscriptionsEventArgs <ISongCollection, SongCollectionChangedEventArgs>(sender, e)); }
private void Parent_CollectionChanged(object sender, SongCollectionChangedEventArgs e) { List <ChangeCollectionItem <Song> > adds = new List <ChangeCollectionItem <Song> >(); foreach (Song addSong in e.GetAdded()) { int index = ran.Next(Count - e.RemovedSongs.Length + adds.Count); adds.Add(new ChangeCollectionItem <Song>(index, addSong)); } Change(e.GetRemoved(), adds); }
private void Parent_CollectionChanged(object sender, SongCollectionChangedEventArgs e) { Song[] ordered = GetOrdered(Parent).ToArray(); Change(e.GetRemoved(), e.GetAdded().Select(s => new ChangeCollectionItem <Song>(Array.IndexOf(ordered, s), s))); }