ソースを参照

Fixed seeking on specific click on trackbar

Janco Kock 10 年 前
コミット
6a9b2956de

+ 4 - 3
MusicPlayer/MusicPlayer/MainForm.Designer.cs

@@ -324,7 +324,7 @@ namespace MusicPlayer
             this.PlayNextSongButton.CheckOnClick = true;
             this.PlayNextSongButton.CheckState = System.Windows.Forms.CheckState.Checked;
             this.PlayNextSongButton.Name = "PlayNextSongButton";
-            this.PlayNextSongButton.Size = new System.Drawing.Size(152, 22);
+            this.PlayNextSongButton.Size = new System.Drawing.Size(123, 22);
             this.PlayNextSongButton.Text = "Play Next";
             // 
             // LoopSongButton
@@ -333,7 +333,7 @@ namespace MusicPlayer
             this.LoopSongButton.CheckOnClick = true;
             this.LoopSongButton.CheckState = System.Windows.Forms.CheckState.Checked;
             this.LoopSongButton.Name = "LoopSongButton";
-            this.LoopSongButton.Size = new System.Drawing.Size(152, 22);
+            this.LoopSongButton.Size = new System.Drawing.Size(123, 22);
             this.LoopSongButton.Text = "Loop";
             // 
             // ShuffleSongButton
@@ -341,7 +341,7 @@ namespace MusicPlayer
             this.ShuffleSongButton.CheckOnClick = true;
             this.ShuffleSongButton.Enabled = false;
             this.ShuffleSongButton.Name = "ShuffleSongButton";
-            this.ShuffleSongButton.Size = new System.Drawing.Size(152, 22);
+            this.ShuffleSongButton.Size = new System.Drawing.Size(123, 22);
             this.ShuffleSongButton.Text = "Shuffle";
             // 
             // playlistToolStripMenuItem
@@ -500,6 +500,7 @@ namespace MusicPlayer
             this.PositionTrackBar.Size = new System.Drawing.Size(778, 45);
             this.PositionTrackBar.TabIndex = 7;
             this.PositionTrackBar.TickStyle = System.Windows.Forms.TickStyle.None;
+            this.PositionTrackBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PositionTrackBar_MouseDown);
             // 
             // BufferLabel
             // 

+ 7 - 0
MusicPlayer/MusicPlayer/MainForm.cs

@@ -377,5 +377,12 @@ namespace MusicPlayer
             SearchGenresTextBox.Text = "";
             ClearGenreSearchButton.Enabled = false;
         }
+
+        private void PositionTrackBar_MouseDown(object sender, MouseEventArgs e)
+        {
+            double dblValue;
+            dblValue = ((double)(e.X+PositionTrackBar.Location.X) / (double)(PositionTrackBar.Width + PositionTrackBar.Location.X)) * (PositionTrackBar.Maximum - PositionTrackBar.Minimum);
+            PositionTrackBar.Value = Convert.ToInt32(dblValue);
+        }
     }
 }