Пример #1
0
 public void AddTrack(TrackObject trackObject)
 {
     if (!Tracks.Contains(trackObject))
     {
         Tracks.Add(trackObject);
     }
 }
Пример #2
0
 public void RemoveTrack(TrackObject trackObject)
 {
     if (Tracks.Contains(trackObject))
     {
         Tracks.Remove(trackObject);
     }
 }
Пример #3
0
        /// <summary>
        /// Удаление трека
        /// </summary>
        public void RemoveTrack(RocksmithTrack track)
        {
            if (!Tracks.Contains(track))
            {
                return;
            }

            Tracks.Remove(track);

            TrackRemoveEvent?.Invoke(new TrackEventArgs {
                Track = track
            });

            // После удаления из очереди проверяем треки, которые можно добавить из отложенных
            RocksmithTrack addTrack = DeferredTracks.FirstOrDefault(t => Tracks.Count(tt => tt.User == t.User) < userLimit);

            if (addTrack != null)
            {
                DeferredTracks.Remove(addTrack);
                Tracks.Add(addTrack);

                TrackAddEvent?.Invoke(new TrackEventArgs {
                    Track = addTrack
                });
            }

            // Сохранение очередей в файл
            Save();
        }
Пример #4
0
        public virtual void ExtendToTrack(Track fromTrack, Track toTrack, GuiLabs.Undo.ActionManager am = null)
        {
            if (Tracks.Contains(toTrack))
            {
                throw new InvalidOperationException("block is already part of track");
            }

            //Tracks.Add(toTrack);
            am.RecordAdd(Tracks, toTrack);
        }
Пример #5
0
        public virtual bool RemoveFromTrack(Track track, GuiLabs.Undo.ActionManager am = null)
        {
            if (Tracks.Count <= 1)
            {
                return(false);
            }
            if (!Tracks.Contains(track))
            {
                throw new InvalidOperationException("block is not part of track");
            }

            am.RecordRemove(Tracks, track);
            return(true);
        }
Пример #6
0
        /// <summary>Calculates the block's color at some time during the block.</summary>
        /// <param name="time">must be within range</param>
        /// <param name="track">must be contained in the block</param>
        public GloColor GetColorAtTime(float time, Track track)
        {
            // Performance optimization: only validate args in debug mode.
#if DEBUG
            if (!IsTimeInOccupiedRange(time))
            {
                throw new ArgumentOutOfRangeException(nameof(time));
            }
            if (!Tracks.Contains(track))
            {
                throw new ArgumentException("invalid track");
            }
#endif

            // Note: If ColorModifierFn becomes relevant, we could apply it generically to the result here.
            return(GetColorAtLocalTimeCore(time - StartTime, track));
        }
Пример #7
0
 /// <summary>
 /// Removes track from current playlist
 /// </summary>
 /// <param name="track"></param>
 public void RemoveTrackFromCurrentPlaylist(SoundCloudTrack track)
 {
     if (track == null)
     {
         throw new Exception("Track to remove is null. Remove track from current playlist failed.");
     }
     if (Playlist == null)
     {
         throw new Exception("Playlist is null. Remove track from current playlist failed.");
     }
     if (!Tracks.Contains(track))
     {
         throw new Exception($"There is no track with id {track.id} in current playlist. Remove track from current playlist failed.");
     }
     // Remove later when syncing with background task
     Tracks.Remove(track);
     MessageService.SendMessageToBackground(this, new DeleteTrackFromPlaybackList(track));
 }
Пример #8
0
        /// <summary>
        /// Handles track reordering
        /// </summary>
        public void ReorderTracks(SoundCloudTrack track, int indexFrom, int indexTo)
        {
            if (track == null)
            {
                throw new Exception("Track to remove is null. Reorder tracks from current playlist failed.");
            }
            if (Playlist == null)
            {
                throw new Exception("Playlist is null. Reorder tracks from current playlist failed.");
            }
            if (!Tracks.Contains(track))
            {
                throw new Exception($"There is no track with id {track.id} in current playlist. Reorder tracks from current playlist failed.");
            }
            var movedPlaylistTrack = PlaylistTrackService.GetPlaylistTrack(Playlist.id, (int)track.id);

            movedPlaylistTrack.TrackOrder = indexTo;
            PlaylistTrackService.ModifyPlaylistTrack(movedPlaylistTrack);
            if (indexTo - indexFrom > 0)
            {
                for (int i = indexFrom; i < indexTo; ++i)
                {
                    var movedTrack = PlaylistTrackService.GetPlaylistTrack(Playlist.id, (int)Tracks[i].id);
                    movedTrack.TrackOrder = i;
                    PlaylistTrackService.ModifyPlaylistTrack(movedTrack);
                }
            }
            else if (indexTo - indexFrom < 0)
            {
                for (int i = indexTo + 1; i <= indexFrom; ++i)
                {
                    var movedTrack = PlaylistTrackService.GetPlaylistTrack(Playlist.id, (int)Tracks[i].id);
                    movedTrack.TrackOrder = i;
                    PlaylistTrackService.ModifyPlaylistTrack(movedTrack);
                }
            }
        }
Пример #9
0
        public override void SaveChanges()
        {
            _context.Artists.AddOrUpdate(Artists.ToArray());
            _context.Albums.AddOrUpdate(Albums.ToArray());
            _context.Tracks.AddOrUpdate(Tracks.ToArray());

            RemoveEntities(_context.Artists, _context.Artists.AsEnumerable().Where(a => !Artists.Contains(a)));
            RemoveEntities(_context.Albums, _context.Albums.AsEnumerable().Where(a => !Albums.Contains(a)));
            RemoveEntities(_context.Tracks, _context.Tracks.AsEnumerable().Where(a => !Tracks.Contains(a)));

            _context.SaveChanges();
        }