Added playlist maker
This commit is contained in:
@@ -39,6 +39,18 @@ namespace MusicPlayer
|
||||
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)
|
||||
{
|
||||
table.Clear();
|
||||
@@ -57,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();
|
||||
|
||||
+64
-53
@@ -35,6 +35,7 @@
|
||||
this.AlbumListView = new System.Windows.Forms.ListView();
|
||||
this.ArtistListBox = new System.Windows.Forms.ListBox();
|
||||
this.MainPanel = new System.Windows.Forms.Panel();
|
||||
this.PlaylistListLabel = new System.Windows.Forms.Label();
|
||||
this.AlbumListLabel = new System.Windows.Forms.Label();
|
||||
this.ArtistListLabel = new System.Windows.Forms.Label();
|
||||
this.GenreListLabel = new System.Windows.Forms.Label();
|
||||
@@ -43,9 +44,14 @@
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.playlistsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.overviewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.playlistsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.playlistToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.loadToolStripMenuItem = 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();
|
||||
@@ -59,12 +65,7 @@
|
||||
this.PlayButton = new System.Windows.Forms.Button();
|
||||
this.UpdateTimer = new System.Windows.Forms.Timer(this.components);
|
||||
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
|
||||
this.PlaylistListLabel = new System.Windows.Forms.Label();
|
||||
this.playlistToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.makeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.SongsTableView)).BeginInit();
|
||||
this.MainPanel.SuspendLayout();
|
||||
this.MenuStrip.SuspendLayout();
|
||||
@@ -150,6 +151,16 @@
|
||||
this.MainPanel.Size = new System.Drawing.Size(784, 352);
|
||||
this.MainPanel.TabIndex = 5;
|
||||
//
|
||||
// PlaylistListLabel
|
||||
//
|
||||
this.PlaylistListLabel.AutoSize = true;
|
||||
this.PlaylistListLabel.Location = new System.Drawing.Point(12, 8);
|
||||
this.PlaylistListLabel.Name = "PlaylistListLabel";
|
||||
this.PlaylistListLabel.Size = new System.Drawing.Size(39, 13);
|
||||
this.PlaylistListLabel.TabIndex = 7;
|
||||
this.PlaylistListLabel.Text = "Playlist";
|
||||
this.PlaylistListLabel.Visible = false;
|
||||
//
|
||||
// AlbumListLabel
|
||||
//
|
||||
this.AlbumListLabel.AutoSize = true;
|
||||
@@ -187,6 +198,7 @@
|
||||
this.PlaylistBox.Size = new System.Drawing.Size(760, 134);
|
||||
this.PlaylistBox.TabIndex = 4;
|
||||
this.PlaylistBox.Visible = false;
|
||||
this.PlaylistBox.SelectedIndexChanged += new System.EventHandler(this.PlaylistBox_SelectedIndexChanged);
|
||||
//
|
||||
// MenuStrip
|
||||
//
|
||||
@@ -224,6 +236,18 @@
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||
this.saveToolStripMenuItem.Text = "Save";
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(100, 6);
|
||||
//
|
||||
// exitToolStripMenuItem
|
||||
//
|
||||
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
|
||||
this.exitToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
|
||||
this.exitToolStripMenuItem.Text = "Exit";
|
||||
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||
//
|
||||
// viewToolStripMenuItem
|
||||
//
|
||||
this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
@@ -233,6 +257,13 @@
|
||||
this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
|
||||
this.viewToolStripMenuItem.Text = "View";
|
||||
//
|
||||
// overviewToolStripMenuItem
|
||||
//
|
||||
this.overviewToolStripMenuItem.Name = "overviewToolStripMenuItem";
|
||||
this.overviewToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
|
||||
this.overviewToolStripMenuItem.Text = "Overview";
|
||||
this.overviewToolStripMenuItem.Click += new System.EventHandler(this.overviewToolStripMenuItem_Click);
|
||||
//
|
||||
// playlistsToolStripMenuItem
|
||||
//
|
||||
this.playlistsToolStripMenuItem.Name = "playlistsToolStripMenuItem";
|
||||
@@ -240,12 +271,27 @@
|
||||
this.playlistsToolStripMenuItem.Text = "Playlists";
|
||||
this.playlistsToolStripMenuItem.Click += new System.EventHandler(this.playlistsToolStripMenuItem_Click);
|
||||
//
|
||||
// overviewToolStripMenuItem
|
||||
// playlistToolStripMenuItem
|
||||
//
|
||||
this.overviewToolStripMenuItem.Name = "overviewToolStripMenuItem";
|
||||
this.overviewToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
|
||||
this.overviewToolStripMenuItem.Text = "Overview";
|
||||
this.overviewToolStripMenuItem.Click += new System.EventHandler(this.overviewToolStripMenuItem_Click);
|
||||
this.playlistToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.saveToolStripMenuItem1,
|
||||
this.loadToolStripMenuItem,
|
||||
this.makeToolStripMenuItem});
|
||||
this.playlistToolStripMenuItem.Name = "playlistToolStripMenuItem";
|
||||
this.playlistToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
|
||||
this.playlistToolStripMenuItem.Text = "Playlist";
|
||||
//
|
||||
// saveToolStripMenuItem1
|
||||
//
|
||||
this.saveToolStripMenuItem1.Name = "saveToolStripMenuItem1";
|
||||
this.saveToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
|
||||
this.saveToolStripMenuItem1.Text = "Save";
|
||||
//
|
||||
// loadToolStripMenuItem
|
||||
//
|
||||
this.loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
||||
this.loadToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.loadToolStripMenuItem.Text = "Load";
|
||||
//
|
||||
// ControlsPanel
|
||||
//
|
||||
@@ -373,48 +419,12 @@
|
||||
this.notifyIcon1.Visible = true;
|
||||
this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);
|
||||
//
|
||||
// PlaylistListLabel
|
||||
// makeToolStripMenuItem
|
||||
//
|
||||
this.PlaylistListLabel.AutoSize = true;
|
||||
this.PlaylistListLabel.Location = new System.Drawing.Point(12, 8);
|
||||
this.PlaylistListLabel.Name = "PlaylistListLabel";
|
||||
this.PlaylistListLabel.Size = new System.Drawing.Size(39, 13);
|
||||
this.PlaylistListLabel.TabIndex = 7;
|
||||
this.PlaylistListLabel.Text = "Playlist";
|
||||
this.PlaylistListLabel.Visible = false;
|
||||
//
|
||||
// playlistToolStripMenuItem
|
||||
//
|
||||
this.playlistToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.saveToolStripMenuItem1,
|
||||
this.loadToolStripMenuItem});
|
||||
this.playlistToolStripMenuItem.Name = "playlistToolStripMenuItem";
|
||||
this.playlistToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
|
||||
this.playlistToolStripMenuItem.Text = "Playlist";
|
||||
//
|
||||
// saveToolStripMenuItem1
|
||||
//
|
||||
this.saveToolStripMenuItem1.Name = "saveToolStripMenuItem1";
|
||||
this.saveToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
|
||||
this.saveToolStripMenuItem1.Text = "Save";
|
||||
//
|
||||
// loadToolStripMenuItem
|
||||
//
|
||||
this.loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
||||
this.loadToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.loadToolStripMenuItem.Text = "Load";
|
||||
//
|
||||
// exitToolStripMenuItem
|
||||
//
|
||||
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
|
||||
this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.exitToolStripMenuItem.Text = "Exit";
|
||||
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(149, 6);
|
||||
this.makeToolStripMenuItem.Name = "makeToolStripMenuItem";
|
||||
this.makeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.makeToolStripMenuItem.Text = "Make";
|
||||
this.makeToolStripMenuItem.Click += new System.EventHandler(this.makeToolStripMenuItem_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
@@ -481,6 +491,7 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem loadToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem makeToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,6 +98,14 @@ namespace MusicPlayer
|
||||
}
|
||||
}
|
||||
|
||||
private void PlaylistBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (PlaylistBox.SelectedItems.Count != 0)
|
||||
{
|
||||
main.PlaylistFilter(PlaylistBox.SelectedItems[0].ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void ArtistListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (ArtistListBox.SelectedItems.Count != 0)
|
||||
@@ -175,5 +183,12 @@ namespace MusicPlayer
|
||||
main.audio.AState = AudioHandler.AudioState.STOPPED;
|
||||
System.Windows.Forms.Application.Exit();
|
||||
}
|
||||
|
||||
private void makeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
new PlaylistMaker(main.pl, main.api).Show();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,12 @@
|
||||
</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" />
|
||||
@@ -88,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>
|
||||
|
||||
@@ -8,12 +8,16 @@ namespace MusicPlayer
|
||||
{
|
||||
public string name { get; }
|
||||
private string basedir;
|
||||
public List<Song> songs;
|
||||
public Playlist(string name, 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)
|
||||
@@ -21,6 +25,34 @@ namespace MusicPlayer
|
||||
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"))
|
||||
@@ -29,6 +61,7 @@ namespace MusicPlayer
|
||||
{
|
||||
stw.WriteLine(s.ToString());
|
||||
});
|
||||
stw.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,12 @@ namespace MusicPlayer
|
||||
public class PlaylistHandler
|
||||
{
|
||||
private List<Playlist> playlists;
|
||||
private APIHandler api;
|
||||
private readonly string basedir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\.mpplaylists\\";
|
||||
public PlaylistHandler()
|
||||
public PlaylistHandler(APIHandler api)
|
||||
{
|
||||
this.playlists = new List<Playlist>();
|
||||
this.api = api;
|
||||
Populate();
|
||||
}
|
||||
|
||||
@@ -22,7 +24,7 @@ namespace MusicPlayer
|
||||
{
|
||||
if (f.EndsWith(".txt"))
|
||||
{
|
||||
playlists.Add(new Playlist(Path.GetFileName(f.Replace(".txt","")) ,basedir));
|
||||
playlists.Add(new Playlist(Path.GetFileName(f.Replace(".txt","")) ,basedir, api));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -35,6 +37,21 @@ namespace MusicPlayer
|
||||
|
||||
}
|
||||
|
||||
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>
|
||||
@@ -20,7 +20,7 @@ namespace MusicPlayer
|
||||
NetworkHandler nw = new NetworkHandler("http://www.imegumii.nl");
|
||||
APIHandler api = new APIHandler(nw);
|
||||
MainForm form = new MainForm();
|
||||
PlaylistHandler pl = new PlaylistHandler();
|
||||
PlaylistHandler pl = new PlaylistHandler(api);
|
||||
new Main(nw, api, form,pl);
|
||||
|
||||
Application.Run(form);
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace MusicPlayer
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{this.SongID}|{this.Name}|{this.Album}|{this.Artist}|{this.Seconds}|{this.Genre}";
|
||||
return $"{this.SongID}|{this.Name}|{this.Album}|{this.Artist}|{this.Genre}|{this.Seconds}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user