Switch between server (untested)

This commit is contained in:
2015-11-01 12:05:22 +01:00
parent aa769cfad9
commit 70bed9b661
4 changed files with 98 additions and 23 deletions
+21
View File
@@ -44,6 +44,27 @@ namespace MusicPlayer
Populate();
}
public void SwitchServer(string server)
{
Clear();
nw.ip = server;
Populate();
}
private void Clear()
{
form.GenreListBox.Items.Clear();
form.ArtistListBox.Items.Clear();
form.AlbumListView.Items.Clear();
form.PlaylistBox.Items.Clear();
table.Clear();
genres = new List<string>();
artists = new List<string>();
currentPlayingList = new List<Song>();
}
private void Populate()
{
this.api.GetAlbums().ForEach(a => { form.AlbumListView.Items.Add(a.albumnaam);});
+51 -21
View File
@@ -31,7 +31,7 @@ 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();
@@ -40,10 +40,10 @@ namespace MusicPlayer
this.MainPanel = new System.Windows.Forms.Panel();
this.SplitContainer = new System.Windows.Forms.SplitContainer();
this.PlaylistBox = new System.Windows.Forms.ListBox();
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();
this.PlaylistListLabel = new System.Windows.Forms.Label();
this.MenuStrip = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
@@ -66,6 +66,9 @@ namespace MusicPlayer
this.SearchArtistToolStripLabel = new System.Windows.Forms.ToolStripMenuItem();
this.SearchArtistsTextBox = new System.Windows.Forms.ToolStripTextBox();
this.ClearArtistSearchButton = 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();
this.ControlsPanel = new System.Windows.Forms.Panel();
this.NextButton = new System.Windows.Forms.Button();
this.PreviousButton = new System.Windows.Forms.Button();
@@ -109,14 +112,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);
@@ -228,16 +231,6 @@ namespace MusicPlayer
this.PlaylistBox.Visible = false;
this.PlaylistBox.SelectedIndexChanged += new System.EventHandler(this.PlaylistBox_SelectedIndexChanged);
//
// PlaylistListLabel
//
this.PlaylistListLabel.AutoSize = true;
this.PlaylistListLabel.Location = new System.Drawing.Point(12, 9);
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;
@@ -265,6 +258,16 @@ namespace MusicPlayer
this.GenreListLabel.TabIndex = 4;
this.GenreListLabel.Text = "Genre";
//
// PlaylistListLabel
//
this.PlaylistListLabel.AutoSize = true;
this.PlaylistListLabel.Location = new System.Drawing.Point(12, 9);
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;
//
// MenuStrip
//
this.MenuStrip.BackColor = System.Drawing.SystemColors.WindowFrame;
@@ -273,7 +276,8 @@ namespace MusicPlayer
this.viewToolStripMenuItem,
this.playbackToolStripMenuItem,
this.playlistToolStripMenuItem,
this.searchToolStripMenuItem});
this.searchToolStripMenuItem,
this.serverToolStripMenuItem});
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
this.MenuStrip.Name = "MenuStrip";
this.MenuStrip.Size = new System.Drawing.Size(784, 24);
@@ -444,6 +448,29 @@ namespace MusicPlayer
this.ClearArtistSearchButton.Text = "Clear Search";
this.ClearArtistSearchButton.Click += new System.EventHandler(this.ClearArtistSearchButton_Click);
//
// serverToolStripMenuItem
//
this.serverToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.SelectServerJancoButton,
this.SelectServerYorickButton});
this.serverToolStripMenuItem.Name = "serverToolStripMenuItem";
this.serverToolStripMenuItem.Size = new System.Drawing.Size(51, 20);
this.serverToolStripMenuItem.Text = "Server";
//
// SelectServerJancoButton
//
this.SelectServerJancoButton.Name = "SelectServerJancoButton";
this.SelectServerJancoButton.Size = new System.Drawing.Size(148, 22);
this.SelectServerJancoButton.Text = "jancokock.me";
this.SelectServerJancoButton.Click += new System.EventHandler(this.SelectServerJancoButton_Click);
//
// SelectServerYorickButton
//
this.SelectServerYorickButton.Name = "SelectServerYorickButton";
this.SelectServerYorickButton.Size = new System.Drawing.Size(148, 22);
this.SelectServerYorickButton.Text = "imegumii.nl";
this.SelectServerYorickButton.Click += new System.EventHandler(this.SelectServerYorickButton_Click);
//
// ControlsPanel
//
this.ControlsPanel.BackColor = System.Drawing.SystemColors.WindowFrame;
@@ -758,6 +785,9 @@ namespace MusicPlayer
private System.Windows.Forms.ToolStripMenuItem NotifyMenuStripPreviousButton;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
private System.Windows.Forms.ToolStripMenuItem ViewCurrentPlaylistButton;
private System.Windows.Forms.ToolStripMenuItem serverToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem SelectServerJancoButton;
private System.Windows.Forms.ToolStripMenuItem SelectServerYorickButton;
}
}
+25 -1
View File
@@ -103,7 +103,11 @@ namespace MusicPlayer
if (main.audio.CurrentSong == null)
CurrentSongLabel.Text = "Not playing any songs";
else
{
if (main.audio.CurrentSong.Seconds < 1)
PositionTrackBar.Enabled = false;
CurrentSongLabel.Text = "Currently playing: " + main.audio.CurrentSong.Name;
}
//Buttons and context menu
if (main.audio.AState == AudioHandler.AudioState.PLAYING)
@@ -122,6 +126,16 @@ namespace MusicPlayer
NotifyMenuStripPlayingSongLabel.Visible = false;
}
if (main.nw.ip == "http://jancokock.me")
SelectServerJancoButton.Enabled = false;
else
SelectServerJancoButton.Enabled = true;
if (main.nw.ip == "http://imegumii.nl")
SelectServerYorickButton.Enabled = false;
else
SelectServerYorickButton.Enabled = true;
if (main.audio.AState == AudioHandler.AudioState.PAUSED)
{
PauseButton.Enabled = false;
@@ -491,12 +505,22 @@ namespace MusicPlayer
int deltax = Math.Abs(startx - e.X);
int deltay = Math.Abs(starty - e.Y);
if ((deltax > 5 || deltay > 5) && draggedstarted)
if ((deltax > 5 || deltay > 5) && draggedstarted && !draggedcompleted)
{
draggedcompleted = true;
playlistsToolStripMenuItem_Click(this, new EventArgs());
Cursor.Current = Cursors.Hand;
}
}
private void SelectServerJancoButton_Click(object sender, EventArgs e)
{
main.SwitchServer("http://jancokock.me");
}
private void SelectServerYorickButton_Click(object sender, EventArgs e)
{
main.SwitchServer("http://imegumii.nl");
}
}
}
+1 -1
View File
@@ -13,7 +13,7 @@ namespace MusicPlayer
public class NetworkHandler
{
private int port = 8585;
private string ip;
public string ip { get; set; }
public NetworkHandler(string ip)
{