Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6659e2dff7 | ||
|
|
4788a80b78 | ||
|
|
2f82bd96c6 | ||
|
|
f385ff773f | ||
|
|
3ea423c87e | ||
|
|
9fb8550dbf | ||
|
|
f07b9e0fdb | ||
|
|
d4b916137b | ||
|
|
e7eba01ac7 | ||
|
|
8e64b6e5b6 | ||
|
|
c760e5a559 |
@@ -24,8 +24,11 @@ namespace MusicPlayer
|
||||
{
|
||||
// Q artist genre album
|
||||
JObject o = nw.SendString($"search?q={search}&album={album}&genre={genre}&artist={artist}");
|
||||
Console.WriteLine(o.PropertyValues().ToString());
|
||||
if (o["result"].ToString() == "OK") { return o; }
|
||||
if (o != null)
|
||||
{
|
||||
Console.WriteLine(o.PropertyValues().ToString());
|
||||
if (o["result"].ToString() == "OK") { return o; }
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace MusicPlayer
|
||||
catch(Exception e)
|
||||
{
|
||||
AState = AudioState.STOPPED;
|
||||
main.form.SongFinished();
|
||||
//main.form.SongFinished();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace MusicPlayer
|
||||
waveOut.Init(blockAlignedStream);
|
||||
waveOut.Play();
|
||||
|
||||
if (CurrentSong.Seconds == 0)
|
||||
if (CurrentSong == null || CurrentSong.Seconds == 0)
|
||||
Length = ms.Length / waveOut.OutputWaveFormat.AverageBytesPerSecond;
|
||||
else
|
||||
Length = CurrentSong.Seconds * waveOut.OutputWaveFormat.AverageBytesPerSecond;
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace MusicPlayer
|
||||
public NetworkHandler nw;
|
||||
public PlaylistHandler pl;
|
||||
public AudioHandler audio;
|
||||
|
||||
public SongsTable table;
|
||||
|
||||
private List<string> genres;
|
||||
@@ -116,7 +115,8 @@ namespace MusicPlayer
|
||||
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.GetAlbums().ForEach(a => form.AlbumListView.Items.Add(a.albumnaam,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));
|
||||
@@ -154,44 +154,13 @@ namespace MusicPlayer
|
||||
api.Songify(o).ForEach(s => table.Add(s));
|
||||
|
||||
//albums
|
||||
api.Albumify(o).ForEach(a => form.AlbumListView.Items.Add(a.albumnaam));
|
||||
api.Albumify(o).ForEach(a => form.AlbumListView.Items.Add(a.albumnaam, a.albumnaam));
|
||||
|
||||
//artists
|
||||
api.Artistify(o).ForEach(a => form.ArtistListBox.Items.Add(a.naam));
|
||||
|
||||
//genres
|
||||
api.Genrify(o).ForEach(g => form.GenreListBox.Items.Add(g.name));
|
||||
BackgroundWorker bw = new BackgroundWorker();
|
||||
bw.DoWork += new DoWorkEventHandler(
|
||||
delegate (object x, DoWorkEventArgs args)
|
||||
{
|
||||
BackgroundWorker b = x as BackgroundWorker;
|
||||
ImageList imagelist = new ImageList();
|
||||
List<string> templist = new List<string>();
|
||||
Action action = () =>
|
||||
{
|
||||
foreach (ListViewItem item in form.AlbumListView.Items)
|
||||
{
|
||||
templist.Add(item.Text);
|
||||
}
|
||||
};
|
||||
form.Invoke(action);
|
||||
|
||||
foreach (string item in templist)
|
||||
{
|
||||
imagelist.Images.Add(item, api.getAlbumCover(item));
|
||||
}
|
||||
|
||||
action = () => {
|
||||
form.AlbumListView.LargeImageList = imagelist;
|
||||
foreach (ListViewItem item in form.AlbumListView.Items)
|
||||
{
|
||||
item.ImageKey = item.Text;
|
||||
}
|
||||
};
|
||||
form.Invoke(action);
|
||||
});
|
||||
bw.RunWorkerAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+34
-17
@@ -31,13 +31,14 @@ namespace MusicPlayer
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||
this.SongsTableView = new System.Windows.Forms.DataGridView();
|
||||
this.GenreListBox = new System.Windows.Forms.ListBox();
|
||||
this.AlbumListView = new System.Windows.Forms.ListView();
|
||||
this.ArtistListBox = new System.Windows.Forms.ListBox();
|
||||
this.MainPanel = new System.Windows.Forms.Panel();
|
||||
this.AddToQueueLabel = new System.Windows.Forms.Label();
|
||||
this.SplitContainer = new System.Windows.Forms.SplitContainer();
|
||||
this.PlaylistBox = new System.Windows.Forms.ListBox();
|
||||
this.AlbumListLabel = new System.Windows.Forms.Label();
|
||||
@@ -73,6 +74,7 @@ namespace MusicPlayer
|
||||
this.SearchSongsButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.AdvancedSearchButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.resetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.serverToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SelectServerJancoButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SelectServerYorickButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -110,7 +112,6 @@ namespace MusicPlayer
|
||||
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.NotifyMenuStripNextButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.NotifyMenuStripPreviousButton = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.resetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.SongsTableView)).BeginInit();
|
||||
this.MainPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.SplitContainer)).BeginInit();
|
||||
@@ -131,14 +132,14 @@ namespace MusicPlayer
|
||||
this.SongsTableView.AllowUserToResizeRows = false;
|
||||
this.SongsTableView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
this.SongsTableView.BackgroundColor = System.Drawing.SystemColors.Control;
|
||||
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.ControlLight;
|
||||
dataGridViewCellStyle4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.SongsTableView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;
|
||||
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.ControlLight;
|
||||
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
|
||||
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
|
||||
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.SongsTableView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
|
||||
this.SongsTableView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.SongsTableView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.SongsTableView.Location = new System.Drawing.Point(0, 0);
|
||||
@@ -204,6 +205,7 @@ namespace MusicPlayer
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.MainPanel.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.MainPanel.Controls.Add(this.AddToQueueLabel);
|
||||
this.MainPanel.Controls.Add(this.SplitContainer);
|
||||
this.MainPanel.Controls.Add(this.AlbumListLabel);
|
||||
this.MainPanel.Controls.Add(this.ArtistListLabel);
|
||||
@@ -214,6 +216,20 @@ namespace MusicPlayer
|
||||
this.MainPanel.Size = new System.Drawing.Size(784, 351);
|
||||
this.MainPanel.TabIndex = 5;
|
||||
//
|
||||
// AddToQueueLabel
|
||||
//
|
||||
this.AddToQueueLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.AddToQueueLabel.AutoSize = true;
|
||||
this.AddToQueueLabel.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.AddToQueueLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.AddToQueueLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.AddToQueueLabel.Location = new System.Drawing.Point(668, 4);
|
||||
this.AddToQueueLabel.Name = "AddToQueueLabel";
|
||||
this.AddToQueueLabel.Size = new System.Drawing.Size(104, 18);
|
||||
this.AddToQueueLabel.TabIndex = 10;
|
||||
this.AddToQueueLabel.Text = "Add to Queue";
|
||||
this.AddToQueueLabel.Visible = false;
|
||||
//
|
||||
// SplitContainer
|
||||
//
|
||||
this.SplitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
@@ -520,6 +536,13 @@ namespace MusicPlayer
|
||||
this.AdvancedSearchButton.Text = "Advanced";
|
||||
this.AdvancedSearchButton.Click += new System.EventHandler(this.AdvancedSearchButton_Click);
|
||||
//
|
||||
// resetToolStripMenuItem
|
||||
//
|
||||
this.resetToolStripMenuItem.Name = "resetToolStripMenuItem";
|
||||
this.resetToolStripMenuItem.Size = new System.Drawing.Size(127, 22);
|
||||
this.resetToolStripMenuItem.Text = "Reset";
|
||||
this.resetToolStripMenuItem.Click += new System.EventHandler(this.resetToolStripMenuItem_Click);
|
||||
//
|
||||
// serverToolStripMenuItem
|
||||
//
|
||||
this.serverToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
@@ -843,13 +866,6 @@ namespace MusicPlayer
|
||||
this.NotifyMenuStripPreviousButton.Text = "Previous";
|
||||
this.NotifyMenuStripPreviousButton.Click += new System.EventHandler(this.NotifyMenuStripPreviousButton_Click);
|
||||
//
|
||||
// resetToolStripMenuItem
|
||||
//
|
||||
this.resetToolStripMenuItem.Name = "resetToolStripMenuItem";
|
||||
this.resetToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.resetToolStripMenuItem.Text = "Reset";
|
||||
this.resetToolStripMenuItem.Click += new System.EventHandler(this.resetToolStripMenuItem_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@@ -964,6 +980,7 @@ namespace MusicPlayer
|
||||
private System.Windows.Forms.ToolStripMenuItem AdvancedSearchButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem resetToolStripMenuItem;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.Label AddToQueueLabel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -421,8 +421,10 @@ namespace MusicPlayer
|
||||
|
||||
private void PositionTrackBar_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
clicked = true;
|
||||
double dblValue;
|
||||
dblValue = ((double)(e.X+PositionTrackBar.Location.X) / (double)(PositionTrackBar.Width + PositionTrackBar.Location.X)) * (PositionTrackBar.Maximum - PositionTrackBar.Minimum);
|
||||
//dblValue = ((double)(e.X+PositionTrackBar.Location.X) / (double)(PositionTrackBar.Width + PositionTrackBar.Location.X)) * (PositionTrackBar.Maximum - PositionTrackBar.Minimum);
|
||||
dblValue = ((double)e.X / (double)PositionTrackBar.Width) * (PositionTrackBar.Maximum - PositionTrackBar.Minimum);
|
||||
PositionTrackBar.Value = Convert.ToInt32(dblValue);
|
||||
}
|
||||
|
||||
@@ -486,7 +488,7 @@ namespace MusicPlayer
|
||||
{
|
||||
main.FilterCurrentPlaying();
|
||||
int selected = main.currentPlayingList.IndexOf(main.audio.CurrentSong);
|
||||
if(main.currentPlayingList.Count >= 1)
|
||||
if(main.currentPlayingList.Count >= 1 && selected >= 0)
|
||||
SongsTableView.CurrentCell = SongsTableView.Rows[selected].Cells[0];
|
||||
}
|
||||
|
||||
@@ -505,23 +507,43 @@ namespace MusicPlayer
|
||||
{
|
||||
Cursor.Current = Cursors.Default;
|
||||
Point point = PlaylistBox.PointToClient(Cursor.Position);
|
||||
Point point2 = AddToQueueLabel.PointToClient(Cursor.Position);
|
||||
bool queue = AddToQueueLabel.ClientRectangle.Contains(point2);
|
||||
int index = PlaylistBox.IndexFromPoint(point);
|
||||
if (index < 0) //nope, niet op een playlist gesleept
|
||||
if (index < 0 && !queue) //nope, niet op een playlist gesleept
|
||||
{
|
||||
draggedstarted = false;
|
||||
draggedcompleted = false;
|
||||
return;
|
||||
}
|
||||
Playlist currentPlaylist = main.pl.GetPlaylistByName(PlaylistBox.Items[index].ToString());
|
||||
SongsTable s = new SongsTable();
|
||||
if (SongsTableView.SelectedRows.Count > 0)
|
||||
|
||||
if (queue)
|
||||
{
|
||||
var drv = SongsTableView.SelectedRows[0].DataBoundItem as DataRowView;
|
||||
var row = drv.Row as DataRow;
|
||||
s.ImportRow(row);
|
||||
currentPlaylist.AddSong((s.Rows[0][5] as Song));
|
||||
currentPlaylist.WriteToFile();
|
||||
SongsTable s = new SongsTable();
|
||||
if (SongsTableView.SelectedRows.Count > 0)
|
||||
{
|
||||
var drv = SongsTableView.SelectedRows[0].DataBoundItem as DataRowView;
|
||||
var row = drv.Row as DataRow;
|
||||
s.ImportRow(row);
|
||||
main.currentPlayingList.Add((s.Rows[0][5] as Song));
|
||||
ViewCurrentPlaylistButton_Click(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Playlist currentPlaylist = main.pl.GetPlaylistByName(PlaylistBox.Items[index].ToString());
|
||||
SongsTable s = new SongsTable();
|
||||
if (SongsTableView.SelectedRows.Count > 0)
|
||||
{
|
||||
var drv = SongsTableView.SelectedRows[0].DataBoundItem as DataRowView;
|
||||
var row = drv.Row as DataRow;
|
||||
s.ImportRow(row);
|
||||
currentPlaylist.AddSong((s.Rows[0][5] as Song));
|
||||
currentPlaylist.WriteToFile();
|
||||
}
|
||||
}
|
||||
|
||||
AddToQueueLabel.Visible = false;
|
||||
}
|
||||
|
||||
draggedcompleted = false;
|
||||
@@ -537,6 +559,7 @@ namespace MusicPlayer
|
||||
{
|
||||
draggedcompleted = true;
|
||||
playlistsToolStripMenuItem_Click(this, new EventArgs());
|
||||
AddToQueueLabel.Visible = true;
|
||||
Cursor.Current = Cursors.Hand;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user