Redesigned and fixed Playlist Maker

This commit is contained in:
2015-10-30 23:57:02 +01:00
parent d31519aeca
commit d5bc7df7e1
3 changed files with 80 additions and 15 deletions
+2 -2
View File
@@ -317,8 +317,8 @@
// makeToolStripMenuItem // makeToolStripMenuItem
// //
this.makeToolStripMenuItem.Name = "makeToolStripMenuItem"; this.makeToolStripMenuItem.Name = "makeToolStripMenuItem";
this.makeToolStripMenuItem.Size = new System.Drawing.Size(103, 22); this.makeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.makeToolStripMenuItem.Text = "Make"; this.makeToolStripMenuItem.Text = "Create / Edit";
this.makeToolStripMenuItem.Click += new System.EventHandler(this.makeToolStripMenuItem_Click); this.makeToolStripMenuItem.Click += new System.EventHandler(this.makeToolStripMenuItem_Click);
// //
// ControlsPanel // ControlsPanel
+60 -11
View File
@@ -36,12 +36,16 @@ namespace MusicPlayer
this.PlaylistSongContainer = new System.Windows.Forms.ListBox(); this.PlaylistSongContainer = new System.Windows.Forms.ListBox();
this.PlaylistNewButton = new System.Windows.Forms.Button(); this.PlaylistNewButton = new System.Windows.Forms.Button();
this.PlaylistNewInputfield = new System.Windows.Forms.TextBox(); this.PlaylistNewInputfield = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// PlaylistSelectBox // PlaylistSelectBox
// //
this.PlaylistSelectBox.FormattingEnabled = true; this.PlaylistSelectBox.FormattingEnabled = true;
this.PlaylistSelectBox.Location = new System.Drawing.Point(12, 12); this.PlaylistSelectBox.Location = new System.Drawing.Point(10, 96);
this.PlaylistSelectBox.Name = "PlaylistSelectBox"; this.PlaylistSelectBox.Name = "PlaylistSelectBox";
this.PlaylistSelectBox.Size = new System.Drawing.Size(354, 21); this.PlaylistSelectBox.Size = new System.Drawing.Size(354, 21);
this.PlaylistSelectBox.TabIndex = 0; this.PlaylistSelectBox.TabIndex = 0;
@@ -50,33 +54,33 @@ namespace MusicPlayer
// PlaylistSongSelector // PlaylistSongSelector
// //
this.PlaylistSongSelector.FormattingEnabled = true; this.PlaylistSongSelector.FormattingEnabled = true;
this.PlaylistSongSelector.Location = new System.Drawing.Point(13, 39); this.PlaylistSongSelector.Location = new System.Drawing.Point(11, 149);
this.PlaylistSongSelector.Name = "PlaylistSongSelector"; this.PlaylistSongSelector.Name = "PlaylistSongSelector";
this.PlaylistSongSelector.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; this.PlaylistSongSelector.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
this.PlaylistSongSelector.Size = new System.Drawing.Size(353, 160); this.PlaylistSongSelector.Size = new System.Drawing.Size(353, 121);
this.PlaylistSongSelector.TabIndex = 1; this.PlaylistSongSelector.TabIndex = 1;
// //
// PlaylistAddSongsButton // PlaylistAddSongsButton
// //
this.PlaylistAddSongsButton.Location = new System.Drawing.Point(12, 293); this.PlaylistAddSongsButton.Location = new System.Drawing.Point(10, 276);
this.PlaylistAddSongsButton.Name = "PlaylistAddSongsButton"; this.PlaylistAddSongsButton.Name = "PlaylistAddSongsButton";
this.PlaylistAddSongsButton.Size = new System.Drawing.Size(354, 23); this.PlaylistAddSongsButton.Size = new System.Drawing.Size(354, 23);
this.PlaylistAddSongsButton.TabIndex = 2; this.PlaylistAddSongsButton.TabIndex = 2;
this.PlaylistAddSongsButton.Text = "Add"; this.PlaylistAddSongsButton.Text = "Add selected to playlist";
this.PlaylistAddSongsButton.UseVisualStyleBackColor = true; this.PlaylistAddSongsButton.UseVisualStyleBackColor = true;
this.PlaylistAddSongsButton.Click += new System.EventHandler(this.PlaylistAddSongsButton_Click); this.PlaylistAddSongsButton.Click += new System.EventHandler(this.PlaylistAddSongsButton_Click);
// //
// PlaylistSongContainer // PlaylistSongContainer
// //
this.PlaylistSongContainer.FormattingEnabled = true; this.PlaylistSongContainer.FormattingEnabled = true;
this.PlaylistSongContainer.Location = new System.Drawing.Point(12, 205); this.PlaylistSongContainer.Location = new System.Drawing.Point(10, 327);
this.PlaylistSongContainer.Name = "PlaylistSongContainer"; this.PlaylistSongContainer.Name = "PlaylistSongContainer";
this.PlaylistSongContainer.Size = new System.Drawing.Size(354, 82); this.PlaylistSongContainer.Size = new System.Drawing.Size(354, 82);
this.PlaylistSongContainer.TabIndex = 3; this.PlaylistSongContainer.TabIndex = 3;
// //
// PlaylistNewButton // PlaylistNewButton
// //
this.PlaylistNewButton.Location = new System.Drawing.Point(118, 342); this.PlaylistNewButton.Location = new System.Drawing.Point(290, 23);
this.PlaylistNewButton.Name = "PlaylistNewButton"; this.PlaylistNewButton.Name = "PlaylistNewButton";
this.PlaylistNewButton.Size = new System.Drawing.Size(75, 23); this.PlaylistNewButton.Size = new System.Drawing.Size(75, 23);
this.PlaylistNewButton.TabIndex = 4; this.PlaylistNewButton.TabIndex = 4;
@@ -86,16 +90,56 @@ namespace MusicPlayer
// //
// PlaylistNewInputfield // PlaylistNewInputfield
// //
this.PlaylistNewInputfield.Location = new System.Drawing.Point(12, 342); this.PlaylistNewInputfield.Location = new System.Drawing.Point(11, 25);
this.PlaylistNewInputfield.Name = "PlaylistNewInputfield"; this.PlaylistNewInputfield.Name = "PlaylistNewInputfield";
this.PlaylistNewInputfield.Size = new System.Drawing.Size(100, 20); this.PlaylistNewInputfield.Size = new System.Drawing.Size(273, 20);
this.PlaylistNewInputfield.TabIndex = 5; this.PlaylistNewInputfield.TabIndex = 5;
// //
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(95, 13);
this.label1.TabIndex = 6;
this.label1.Text = "Create new playlist";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(10, 80);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(97, 13);
this.label2.TabIndex = 7;
this.label2.Text = "Edit existing playlist";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(7, 311);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(82, 13);
this.label3.TabIndex = 8;
this.label3.Text = "Songs in playlist";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(11, 130);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(49, 13);
this.label4.TabIndex = 9;
this.label4.Text = "All songs";
//
// PlaylistMaker // PlaylistMaker
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(382, 400); this.ClientSize = new System.Drawing.Size(382, 419);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.PlaylistNewInputfield); this.Controls.Add(this.PlaylistNewInputfield);
this.Controls.Add(this.PlaylistNewButton); this.Controls.Add(this.PlaylistNewButton);
this.Controls.Add(this.PlaylistSongContainer); this.Controls.Add(this.PlaylistSongContainer);
@@ -103,7 +147,8 @@ namespace MusicPlayer
this.Controls.Add(this.PlaylistSongSelector); this.Controls.Add(this.PlaylistSongSelector);
this.Controls.Add(this.PlaylistSelectBox); this.Controls.Add(this.PlaylistSelectBox);
this.Name = "PlaylistMaker"; this.Name = "PlaylistMaker";
this.Text = "PlaylistMaker"; this.Text = "Create / Edit playlists";
this.Shown += new System.EventHandler(this.PlaylistMaker_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -117,5 +162,9 @@ namespace MusicPlayer
private System.Windows.Forms.ListBox PlaylistSongContainer; private System.Windows.Forms.ListBox PlaylistSongContainer;
private Button PlaylistNewButton; private Button PlaylistNewButton;
private TextBox PlaylistNewInputfield; private TextBox PlaylistNewInputfield;
private Label label1;
private Label label2;
private Label label3;
private Label label4;
} }
} }
+18 -2
View File
@@ -5,6 +5,7 @@ using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
@@ -25,7 +26,6 @@ namespace MusicPlayer
this.allPlaylistSongs = new List<Song>(); this.allPlaylistSongs = new List<Song>();
this.allsongs = new List<Song>(); this.allsongs = new List<Song>();
InitializeComponent(); InitializeComponent();
Populate();
} }
public void PlaylistSelectBox_SelectedIndexChanged(object sender, EventArgs e) public void PlaylistSelectBox_SelectedIndexChanged(object sender, EventArgs e)
@@ -40,8 +40,10 @@ namespace MusicPlayer
public void Repopulate() public void Repopulate()
{ {
PlaylistSelectBox.Items.Clear(); int selection = PlaylistSelectBox.SelectedIndex;
PlaylistSelectBox.Items.Clear();
pl.GetPlaylists().ForEach(p => PlaylistSelectBox.Items.Add(p.name)); pl.GetPlaylists().ForEach(p => PlaylistSelectBox.Items.Add(p.name));
PlaylistSelectBox.SelectedIndex = selection;
if (PlaylistSelectBox.SelectedItem != null) if (PlaylistSelectBox.SelectedItem != null)
{ {
PlaylistSongContainer.Items.Clear(); PlaylistSongContainer.Items.Clear();
@@ -53,8 +55,16 @@ namespace MusicPlayer
public void Populate() public void Populate()
{ {
pl.GetPlaylists().ForEach(p => PlaylistSelectBox.Items.Add(p.name)); pl.GetPlaylists().ForEach(p => PlaylistSelectBox.Items.Add(p.name));
if (PlaylistSelectBox.Items.Count > 0)
PlaylistSelectBox.SelectedIndex = 0;
allsongs = api.GetAllSongs(); allsongs = api.GetAllSongs();
allsongs.ForEach(s => PlaylistSongSelector.Items.Add(s.Name)); allsongs.ForEach(s => PlaylistSongSelector.Items.Add(s.Name));
if (PlaylistSelectBox.SelectedItem != null)
{
allPlaylistSongs = pl.GetPlaylistByName(PlaylistSelectBox.SelectedItem.ToString()).GetSongs();
allPlaylistSongs.ForEach(s => PlaylistSongContainer.Items.Add(s.Name));
}
} }
private void PlaylistAddSongsButton_Click(object sender, EventArgs e) private void PlaylistAddSongsButton_Click(object sender, EventArgs e)
@@ -74,6 +84,7 @@ namespace MusicPlayer
} }
currentPlaylist.WriteToFile(); currentPlaylist.WriteToFile();
} }
Thread.Sleep(10);
Repopulate(); Repopulate();
} }
@@ -82,5 +93,10 @@ namespace MusicPlayer
pl.MakeNewPlaylistByName(PlaylistNewInputfield.Text); pl.MakeNewPlaylistByName(PlaylistNewInputfield.Text);
Repopulate(); Repopulate();
} }
private void PlaylistMaker_Load(object sender, EventArgs e)
{
Populate();
}
} }
} }