Merge branch 'developer' into gui
Conflicts: MusicPlayer/MusicPlayer/MainForm.Designer.cs MusicPlayer/MusicPlayer/MainForm.cs
This commit is contained in:
@@ -46,6 +46,22 @@ namespace MusicPlayer
|
||||
return GetSongsByArgs("album=" + year);
|
||||
}
|
||||
|
||||
public List<Song> GetAllSongs()
|
||||
{
|
||||
List<Song> allsongslist = new List<Song>();
|
||||
JObject o = nw.SendString("getallsongs?");
|
||||
if (o["result"].ToString() == "OK")
|
||||
{
|
||||
dynamic songs = o["songs"];
|
||||
for (int i = 0; i < songs.Count; i++)
|
||||
{
|
||||
allsongslist.Add(new Song(songs[i][0].ToString(), songs[i][3].ToString(), songs[i][5].ToString(), songs[i][4].ToString(), songs[i][1].ToString(), (int)songs[i][9], this));
|
||||
}
|
||||
}
|
||||
return allsongslist;
|
||||
|
||||
}
|
||||
|
||||
public List<Song> GetSongsByArgs(string args)
|
||||
{
|
||||
List<Song> songslist = new List<Song>();
|
||||
|
||||
@@ -11,16 +11,18 @@ namespace MusicPlayer
|
||||
public APIHandler api;
|
||||
public MainForm form;
|
||||
public NetworkHandler nw;
|
||||
public PlaylistHandler pl;
|
||||
public AudioHandler audio;
|
||||
|
||||
private SongsTable table;
|
||||
|
||||
public Main(NetworkHandler nw, APIHandler api, MainForm form)
|
||||
public Main(NetworkHandler nw, APIHandler api, MainForm form, PlaylistHandler pl)
|
||||
{
|
||||
this.nw = nw;
|
||||
this.api = api;
|
||||
this.form = form;
|
||||
form.main = this;
|
||||
this.pl = pl;
|
||||
|
||||
audio = new AudioHandler();
|
||||
table = new SongsTable();
|
||||
@@ -34,6 +36,19 @@ namespace MusicPlayer
|
||||
this.api.GetAlbums().ForEach(a => form.AlbumListView.Items.Add(a.albumnaam));
|
||||
this.api.GetArtists().ForEach(a => form.ArtistListBox.Items.Add(a.naam));
|
||||
this.api.GetGenres().ForEach(g => form.GenreListBox.Items.Add(g.name));
|
||||
this.pl.GetPlaylists().ForEach(p => form.PlaylistBox.Items.Add(p.name));
|
||||
}
|
||||
|
||||
public void Repopulate()
|
||||
{
|
||||
form.AlbumListView.Items.Clear();
|
||||
form.ArtistListBox.Items.Clear();
|
||||
form.GenreListBox.Items.Clear();
|
||||
form.PlaylistBox.Items.Clear();
|
||||
this.api.GetAlbums().ForEach(a => form.AlbumListView.Items.Add(a.albumnaam));
|
||||
this.api.GetArtists().ForEach(a => form.ArtistListBox.Items.Add(a.naam));
|
||||
this.api.GetGenres().ForEach(g => form.GenreListBox.Items.Add(g.name));
|
||||
this.pl.GetPlaylists().ForEach(p => form.PlaylistBox.Items.Add(p.name));
|
||||
}
|
||||
|
||||
public void ArtistFilter(string artist)
|
||||
@@ -54,6 +69,13 @@ namespace MusicPlayer
|
||||
});
|
||||
}
|
||||
|
||||
public void PlaylistFilter(string name)
|
||||
{
|
||||
table.Clear();
|
||||
pl.GetPlaylistByName(name).GetSongs().ForEach(s => table.Add(s));
|
||||
|
||||
}
|
||||
|
||||
public void AlbumFilter(string album)
|
||||
{
|
||||
table.Clear();
|
||||
|
||||
+15
-4
@@ -51,6 +51,7 @@
|
||||
this.playlistToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.makeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ControlsPanel = new System.Windows.Forms.Panel();
|
||||
this.CurrentSongLabel = new System.Windows.Forms.Label();
|
||||
this.SeperatorLabel = new System.Windows.Forms.Label();
|
||||
@@ -195,6 +196,7 @@
|
||||
this.PlaylistBox.Size = new System.Drawing.Size(760, 131);
|
||||
this.PlaylistBox.TabIndex = 4;
|
||||
this.PlaylistBox.Visible = false;
|
||||
this.PlaylistBox.SelectedIndexChanged += new System.EventHandler(this.PlaylistBox_SelectedIndexChanged);
|
||||
//
|
||||
// PlaylistListLabel
|
||||
//
|
||||
@@ -294,7 +296,8 @@
|
||||
//
|
||||
this.playlistToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.saveToolStripMenuItem1,
|
||||
this.loadToolStripMenuItem});
|
||||
this.loadToolStripMenuItem,
|
||||
this.makeToolStripMenuItem});
|
||||
this.playlistToolStripMenuItem.Name = "playlistToolStripMenuItem";
|
||||
this.playlistToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
|
||||
this.playlistToolStripMenuItem.Text = "Playlist";
|
||||
@@ -302,15 +305,22 @@
|
||||
// saveToolStripMenuItem1
|
||||
//
|
||||
this.saveToolStripMenuItem1.Name = "saveToolStripMenuItem1";
|
||||
this.saveToolStripMenuItem1.Size = new System.Drawing.Size(100, 22);
|
||||
this.saveToolStripMenuItem1.Size = new System.Drawing.Size(103, 22);
|
||||
this.saveToolStripMenuItem1.Text = "Save";
|
||||
//
|
||||
// loadToolStripMenuItem
|
||||
//
|
||||
this.loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
||||
this.loadToolStripMenuItem.Size = new System.Drawing.Size(100, 22);
|
||||
this.loadToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||
this.loadToolStripMenuItem.Text = "Load";
|
||||
//
|
||||
// makeToolStripMenuItem
|
||||
//
|
||||
this.makeToolStripMenuItem.Name = "makeToolStripMenuItem";
|
||||
this.makeToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||
this.makeToolStripMenuItem.Text = "Make";
|
||||
this.makeToolStripMenuItem.Click += new System.EventHandler(this.makeToolStripMenuItem_Click);
|
||||
//
|
||||
// ControlsPanel
|
||||
//
|
||||
this.ControlsPanel.BackColor = System.Drawing.SystemColors.WindowFrame;
|
||||
@@ -558,7 +568,7 @@
|
||||
private System.Windows.Forms.Label GenreListLabel;
|
||||
private System.Windows.Forms.ToolStripMenuItem playlistsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem overviewToolStripMenuItem;
|
||||
private System.Windows.Forms.ListBox PlaylistBox;
|
||||
public System.Windows.Forms.ListBox PlaylistBox;
|
||||
private System.Windows.Forms.Label PlaylistListLabel;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem playlistToolStripMenuItem;
|
||||
@@ -573,6 +583,7 @@
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
||||
private System.Windows.Forms.ToolStripMenuItem NotifyMenuStripPlayingSongLabel;
|
||||
private System.Windows.Forms.SplitContainer SplitContainer;
|
||||
private System.Windows.Forms.ToolStripMenuItem makeToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,6 +147,18 @@ namespace MusicPlayer
|
||||
{
|
||||
main.GenreFilter(GenreListBox.SelectedItems[0].ToString());
|
||||
ArtistListBox.ClearSelected();
|
||||
PlaylistBox.ClearSelected();
|
||||
AlbumListView.SelectedIndices.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void PlaylistBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (PlaylistBox.SelectedItems.Count != 0)
|
||||
{
|
||||
main.PlaylistFilter(PlaylistBox.SelectedItems[0].ToString());
|
||||
GenreListBox.ClearSelected();
|
||||
ArtistListBox.ClearSelected();
|
||||
AlbumListView.SelectedIndices.Clear();
|
||||
}
|
||||
}
|
||||
@@ -157,6 +169,7 @@ namespace MusicPlayer
|
||||
{
|
||||
main.ArtistFilter(ArtistListBox.SelectedItems[0].ToString());
|
||||
GenreListBox.ClearSelected();
|
||||
PlaylistBox.ClearSelected();
|
||||
AlbumListView.SelectedIndices.Clear();
|
||||
}
|
||||
}
|
||||
@@ -166,6 +179,7 @@ namespace MusicPlayer
|
||||
if (AlbumListView.SelectedItems.Count != 0)
|
||||
{
|
||||
main.AlbumFilter(AlbumListView.SelectedItems[0].Text);
|
||||
PlaylistBox.ClearSelected();
|
||||
ArtistListBox.ClearSelected();
|
||||
GenreListBox.ClearSelected();
|
||||
}
|
||||
@@ -264,5 +278,12 @@ namespace MusicPlayer
|
||||
{
|
||||
StopButton_Click(sender, e);
|
||||
}
|
||||
|
||||
private void makeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
new PlaylistMaker(main.pl, main.api).Show();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,14 @@
|
||||
<Compile Include="NotificationPopup.Designer.cs">
|
||||
<DependentUpon>NotificationPopup.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Playlist.cs" />
|
||||
<Compile Include="PlaylistHandler.cs" />
|
||||
<Compile Include="PlaylistMaker.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="PlaylistMaker.Designer.cs">
|
||||
<DependentUpon>PlaylistMaker.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Song.cs" />
|
||||
@@ -86,6 +94,9 @@
|
||||
<EmbeddedResource Include="NotificationPopup.resx">
|
||||
<DependentUpon>NotificationPopup.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="PlaylistMaker.resx">
|
||||
<DependentUpon>PlaylistMaker.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
public class Playlist
|
||||
{
|
||||
public string name { get; }
|
||||
private string basedir;
|
||||
public List<Song> songs;
|
||||
|
||||
private APIHandler api;
|
||||
public Playlist(string name, string basedir, APIHandler api)
|
||||
{
|
||||
this.songs = new List<Song>();
|
||||
this.name = name;
|
||||
this.api = api;
|
||||
this.basedir = basedir;
|
||||
this.ReadFromFile();
|
||||
}
|
||||
|
||||
public void AddSong(Song s)
|
||||
{
|
||||
this.songs.Add(s);
|
||||
}
|
||||
|
||||
public List<Song> GetSongs()
|
||||
{
|
||||
return songs;
|
||||
}
|
||||
|
||||
public void ReadFromFile()
|
||||
{
|
||||
try {
|
||||
using (StreamReader str = new StreamReader(basedir + name + ".txt"))
|
||||
{
|
||||
string readline;
|
||||
while ((readline = str.ReadLine()) != null)
|
||||
{
|
||||
string[] songsvalues = readline.Split('|');
|
||||
|
||||
songs.Add(new Song(songsvalues[0], songsvalues[1], songsvalues[2], songsvalues[3], songsvalues[4], Int32.Parse(songsvalues[5]), api));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
FileStream fs = new FileStream(basedir + name + ".txt", FileMode.CreateNew);
|
||||
fs.Close();
|
||||
ReadFromFile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void WriteToFile()
|
||||
{
|
||||
using (StreamWriter stw = new StreamWriter(basedir + name + ".txt"))
|
||||
{
|
||||
this.songs.ForEach(s =>
|
||||
{
|
||||
stw.WriteLine(s.ToString());
|
||||
});
|
||||
stw.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
public class PlaylistHandler
|
||||
{
|
||||
private List<Playlist> playlists;
|
||||
private APIHandler api;
|
||||
private readonly string basedir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\.mpplaylists\\";
|
||||
public PlaylistHandler(APIHandler api)
|
||||
{
|
||||
this.playlists = new List<Playlist>();
|
||||
this.api = api;
|
||||
Populate();
|
||||
}
|
||||
|
||||
private void Populate()
|
||||
{
|
||||
try {
|
||||
Directory.GetFiles(basedir).ToList().ForEach(f =>
|
||||
{
|
||||
if (f.EndsWith(".txt"))
|
||||
{
|
||||
playlists.Add(new Playlist(Path.GetFileName(f.Replace(".txt","")) ,basedir, api));
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
Directory.CreateDirectory(basedir);
|
||||
Populate();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void MakeNewPlaylistByName(string name)
|
||||
{
|
||||
playlists.Add(new Playlist(name, basedir, api));
|
||||
}
|
||||
|
||||
public Playlist GetPlaylistByName(string name)
|
||||
{
|
||||
Playlist toFind = null;
|
||||
playlists.ForEach(p =>
|
||||
{
|
||||
if (p.name == name) { toFind = p; }
|
||||
});
|
||||
return toFind;
|
||||
}
|
||||
|
||||
public List<Playlist> GetPlaylists()
|
||||
{
|
||||
return playlists;
|
||||
}
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
partial class PlaylistMaker
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.PlaylistSelectBox = new System.Windows.Forms.ComboBox();
|
||||
this.PlaylistSongSelector = new System.Windows.Forms.ListBox();
|
||||
this.PlaylistAddSongsButton = new System.Windows.Forms.Button();
|
||||
this.PlaylistSongContainer = new System.Windows.Forms.ListBox();
|
||||
this.PlaylistNewButton = new System.Windows.Forms.Button();
|
||||
this.PlaylistNewInputfield = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// PlaylistSelectBox
|
||||
//
|
||||
this.PlaylistSelectBox.FormattingEnabled = true;
|
||||
this.PlaylistSelectBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.PlaylistSelectBox.Name = "PlaylistSelectBox";
|
||||
this.PlaylistSelectBox.Size = new System.Drawing.Size(354, 21);
|
||||
this.PlaylistSelectBox.TabIndex = 0;
|
||||
this.PlaylistSelectBox.SelectedIndexChanged += new System.EventHandler(this.PlaylistSelectBox_SelectedIndexChanged);
|
||||
//
|
||||
// PlaylistSongSelector
|
||||
//
|
||||
this.PlaylistSongSelector.FormattingEnabled = true;
|
||||
this.PlaylistSongSelector.Location = new System.Drawing.Point(13, 39);
|
||||
this.PlaylistSongSelector.Name = "PlaylistSongSelector";
|
||||
this.PlaylistSongSelector.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
|
||||
this.PlaylistSongSelector.Size = new System.Drawing.Size(353, 160);
|
||||
this.PlaylistSongSelector.TabIndex = 1;
|
||||
//
|
||||
// PlaylistAddSongsButton
|
||||
//
|
||||
this.PlaylistAddSongsButton.Location = new System.Drawing.Point(12, 293);
|
||||
this.PlaylistAddSongsButton.Name = "PlaylistAddSongsButton";
|
||||
this.PlaylistAddSongsButton.Size = new System.Drawing.Size(354, 23);
|
||||
this.PlaylistAddSongsButton.TabIndex = 2;
|
||||
this.PlaylistAddSongsButton.Text = "Add";
|
||||
this.PlaylistAddSongsButton.UseVisualStyleBackColor = true;
|
||||
this.PlaylistAddSongsButton.Click += new System.EventHandler(this.PlaylistAddSongsButton_Click);
|
||||
//
|
||||
// PlaylistSongContainer
|
||||
//
|
||||
this.PlaylistSongContainer.FormattingEnabled = true;
|
||||
this.PlaylistSongContainer.Location = new System.Drawing.Point(12, 205);
|
||||
this.PlaylistSongContainer.Name = "PlaylistSongContainer";
|
||||
this.PlaylistSongContainer.Size = new System.Drawing.Size(354, 82);
|
||||
this.PlaylistSongContainer.TabIndex = 3;
|
||||
//
|
||||
// PlaylistNewButton
|
||||
//
|
||||
this.PlaylistNewButton.Location = new System.Drawing.Point(118, 342);
|
||||
this.PlaylistNewButton.Name = "PlaylistNewButton";
|
||||
this.PlaylistNewButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.PlaylistNewButton.TabIndex = 4;
|
||||
this.PlaylistNewButton.Text = "New";
|
||||
this.PlaylistNewButton.UseVisualStyleBackColor = true;
|
||||
this.PlaylistNewButton.Click += new System.EventHandler(this.PlaylistNewButton_Click);
|
||||
//
|
||||
// PlaylistNewInputfield
|
||||
//
|
||||
this.PlaylistNewInputfield.Location = new System.Drawing.Point(12, 342);
|
||||
this.PlaylistNewInputfield.Name = "PlaylistNewInputfield";
|
||||
this.PlaylistNewInputfield.Size = new System.Drawing.Size(100, 20);
|
||||
this.PlaylistNewInputfield.TabIndex = 5;
|
||||
//
|
||||
// PlaylistMaker
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(382, 400);
|
||||
this.Controls.Add(this.PlaylistNewInputfield);
|
||||
this.Controls.Add(this.PlaylistNewButton);
|
||||
this.Controls.Add(this.PlaylistSongContainer);
|
||||
this.Controls.Add(this.PlaylistAddSongsButton);
|
||||
this.Controls.Add(this.PlaylistSongSelector);
|
||||
this.Controls.Add(this.PlaylistSelectBox);
|
||||
this.Name = "PlaylistMaker";
|
||||
this.Text = "PlaylistMaker";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ComboBox PlaylistSelectBox;
|
||||
private System.Windows.Forms.ListBox PlaylistSongSelector;
|
||||
private System.Windows.Forms.Button PlaylistAddSongsButton;
|
||||
private System.Windows.Forms.ListBox PlaylistSongContainer;
|
||||
private Button PlaylistNewButton;
|
||||
private TextBox PlaylistNewInputfield;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
public partial class PlaylistMaker : Form
|
||||
{
|
||||
private PlaylistHandler pl;
|
||||
private APIHandler api;
|
||||
|
||||
private List<Song> allPlaylistSongs;
|
||||
private List<Song> allsongs;
|
||||
|
||||
public PlaylistMaker(PlaylistHandler pl, APIHandler api)
|
||||
{
|
||||
this.pl = pl;
|
||||
this.api = api;
|
||||
this.allPlaylistSongs = new List<Song>();
|
||||
this.allsongs = new List<Song>();
|
||||
InitializeComponent();
|
||||
Populate();
|
||||
}
|
||||
|
||||
public void PlaylistSelectBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (PlaylistSelectBox.SelectedItem != null)
|
||||
{
|
||||
PlaylistSongContainer.Items.Clear();
|
||||
allPlaylistSongs = pl.GetPlaylistByName(PlaylistSelectBox.SelectedItem.ToString()).GetSongs();
|
||||
allPlaylistSongs.ForEach(s => PlaylistSongContainer.Items.Add(s.Name));
|
||||
}
|
||||
}
|
||||
|
||||
public void Repopulate()
|
||||
{
|
||||
PlaylistSelectBox.Items.Clear();
|
||||
pl.GetPlaylists().ForEach(p => PlaylistSelectBox.Items.Add(p.name));
|
||||
if (PlaylistSelectBox.SelectedItem != null)
|
||||
{
|
||||
PlaylistSongContainer.Items.Clear();
|
||||
allPlaylistSongs = pl.GetPlaylistByName(PlaylistSelectBox.SelectedItem.ToString()).GetSongs();
|
||||
allPlaylistSongs.ForEach(s => PlaylistSongContainer.Items.Add(s.Name));
|
||||
}
|
||||
}
|
||||
|
||||
public void Populate()
|
||||
{
|
||||
pl.GetPlaylists().ForEach(p => PlaylistSelectBox.Items.Add(p.name));
|
||||
allsongs = api.GetAllSongs();
|
||||
allsongs.ForEach(s => PlaylistSongSelector.Items.Add(s.Name));
|
||||
}
|
||||
|
||||
private void PlaylistAddSongsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (PlaylistSelectBox.SelectedItem!=null)
|
||||
{
|
||||
Playlist currentPlaylist = pl.GetPlaylistByName(PlaylistSelectBox.SelectedItem.ToString());
|
||||
foreach (string song in PlaylistSongSelector.SelectedItems)
|
||||
{
|
||||
foreach (Song s in allsongs) {
|
||||
if (s.Name == song)
|
||||
{
|
||||
currentPlaylist.AddSong(s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
currentPlaylist.WriteToFile();
|
||||
}
|
||||
Repopulate();
|
||||
}
|
||||
|
||||
private void PlaylistNewButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
pl.MakeNewPlaylistByName(PlaylistNewInputfield.Text);
|
||||
Repopulate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -19,24 +19,9 @@ namespace MusicPlayer
|
||||
|
||||
NetworkHandler nw = new NetworkHandler("http://www.imegumii.nl");
|
||||
APIHandler api = new APIHandler(nw);
|
||||
// api.GetSongsByArtist("Amon Amarth").ForEach(s =>
|
||||
// {
|
||||
// Console.WriteLine(s.SongID);
|
||||
// });
|
||||
// api.GetSongsByYear("2009").ForEach(s =>
|
||||
// {
|
||||
// Console.WriteLine(s.Name);
|
||||
// });
|
||||
// api.GetSongsByGenre("Melodic Death Metal").ForEach(s =>
|
||||
// {
|
||||
// Console.WriteLine(s.Name);
|
||||
// });
|
||||
// api.GetSongsByAlbum("Stronger").ForEach(s =>
|
||||
// {
|
||||
// Console.WriteLine(s.Name);
|
||||
// });
|
||||
MainForm form = new MainForm();
|
||||
new Main(nw, api, form);
|
||||
PlaylistHandler pl = new PlaylistHandler(api);
|
||||
new Main(nw, api, form,pl);
|
||||
|
||||
Application.Run(form);
|
||||
}
|
||||
|
||||
@@ -48,5 +48,10 @@ namespace MusicPlayer
|
||||
{
|
||||
url = str;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.SongID}|{this.Name}|{this.Album}|{this.Artist}|{this.Genre}|{this.Seconds}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user