Redesign interface

This commit is contained in:
2015-10-30 19:40:22 +01:00
parent 870c67595b
commit 362a37f0eb
6 changed files with 120 additions and 51 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ namespace MusicPlayer
private Thread network;
private Thread audio;
private Song CurrentSong;
public Song CurrentSong;
public AudioHandler()
{
+19 -1
View File
@@ -25,7 +25,7 @@ namespace MusicPlayer
audio = new AudioHandler();
table = new SongsTable();
form.SongsTableView.DataSource = table;
form.SongsTableView.Columns[4].Visible = false;
form.SongsTableView.Columns[5].Visible = false;
Populate();
}
@@ -62,6 +62,24 @@ namespace MusicPlayer
table.Add(s);
});
}
public static string SecondsToTimestamp(int seconds)
{
string str = "";
//Hours
str += (seconds / 3600).ToString("D2") + ":";
seconds %= 3600;
//Minutes
str += (seconds / 60).ToString("D2") + ":";
seconds %= 60;
//Seconds
str += seconds.ToString("D2");
return str;
}
}
}
+87 -44
View File
@@ -35,18 +35,21 @@
this.AlbumListView = new System.Windows.Forms.ListView();
this.ArtistListBox = new System.Windows.Forms.ListBox();
this.MainPanel = new System.Windows.Forms.Panel();
this.AlbumListLabel = new System.Windows.Forms.Label();
this.ArtistListLabel = new System.Windows.Forms.Label();
this.GenreListLabel = new System.Windows.Forms.Label();
this.MenuStrip = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.viewToolStripMenuItem = 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();
this.LabelTotalTime = new System.Windows.Forms.Label();
this.LabelCurrentTime = new System.Windows.Forms.Label();
this.PositionTrackBar = new System.Windows.Forms.TrackBar();
this.PositionLabel = new System.Windows.Forms.Label();
this.BufferLabel = new System.Windows.Forms.Label();
this.PositionBar = new System.Windows.Forms.ProgressBar();
this.BufferBar = new System.Windows.Forms.ProgressBar();
this.StopButton = new System.Windows.Forms.Button();
this.PauseButton = new System.Windows.Forms.Button();
@@ -71,14 +74,14 @@
this.SongsTableView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.SongsTableView.BackgroundColor = System.Drawing.SystemColors.Control;
this.SongsTableView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.SongsTableView.Location = new System.Drawing.Point(12, 153);
this.SongsTableView.Location = new System.Drawing.Point(12, 165);
this.SongsTableView.MultiSelect = false;
this.SongsTableView.Name = "SongsTableView";
this.SongsTableView.ReadOnly = true;
this.SongsTableView.RowHeadersVisible = false;
this.SongsTableView.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.SongsTableView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.SongsTableView.Size = new System.Drawing.Size(760, 148);
this.SongsTableView.Size = new System.Drawing.Size(760, 175);
this.SongsTableView.TabIndex = 0;
this.SongsTableView.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.SongsTableView_CellDoubleClick);
//
@@ -86,9 +89,9 @@
//
this.GenreListBox.BackColor = System.Drawing.SystemColors.Control;
this.GenreListBox.FormattingEnabled = true;
this.GenreListBox.Location = new System.Drawing.Point(12, 12);
this.GenreListBox.Location = new System.Drawing.Point(12, 25);
this.GenreListBox.Name = "GenreListBox";
this.GenreListBox.Size = new System.Drawing.Size(124, 134);
this.GenreListBox.Size = new System.Drawing.Size(150, 134);
this.GenreListBox.Sorted = true;
this.GenreListBox.TabIndex = 1;
this.GenreListBox.SelectedIndexChanged += new System.EventHandler(this.GenreListBox_SelectedIndexChanged);
@@ -98,9 +101,9 @@
this.AlbumListView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.AlbumListView.BackColor = System.Drawing.SystemColors.Control;
this.AlbumListView.Location = new System.Drawing.Point(272, 12);
this.AlbumListView.Location = new System.Drawing.Point(324, 25);
this.AlbumListView.Name = "AlbumListView";
this.AlbumListView.Size = new System.Drawing.Size(500, 134);
this.AlbumListView.Size = new System.Drawing.Size(448, 134);
this.AlbumListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.AlbumListView.TabIndex = 2;
this.AlbumListView.UseCompatibleStateImageBehavior = false;
@@ -110,9 +113,9 @@
//
this.ArtistListBox.BackColor = System.Drawing.SystemColors.Control;
this.ArtistListBox.FormattingEnabled = true;
this.ArtistListBox.Location = new System.Drawing.Point(142, 12);
this.ArtistListBox.Location = new System.Drawing.Point(168, 25);
this.ArtistListBox.Name = "ArtistListBox";
this.ArtistListBox.Size = new System.Drawing.Size(124, 134);
this.ArtistListBox.Size = new System.Drawing.Size(150, 134);
this.ArtistListBox.Sorted = true;
this.ArtistListBox.TabIndex = 3;
this.ArtistListBox.SelectedIndexChanged += new System.EventHandler(this.ArtistListBox_SelectedIndexChanged);
@@ -123,18 +126,48 @@
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.MainPanel.BackColor = System.Drawing.SystemColors.Window;
this.MainPanel.Controls.Add(this.AlbumListLabel);
this.MainPanel.Controls.Add(this.ArtistListLabel);
this.MainPanel.Controls.Add(this.GenreListLabel);
this.MainPanel.Controls.Add(this.GenreListBox);
this.MainPanel.Controls.Add(this.ArtistListBox);
this.MainPanel.Controls.Add(this.AlbumListView);
this.MainPanel.Controls.Add(this.SongsTableView);
this.MainPanel.Location = new System.Drawing.Point(0, 24);
this.MainPanel.Name = "MainPanel";
this.MainPanel.Size = new System.Drawing.Size(784, 313);
this.MainPanel.Size = new System.Drawing.Size(784, 352);
this.MainPanel.TabIndex = 5;
//
// AlbumListLabel
//
this.AlbumListLabel.AutoSize = true;
this.AlbumListLabel.Location = new System.Drawing.Point(321, 9);
this.AlbumListLabel.Name = "AlbumListLabel";
this.AlbumListLabel.Size = new System.Drawing.Size(36, 13);
this.AlbumListLabel.TabIndex = 6;
this.AlbumListLabel.Text = "Album";
//
// ArtistListLabel
//
this.ArtistListLabel.AutoSize = true;
this.ArtistListLabel.Location = new System.Drawing.Point(165, 9);
this.ArtistListLabel.Name = "ArtistListLabel";
this.ArtistListLabel.Size = new System.Drawing.Size(30, 13);
this.ArtistListLabel.TabIndex = 5;
this.ArtistListLabel.Text = "Artist";
//
// GenreListLabel
//
this.GenreListLabel.AutoSize = true;
this.GenreListLabel.Location = new System.Drawing.Point(12, 9);
this.GenreListLabel.Name = "GenreListLabel";
this.GenreListLabel.Size = new System.Drawing.Size(36, 13);
this.GenreListLabel.TabIndex = 4;
this.GenreListLabel.Text = "Genre";
//
// MenuStrip
//
this.MenuStrip.BackColor = System.Drawing.SystemColors.Window;
this.MenuStrip.BackColor = System.Drawing.SystemColors.WindowFrame;
this.MenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.viewToolStripMenuItem});
@@ -174,26 +207,44 @@
// ControlsPanel
//
this.ControlsPanel.BackColor = System.Drawing.SystemColors.WindowFrame;
this.ControlsPanel.Controls.Add(this.CurrentSongLabel);
this.ControlsPanel.Controls.Add(this.SeperatorLabel);
this.ControlsPanel.Controls.Add(this.LabelTotalTime);
this.ControlsPanel.Controls.Add(this.LabelCurrentTime);
this.ControlsPanel.Controls.Add(this.PositionTrackBar);
this.ControlsPanel.Controls.Add(this.PositionLabel);
this.ControlsPanel.Controls.Add(this.BufferLabel);
this.ControlsPanel.Controls.Add(this.PositionBar);
this.ControlsPanel.Controls.Add(this.BufferBar);
this.ControlsPanel.Controls.Add(this.StopButton);
this.ControlsPanel.Controls.Add(this.PauseButton);
this.ControlsPanel.Controls.Add(this.PlayButton);
this.ControlsPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.ControlsPanel.Location = new System.Drawing.Point(0, 343);
this.ControlsPanel.Location = new System.Drawing.Point(0, 379);
this.ControlsPanel.Name = "ControlsPanel";
this.ControlsPanel.Size = new System.Drawing.Size(784, 119);
this.ControlsPanel.Size = new System.Drawing.Size(784, 83);
this.ControlsPanel.TabIndex = 4;
//
// CurrentSongLabel
//
this.CurrentSongLabel.AutoSize = true;
this.CurrentSongLabel.Location = new System.Drawing.Point(256, 56);
this.CurrentSongLabel.Name = "CurrentSongLabel";
this.CurrentSongLabel.Size = new System.Drawing.Size(111, 13);
this.CurrentSongLabel.TabIndex = 11;
this.CurrentSongLabel.Text = "Not playing any songs";
//
// SeperatorLabel
//
this.SeperatorLabel.AutoSize = true;
this.SeperatorLabel.Location = new System.Drawing.Point(67, 35);
this.SeperatorLabel.Name = "SeperatorLabel";
this.SeperatorLabel.Size = new System.Drawing.Size(12, 13);
this.SeperatorLabel.TabIndex = 10;
this.SeperatorLabel.Text = "/";
//
// LabelTotalTime
//
this.LabelTotalTime.AutoSize = true;
this.LabelTotalTime.Location = new System.Drawing.Point(693, 60);
this.LabelTotalTime.Location = new System.Drawing.Point(85, 35);
this.LabelTotalTime.Name = "LabelTotalTime";
this.LabelTotalTime.Size = new System.Drawing.Size(49, 13);
this.LabelTotalTime.TabIndex = 9;
@@ -202,7 +253,7 @@
// LabelCurrentTime
//
this.LabelCurrentTime.AutoSize = true;
this.LabelCurrentTime.Location = new System.Drawing.Point(358, 60);
this.LabelCurrentTime.Location = new System.Drawing.Point(12, 35);
this.LabelCurrentTime.Name = "LabelCurrentTime";
this.LabelCurrentTime.Size = new System.Drawing.Size(49, 13);
this.LabelCurrentTime.TabIndex = 8;
@@ -210,48 +261,36 @@
//
// PositionTrackBar
//
this.PositionTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.PositionTrackBar.Enabled = false;
this.PositionTrackBar.Location = new System.Drawing.Point(346, 13);
this.PositionTrackBar.Location = new System.Drawing.Point(3, 3);
this.PositionTrackBar.Maximum = 100;
this.PositionTrackBar.Name = "PositionTrackBar";
this.PositionTrackBar.Size = new System.Drawing.Size(426, 45);
this.PositionTrackBar.Size = new System.Drawing.Size(778, 45);
this.PositionTrackBar.TabIndex = 7;
//
// PositionLabel
//
this.PositionLabel.AutoSize = true;
this.PositionLabel.Location = new System.Drawing.Point(285, 90);
this.PositionLabel.Name = "PositionLabel";
this.PositionLabel.Size = new System.Drawing.Size(44, 13);
this.PositionLabel.TabIndex = 6;
this.PositionLabel.Text = "Position";
//
// BufferLabel
//
this.BufferLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.BufferLabel.AutoSize = true;
this.BufferLabel.Location = new System.Drawing.Point(285, 60);
this.BufferLabel.Location = new System.Drawing.Point(597, 56);
this.BufferLabel.Name = "BufferLabel";
this.BufferLabel.Size = new System.Drawing.Size(35, 13);
this.BufferLabel.TabIndex = 5;
this.BufferLabel.Text = "Buffer";
//
// PositionBar
//
this.PositionBar.Location = new System.Drawing.Point(13, 90);
this.PositionBar.Name = "PositionBar";
this.PositionBar.Size = new System.Drawing.Size(265, 23);
this.PositionBar.TabIndex = 4;
//
// BufferBar
//
this.BufferBar.Location = new System.Drawing.Point(13, 60);
this.BufferBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.BufferBar.Location = new System.Drawing.Point(638, 51);
this.BufferBar.Name = "BufferBar";
this.BufferBar.Size = new System.Drawing.Size(265, 23);
this.BufferBar.Size = new System.Drawing.Size(134, 23);
this.BufferBar.TabIndex = 3;
//
// StopButton
//
this.StopButton.Location = new System.Drawing.Point(203, 13);
this.StopButton.Location = new System.Drawing.Point(174, 51);
this.StopButton.Name = "StopButton";
this.StopButton.Size = new System.Drawing.Size(75, 23);
this.StopButton.TabIndex = 2;
@@ -261,7 +300,7 @@
//
// PauseButton
//
this.PauseButton.Location = new System.Drawing.Point(108, 13);
this.PauseButton.Location = new System.Drawing.Point(93, 51);
this.PauseButton.Name = "PauseButton";
this.PauseButton.Size = new System.Drawing.Size(75, 23);
this.PauseButton.TabIndex = 1;
@@ -271,7 +310,7 @@
//
// PlayButton
//
this.PlayButton.Location = new System.Drawing.Point(12, 13);
this.PlayButton.Location = new System.Drawing.Point(12, 51);
this.PlayButton.Name = "PlayButton";
this.PlayButton.Size = new System.Drawing.Size(75, 23);
this.PlayButton.TabIndex = 0;
@@ -307,6 +346,7 @@
this.Load += new System.EventHandler(this.MainForm_Load);
((System.ComponentModel.ISupportInitialize)(this.SongsTableView)).EndInit();
this.MainPanel.ResumeLayout(false);
this.MainPanel.PerformLayout();
this.MenuStrip.ResumeLayout(false);
this.MenuStrip.PerformLayout();
this.ControlsPanel.ResumeLayout(false);
@@ -333,15 +373,18 @@
private System.Windows.Forms.Button PlayButton;
private System.Windows.Forms.Button StopButton;
private System.Windows.Forms.Button PauseButton;
private System.Windows.Forms.Label PositionLabel;
private System.Windows.Forms.Label BufferLabel;
private System.Windows.Forms.ProgressBar PositionBar;
private System.Windows.Forms.ProgressBar BufferBar;
private System.Windows.Forms.Timer UpdateTimer;
private System.Windows.Forms.TrackBar PositionTrackBar;
private System.Windows.Forms.Label LabelTotalTime;
private System.Windows.Forms.Label LabelCurrentTime;
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.Label CurrentSongLabel;
private System.Windows.Forms.Label SeperatorLabel;
private System.Windows.Forms.Label AlbumListLabel;
private System.Windows.Forms.Label ArtistListLabel;
private System.Windows.Forms.Label GenreListLabel;
}
}
+8 -4
View File
@@ -78,13 +78,17 @@ namespace MusicPlayer
PositionTrackBar.Enabled = false;
BufferBar.Value = main.audio.Buffered;
PositionBar.Value = main.audio.Position;
if(!clicked)
PositionTrackBar.Value = main.audio.Position;
LabelCurrentTime.Text = main.audio.CurrentTime + "";
LabelTotalTime.Text = main.audio.TotalTime + "";
LabelCurrentTime.Text = Main.SecondsToTimestamp(main.audio.CurrentTime);
LabelTotalTime.Text = Main.SecondsToTimestamp(main.audio.TotalTime);
if(main.audio.CurrentSong == null)
CurrentSongLabel.Text = "Not playing any songs";
else
CurrentSongLabel.Text = "Currently playing: " + main.audio.CurrentSong.Name;
}
private void GenreListBox_SelectedIndexChanged(object sender, EventArgs e)
@@ -111,7 +115,7 @@ namespace MusicPlayer
var drv = SongsTableView.SelectedRows[0].DataBoundItem as DataRowView;
var row = drv.Row as DataRow;
s.ImportRow(row);
main.audio.Play((s.Rows[0][4] as Song));
main.audio.Play((s.Rows[0][5] as Song));
}
}
@@ -108,6 +108,9 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
+2 -1
View File
@@ -16,12 +16,13 @@ namespace MusicPlayer
this.Columns.Add("Album", typeof(string));
this.Columns.Add("Artiest", typeof(string));
this.Columns.Add("Genre", typeof(string));
this.Columns.Add("Duration", typeof(string));
this.Columns.Add("song", typeof(Song));
}
public void Add(Song s)
{
this.Rows.Add(s.Name, s.Album, s.Artist, s.Genre, s);
this.Rows.Add(s.Name, s.Album, s.Artist, s.Genre, Main.SecondsToTimestamp(s.Seconds), s);
}
}