private ShuffleOffCollection(ISongCollection parent, IEnumerable <Song> shuffleSongs) : base(parent) { Changed += OnChanged; parent.Changed += Parent_CollectionChanged; Change(null, shuffleSongs); }
private void lbxSongs_LayoutUpdated(object sender, object e) { if (scrollTo == ScrollToType.No || lbxSongs.Items.Count == 0) { return; } ISongCollection songs = Source; if (songs == null) { scrollTo = ScrollToType.No; return; } if (lbxSongs.Items.Count < songs.Shuffle.Count) { return; } if (scrollTo == ScrollToType.Current) { lbxSongs.ScrollIntoView(CurrentSong); scrollTo = ScrollToType.No; } else { lbxSongs.ScrollIntoView(lbxSongs.Items.Last()); scrollTo = ScrollToType.Current; } }
public ShuffleCompleteCollection(ISongCollection songs, Song currentSong) : base(songs) { Change(null, GetStart(songs, currentSong)); Parent.Changed += Parent_CollectionChanged; Parent.Parent.CurrentSongChanged += Playlist_CurrentSongChanged; }
private static IShuffleCollection GetShuffleCollection(ShuffleType type, ISongCollection songs, string xmlText) { IShuffleCollection shuffle; switch (type) { case ShuffleType.Off: shuffle = new ShuffleOffCollection(songs); break; case ShuffleType.OneTime: shuffle = new ShuffleOneTimeCollection(songs); break; case ShuffleType.Path: shuffle = new ShufflePathCollection(songs); break; case ShuffleType.Complete: shuffle = new ShuffleCompleteCollection(songs); break; default: throw new NotImplementedException(); } shuffle.ReadXml(XmlConverter.GetReader(xmlText)); return(shuffle); }
protected override void OnSourceChanged(ISongCollection oldSongs, ISongCollection newSongs) { Unsubscribe(oldSongs); Subscribe(newSongs); SetItemsSource(); }
protected virtual void OnSourceChanged(ISongCollection oldSongs, ISongCollection newSongs) { Unsubscribe(oldSongs); Subscribe(newSongs); SetItemsSource(Source.Shuffle.ToArray()); }
private static void OnSourcePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { SongsView s = (SongsView)sender; ISongCollection oldSongs = e.OldValue as ISongCollection; ISongCollection newSongs = e.NewValue as ISongCollection; s.OnSourceChanged(oldSongs, newSongs); s.scrollTo = ScrollToType.Last; }
private void Unsubscribe(ISongCollection songs) { if (songs == null) { return; } songs.ShuffleChanged -= Songs_ShuffleChanged; Unsubscribe(songs.Shuffle); }
public Album(AlbumDataDto dto, IAlbumRepository albumRepository, IArtistCollection artistCollection, ISongCollection songCollection) { Id = dto.Id; Name = dto.Name; CoverArt = dto.CoverArt; _artistId = dto.ArtistId; _albumRepository = albumRepository; _artistCollection = artistCollection; _songCollection = songCollection; }
public User(UserDataDto dto, IUserRepository userRepository, ISongCollection songCollection, IAlbumCollection albumCollection, IArtistCollection artistCollection) { Id = dto.Id; Username = dto.Username; _password = dto.Password; _apiToken = dto.ApiToken; _userRepository = userRepository; _songCollection = songCollection; _albumCollection = albumCollection; _artistCollection = artistCollection; }
private void Unsubscribe(ISongCollection songs) { if (songs == null) { return; } songs.Changed -= OnSongsCollectionChanged; songs.ShuffleChanged -= OnShufflePropertyChanged; Unsubscribe(songs.AsEnumerable()); Unsubscribe(songs.Shuffle); }
private void Unsubscribe(ISongCollection songs) { if (songs == null) { return; } songs.Changed -= OnSomethingChanged; foreach (Song song in songs) { Unsubscribe(song); } }
private static IEnumerable <ChangeCollectionItem <Song> > GetStart(ISongCollection songs, Song currentSong) { List <Song> remaining = new List <Song>(songs); int shuffleCount = GetCount(songs.Count); int currentSongIndex = GetCurrentSongIndex(songs.Count); for (int i = 0; i < shuffleCount; i++) { Song addSong = i == currentSongIndex && currentSong != null ? currentSong : remaining[rnd.Next(remaining.Count)]; remaining.Remove(addSong); yield return(new ChangeCollectionItem <Song>(i, addSong)); } }
private static IEnumerable <Song> GetStart(ISongCollection songs, Song currentSong) { List <Song> remaining = new List <Song>(songs); if (currentSong != null && remaining.Remove(currentSong)) { yield return(currentSong); } while (remaining.Count > 0) { int index = ran.Next(remaining.Count); yield return(remaining[index]); remaining.RemoveAt(index); } }
public static void SetNextShuffle(this ISongCollection songs) { switch (songs.Shuffle.Type) { case ShuffleType.Off: songs.SetShuffleType(ShuffleType.Path); break; case ShuffleType.Path: songs.SetShuffleType(ShuffleType.OneTime); break; case ShuffleType.OneTime: songs.SetShuffleType(ShuffleType.Complete); break; case ShuffleType.Complete: songs.SetShuffleType(ShuffleType.Off); break; } }
public void ReadXml(XmlReader reader) { double currentSongPosition = double.Parse(reader.GetAttribute("CurrentSongPosition") ?? "0"); AbsolutePath = reader.GetAttribute("AbsolutePath") ?? emptyOrLoadingPath; Name = reader.GetAttribute("Name") ?? emptyName; Loop = (LoopType)Enum.Parse(typeof(LoopType), reader.GetAttribute("Loop") ?? LoopType.Off.ToString()); string currentSongPath = reader.GetAttribute("CurrentSongPath") ?? string.Empty;; ShuffleType shuffle = (ShuffleType)Enum.Parse(typeof(ShuffleType), reader.GetAttribute("Shuffle") ?? ShuffleType.Off.ToString()); reader.ReadStartElement(); ISongCollection songs = reader.Name == typeof(SongCollection).Name ? (ISongCollection) new SongCollection() : new SimpleSongCollection(); songs.Parent = this; Songs = XmlConverter.Deserialize(songs, reader.ReadOuterXml()); CurrentSong = songs.FirstOrDefault(s => s.Path == currentSongPath) ?? songs.FirstOrDefault(); CurrentSongPosition = currentSongPosition; }
public static IShuffleCollection GetShuffleOffCollection(this ISongCollection songs) { return(new ShuffleOffCollection(songs)); }
public ShufflePathCollection(ISongCollection parent) : this(parent, GetOrdered(parent)) { }
private ShuffleOneTimeCollection(ISongCollection parent, IEnumerable <Song> songs) : base(parent) { parent.Changed += Parent_CollectionChanged; Change(null, songs); }
private ShuffleCompleteCollection(ISongCollection songs, IEnumerable <Song> shuffleSongs) : this(songs) { Change(null, shuffleSongs.Select((s, i) => new ChangeCollectionItem <Song>(i, s))); }
public ShuffleCompleteCollection(ISongCollection songs) : base(songs) { Parent.Changed += Parent_CollectionChanged; Parent.Parent.CurrentSongChanged += Playlist_CurrentSongChanged; }
public SongsChangedEventArgs(ISongCollection oldSongs, ISongCollection newSongs) { OldSongs = oldSongs; NewSongs = newSongs; }
public ShuffleOneTimeCollection(ISongCollection parent, Song currentSong) : this(parent, GetStart(parent, currentSong)) { }
public ShuffleCollectionBase(ISongCollection parent) { list = new List <Song>(); Parent = parent; }
public SimpleShuffleCollection(ISongCollection parent, ShuffleType type) { Parent = parent; Type = type; }
public SongLikesController(ISongCollection songCollection, AuthenticatedUser authenticatedUser) { _songCollection = songCollection; _authenticatedUser = authenticatedUser; }
public SongController(ISongCollection songCollection, IAlbumCollection albumCollection, AuthenticatedUser authenticatedUser) { _songCollection = songCollection; _albumCollection = albumCollection; _authenticatedUser = authenticatedUser; }
public ShuffleOneTimeCollection(ISongCollection parent) : this(parent, Enumerable.Empty <Song>()) { }