using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; namespace TJAPlayer3 { internal class RecentlyPlayedSongs { public void tRecentlyPlayedSongs() { if (!File.Exists("RecentlyPlayedSongs.json")) tSaveFile(); tLoadFile(); } #region [Auxiliary methods] public void tAddChart(string chartID) { if (!data.recentlyplayedsongs[TJAPlayer3.SaveFile].Contains(chartID)) data.recentlyplayedsongs[TJAPlayer3.SaveFile].Enqueue(chartID); while (data.recentlyplayedsongs[TJAPlayer3.SaveFile].Count > 6) // Replace the 6 by a value defined in the settings later data.recentlyplayedsongs[TJAPlayer3.SaveFile].Dequeue(); tSaveFile(); } #endregion public class Data { public Queue[] recentlyplayedsongs = new Queue[2] { new Queue(), new Queue() }; } public Data data = new Data(); #region [private] private void tSaveFile() { ConfigManager.SaveConfig(data, "RecentlyPlayedSongs.json"); } private void tLoadFile() { data = ConfigManager.GetConfig(@"RecentlyPlayedSongs.json"); } #endregion } }