Main.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace MusicPlayer
  7. {
  8. public class Main
  9. {
  10. public APIHandler api;
  11. public MainForm form;
  12. public NetworkHandler nw;
  13. public AudioHandler audio;
  14. private SongsTable table;
  15. public Main(NetworkHandler nw, APIHandler api, MainForm form)
  16. {
  17. this.nw = nw;
  18. this.api = api;
  19. this.form = form;
  20. form.main = this;
  21. audio = new AudioHandler();
  22. table = new SongsTable();
  23. form.SongsTableView.DataSource = table;
  24. form.SongsTableView.Columns[4].Visible = false;
  25. Populate();
  26. }
  27. private void Populate()
  28. {
  29. this.api.GetAlbums().ForEach(a => form.AlbumListView.Items.Add(a.albumnaam));
  30. this.api.GetArtists().ForEach(a => form.ArtistListBox.Items.Add(a.naam));
  31. this.api.GetGenres().ForEach(g => form.GenreListBox.Items.Add(g.name));
  32. }
  33. public void ArtistFilter(string artist)
  34. {
  35. table.Clear();
  36. api.GetSongsByArtist(artist).ForEach(s =>
  37. {
  38. table.Add(s);
  39. });
  40. }
  41. public void GenreFilter(string genre)
  42. {
  43. table.Clear();
  44. api.GetSongsByGenre(genre).ForEach(s =>
  45. {
  46. table.Add(s);
  47. });
  48. }
  49. public void AlbumFilter(string album)
  50. {
  51. table.Clear();
  52. api.GetSongsByAlbum(album).ForEach(s =>
  53. {
  54. table.Add(s);
  55. });
  56. }
  57. }
  58. }