Ejemplo n.º 1
0
        public static Playlist MakePlaylist(string path, Library library, Settings settings)
        {
            try
            {
                using (var sr = new StreamReader(path))
                {
                    string type = sr.ReadLine();

                    switch (type)
                    {
                        case "Playlist":
                            return new Playlist(sr, library);
                        case "ShuffleQueue":
                            return new ShuffleQueue(sr, library, settings);
                        case "FilterPlaylist":
                            return new FilterPlaylist(sr, library);
                        default:
                            return null;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                return null;
            }
        }
Ejemplo n.º 2
0
        public MainForm()
        {
            library = Library.Load();
            if (library == null)
            {
                library = new Library();
                library.Save();
            }
            library.Changed += library_LibraryChanged;

            settings = Settings.Load(SettingsPath) ?? new Settings();

            musicPlayer.OpenCompleted += equalizerSettings_ShouldSet;
            musicPlayer.OpenCompleted += musicPlayer_ShouldPlay;
            musicPlayer.DeviceVolume = settings.DeviceVolume;

            equalizerSettings = EqualizerSettings.Load(EqualizerPath);
            if (equalizerSettings == null)
            {
                equalizerSettings = new EqualizerSettings();
                equalizerSettings.Save(EqualizerPath);
            }
            equalizerSettings.ValueChanged += equalizerSettings_ShouldSet;

            SetUpGlobalHotkeys();

            lfmHandler = new LastfmHandler();
            if (settings.ScrobblingEnabled)
                lfmHandler.ResumeSessionAsync();

            InitializeComponent();
            SetControlReferences();
        }
Ejemplo n.º 3
0
        public Playlist(Library library, string name, List<Song> songs)
        {
            this.Name = name;
            this.songs = songs;

            Init(library);
        }
Ejemplo n.º 4
0
        public static Library CreateLibrary()
        {
            Library lib = new Library();

            AddSongsToLibrary(lib);

            return lib;
        }
Ejemplo n.º 5
0
        public FilterPlaylist(Library library, string name, List<Filter> filters)
            : base(library, name)
        {
            this.library = library;

            Filters = filters ?? new List<Filter>();

            FilterLibrary();
        }
Ejemplo n.º 6
0
        public void LibraryCreate()
        {
            int numSongsExpected = 0;
            string nameExpected = "Library";

            Library lib = new Library();

            Assert.AreEqual(lib.NumSongs, numSongsExpected);
            Assert.AreEqual(lib.Name, nameExpected);
        }
Ejemplo n.º 7
0
        private void AddSongsToLibrary(Library lib)
        {
            var song = new Song(@"Songs\empty10sec.mp3");
            song.Rating = 3;
            lib.Add(song);

            song = new Song(@"Songs\empty10sec2.mp3");
            song.Rating = 1;
            lib.Add(song);
        }
Ejemplo n.º 8
0
        public SongPropertiesWindow(MainForm mainForm, Song song, int clickedIndex, PlaylistBase currentPlaylist, Library library)
        {
            this.mainForm = mainForm;
            this.song = song;
            this.currentIndex = clickedIndex;
            this.currentPlaylist = currentPlaylist;
            this.library = library;

            InitializeComponent();
        }
Ejemplo n.º 9
0
        public MultiSongPropertiesWindow(MainForm mainForm, List<Song> songs, PlaylistBase currentPlaylist, Library library)
        {
            this.mainForm = mainForm;
            this.songs = songs;
            this.currentPlaylist = currentPlaylist;
            this.library = library;
            this.saveProperties = new Dictionary<string, bool>();
            InitializeComponent();

            save_ComboBox.SelectedIndex = 0;
            for (int i = 2; i < save_ComboBox.Items.Count; i++)
                this.saveProperties.Add(save_ComboBox.Items[i].ToString(), false);
        }
Ejemplo n.º 10
0
        public FilterPlaylist(StreamReader sr, Library library)
        {
            this.library = library;
            Filters = new List<Filter>();

            ReadHeader(sr);

            ResetSortVariables();
            songs = new List<Song>();
            this.sortDictionaries = new List<Dictionary<string, List<Song>>>();

            FilterLibrary();
            Sorting.CreateSortDictionaries(songs, this.sortDictionaries);
        }
Ejemplo n.º 11
0
        public void LibrarySave()
        {
            Library lib = new Library();
            lib.Add(new Song(@"Songs\empty10sec.mp3"));

            try
            {
                lib.Save();
            }
            catch
            {
                Assert.Fail();
            }
        }
Ejemplo n.º 12
0
        public Playlist(StreamReader sr, Library library)
        {
            ReadHeader(sr);

            var paths = new List<string>();
            string current;
            while ((current = sr.ReadLine()) != null)
                paths.Add(current);

            songs = new List<Song>();
            foreach (string path in paths)
                songs.Add(library.PathDictionary[path]);

            Init(library);
        }
Ejemplo n.º 13
0
 public ShuffleQueue(StreamReader sr, Library library, Settings settings)
     : base(sr, library)
 {
     this.library = library;
     this.Settings = settings;
 }
Ejemplo n.º 14
0
 public SearchResult(Library library)
     : base(library, "Search Results")
 {
     this.library = library;
 }
Ejemplo n.º 15
0
 public FilterPlaylist(Library library, string name)
     : this(library, name, null)
 {
     this.library = library;
     Filters = new List<Filter>();
 }
Ejemplo n.º 16
0
 public Playlist(Library library)
     : this(library, "PlaylistName")
 {
 }
Ejemplo n.º 17
0
        private static void AddSongsToLibrary(Library lib)
        {
            var song = new Song(@"Songs\empty10sec.mp3");
            song.Rating = 3;
            song.DateAdded = DateTime.Now.AddDays(-1);
            lib.Add(song);

            song = new Song(@"Songs\empty10sec2.mp3");
            song.DateAdded = DateTime.Now.AddDays(-8);
            lib.Add(song);

            song = new Song(@"Songs\empty10sec3.mp3");
            song.DateAdded = DateTime.Now.AddMonths(-3);
            song.Rating = 5;
            lib.Add(song);
        }
Ejemplo n.º 18
0
 public ShuffleQueue(Library library, Settings settings)
     : base(library, "Shuffle Queue")
 {
     Settings = settings;
     this.library = library;
 }
Ejemplo n.º 19
0
 private Library SetupLibrary()
 {
     var lib = new Library();
     AddSongsToLibrary(lib);
     return lib;
 }
Ejemplo n.º 20
0
        protected void Init(Library library)
        {
            this.libraryDictionary = library.PathDictionary;
            library.Changed += library_LibraryChanged;

            ResetSortVariables();

            this.sortDictionaries = new List<Dictionary<string, List<Song>>>();
            Sorting.CreateSortDictionaries(this.songs, this.sortDictionaries);
        }
Ejemplo n.º 21
0
 public Playlist(Library library, string name)
     : this(library, name, new List<Song>())
 {
 }
Ejemplo n.º 22
0
        public void FilterPlaylistLibraryChange()
        {
            var lib = new Library();

            var fpl = new FilterPlaylist(lib, "fpl 4");

            fpl.Filters.Add(new StringFilter("genre", "noise", true));

            fpl.FilterLibrary();

            Assert.AreEqual(0, fpl.NumSongs);

            AddSongsToLibrary(lib);
            lib.Changed += (s, e) => { };
            fpl.FilterLibrary();
            Assert.AreEqual(2, fpl.NumSongs);
        }
Ejemplo n.º 23
0
 public ShuffleQueue(Library library, Settings settings, List<Song> songs)
     : base(library, "Shuffle Queue", songs)
 {
     Settings = settings;
     this.library = library;
 }