Improvement on seek time slider

This commit is contained in:
Théo Marchal 2021-08-31 01:53:52 +02:00
parent 0aa80ed8b5
commit 86a652c170
2 changed files with 11 additions and 2 deletions

View File

@ -37,7 +37,7 @@
<Grid HorizontalAlignment="Center" VerticalAlignment="Top">
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="CurrentTime" Text="0:00" TextWrapping="Wrap" HorizontalAlignment="Left"/>
<Slider Style="{DynamicResource SliderTime}" x:Name="TimeSlider" MinWidth="320" Margin="5,0,5,0" HorizontalAlignment="Center" Maximum="100" PreviewMouseUp="TimeSlider_DragCompleted" FocusVisualStyle="{x:Null}"/>
<Slider Style="{DynamicResource SliderTime}" x:Name="TimeSlider" MinWidth="320" Margin="5,0,5,0" HorizontalAlignment="Center" Maximum="100" PreviewMouseUp="TimeSlider_DragCompleted" Thumb.DragStarted="TimeSlider_DragStarted" FocusVisualStyle="{x:Null}"/>
<TextBlock x:Name="EndTime" Text="0:00" TextWrapping="Wrap" Height="18" HorizontalAlignment="Right"/>
</StackPanel>
</Grid>

View File

@ -5,6 +5,7 @@ using System.Windows.Controls;
using System.Windows.Threading;
using System.Windows.Interop;
using System.Windows.Input;
using System.Windows.Controls.Primitives;
namespace unison
{
@ -14,6 +15,8 @@ namespace unison
private readonly MPDHandler mpd;
DispatcherTimer timer = new DispatcherTimer();
Thickness SelectedThickness;
Thickness BaseThickness;
@ -26,7 +29,7 @@ namespace unison
mpd = (MPDHandler)Application.Current.Properties["mpd"];
DispatcherTimer timer = new DispatcherTimer();
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(0.5);
timer.Tick += Timer_Tick;
timer.Start();
@ -174,6 +177,11 @@ namespace unison
Hide();
}
private void TimeSlider_DragStarted(object sender, DragStartedEventArgs e)
{
timer.Stop();
}
private void TimeSlider_DragCompleted(object sender, MouseButtonEventArgs e)
{
Slider slider = (Slider)sender;
@ -183,6 +191,7 @@ namespace unison
double SeekTime = SongPercentage / 100 * SongTime;
mpd.SetTime(SeekTime);
timer.Start();
}
private void VolumeSlider_DragCompleted(object sender, MouseButtonEventArgs e)