Ejemplo n.º 1
0
        public static void RemovePlaylist(Guid targetGUID)
        {
            string configPath = Properties.Settings.Default.TrackDBPath;

            try
            {
                PlaylistCollection plc = DataControl.ReadFromJson <PlaylistCollection>(configPath, true);
                plc.TrackLists.RemoveAt(plc.TrackLists.FindIndex(x => x.GUID == targetGUID));
                DataControl.SaveData <PlaylistCollection>(configPath, plc, false, true);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public static void RemovePlaylist(string listName)
        {
            string configPath = Properties.Settings.Default.TrackDBPath;

            try
            {
                PlaylistCollection plc = DataControl.ReadFromJson <PlaylistCollection>(configPath, true);
                plc.TrackLists.Remove(plc.TrackLists.Find(x => x.ListName == listName));
                DataControl.SaveData <PlaylistCollection>(configPath, plc, false, true);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        public static void DeleteTracksByIndices(int[] indices, Guid guid)
        {
            string             configPath = Properties.Settings.Default.TrackDBPath;
            PlaylistCollection plc        = DataControl.ReadFromJson <PlaylistCollection>(configPath, true);

            if (plc == null)
            {
                throw new EmptyJsonFileException("No track can be deleted from database. Please check your config file.");
            }

            Playlist pl = plc.TrackLists.Find(x => x.GUID == guid);

            pl.DeleteTracksByIndices(indices);

            DataControl.SaveData <PlaylistCollection>(configPath, plc, false, true);
        }
Ejemplo n.º 4
0
        public static void AddPlaylist(Playlist pl)
        {
            string configPath = Properties.Settings.Default.TrackDBPath;

            try
            {
                PlaylistCollection plc = DataControl.ReadFromJson <PlaylistCollection>(configPath, true);
                plc = (plc == null) ? new PlaylistCollection() : plc;
                plc.TrackLists.Add(pl);
                DataControl.SaveData <PlaylistCollection>(configPath, plc, false, true);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 5
0
        public static Playlist GetPlaylist(string listName)
        {
            string   configPath = Properties.Settings.Default.TrackDBPath;
            Playlist pl;

            try
            {
                PlaylistCollection plc = DataControl.ReadFromJson <PlaylistCollection>(configPath, true);
                pl = (plc == null) ? null : plc.TrackLists.Find(x => x.ListName == listName);
            }
            catch
            {
                throw;
            }
            return(pl);
        }
Ejemplo n.º 6
0
        public static void AddPlaylist(List <TrackInfo> tracks, string listName)
        {
            string             configPath = Properties.Settings.Default.TrackDBPath;
            PlaylistCollection plc        = DataControl.ReadFromJson <PlaylistCollection>(configPath, true);

            if (plc == null)
            {
                Playlist pl = new Playlist(listName);
                pl.UpdateTracks(tracks);
                plc = new PlaylistCollection();
                plc.TrackLists.Add(pl);
            }
            else
            {
                Playlist pl = plc.TrackLists.Find(x => x.ListName == listName);
                pl.UpdateTracks(tracks);
            }
            DataControl.SaveData <PlaylistCollection>(configPath, plc, false, true);
        }
Ejemplo n.º 7
0
        public static string AddPlaylist(string listName)
        {
            string configPath = Properties.Settings.Default.TrackDBPath;

            try
            {
                PlaylistCollection plc = DataControl.ReadFromJson <PlaylistCollection>(configPath, true);
                plc = (plc == null) ? new PlaylistCollection() : plc;

                string   newlistName = AddSerialNum(plc.TrackLists, listName);
                Playlist pl          = new Playlist(newlistName);
                plc.TrackLists.Add(pl);
                DataControl.SaveData <PlaylistCollection>(configPath, plc, false, true);

                return(newlistName);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 8
0
        public static PlaylistCollection GetDatabase()
        {
            string configPath = Properties.Settings.Default.TrackDBPath;

            return(DataControl.ReadFromJson <PlaylistCollection>(configPath, true));
        }