private void OnReleaseSongPosition(object sender, MouseButtonEventArgs e) { SongProgressBar.ReleaseMouseCapture(); IsMouseCapture = false; ViewModel.PlayAtPercentage(SongProgressBar.Value); }
private void OnCaptureSongPosition(object sender, MouseButtonEventArgs e) { SongProgressBar.CaptureMouse(); IsMouseCapture = true; // user maybe click and release so update event will not be fired OnUpdateSongPosition(sender, e); }
private void OnUpdateSongPosition(object sender, MouseEventArgs e) { if (IsMouseCapture && e.LeftButton == MouseButtonState.Pressed) { Point mouse = e.GetPosition(this); Point progressbar = SongProgressBar.TransformToAncestor(this).Transform(new Point(0, 0)); double percent = (mouse.X - progressbar.X) / SongProgressBar.ActualWidth * 100.0; SongProgressBar.Value = percent; } }