mirror of
https://github.com/Royce551/FRESHMusicPlayer.git
synced 2025-01-22 10:51:52 -05:00
Queue management and lyrics redesigns
This commit is contained in:
parent
49d3e7c4ea
commit
cf8d6317eb
5 changed files with 126 additions and 49 deletions
|
@ -16,9 +16,9 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
|
||||
public void Initialize()
|
||||
{
|
||||
Update();
|
||||
MainWindow.Player.SongChanged += Player_SongChanged;
|
||||
MainWindow.ProgressTimer.Elapsed += ProgressTimer_Elapsed;
|
||||
Update();
|
||||
}
|
||||
|
||||
private void ProgressTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
|
@ -26,10 +26,15 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
if (!MainWindow.Player.FileLoaded || TimedLyrics is null) return;
|
||||
if (MainWindow.Player.CurrentBackend.CurrentTime < TimedLyrics.Lines.Keys.First()) return;
|
||||
var currentLines = TimedLyrics.Lines.Where(x => x.Key < MainWindow.Player.CurrentBackend.CurrentTime).ToList();
|
||||
var previousLines = TimedLyrics.Lines.Where(x => x.Key > MainWindow.Player.CurrentBackend.CurrentTime).Reverse().ToList();
|
||||
if (currentLines.Count != 0)
|
||||
{
|
||||
var closest = currentLines.Last();
|
||||
Text = closest.Value;
|
||||
TextPlus1 = previousLines.Count - 1 >= 0 && previousLines.Count - 1 < previousLines.Count ? previousLines[previousLines.Count - 1].Value : string.Empty;
|
||||
TextPlus2 = previousLines.Count - 2 >= 0 && previousLines.Count - 2 < previousLines.Count ? previousLines[previousLines.Count - 2].Value : string.Empty;
|
||||
TextMinus1 = currentLines.Count - 2 >= 0 && currentLines.Count - 3 < currentLines.Count ? currentLines[currentLines.Count - 2].Value : string.Empty;
|
||||
TextMinus2 = currentLines.Count - 3 >= 0 && currentLines.Count - 3 < currentLines.Count ? currentLines[currentLines.Count - 3].Value : string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,12 +69,36 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private string textMinus1 = string.Empty;
|
||||
public string TextMinus1
|
||||
{
|
||||
get => textMinus1;
|
||||
set => this.RaiseAndSetIfChanged(ref textMinus1, value);
|
||||
}
|
||||
private string textMinus2 = string.Empty;
|
||||
public string TextMinus2
|
||||
{
|
||||
get => textMinus2;
|
||||
set => this.RaiseAndSetIfChanged(ref textMinus2, value);
|
||||
}
|
||||
private string text = Properties.Resources.Lyrics_NoLyrics;
|
||||
public string Text
|
||||
{
|
||||
get => text;
|
||||
set => this.RaiseAndSetIfChanged(ref text, value);
|
||||
}
|
||||
private string textPlus1 = string.Empty;
|
||||
public string TextPlus1
|
||||
{
|
||||
get => textPlus1;
|
||||
set => this.RaiseAndSetIfChanged(ref textPlus1, value);
|
||||
}
|
||||
private string textPlus2 = string.Empty;
|
||||
public string TextPlus2
|
||||
{
|
||||
get => textPlus2;
|
||||
set => this.RaiseAndSetIfChanged(ref textPlus2, value);
|
||||
}
|
||||
|
||||
private Bitmap coverArt;
|
||||
public Bitmap CoverArt
|
||||
|
|
|
@ -139,22 +139,34 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
|
||||
private async void ProgressTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (!Player.FileLoaded) return;
|
||||
//await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
//{
|
||||
// TimeSpan x = new();
|
||||
// int i = 1;
|
||||
// int i2 = 0;
|
||||
// foreach (var track in Player.Queue.Queue)
|
||||
// {
|
||||
// i++;
|
||||
// if (i <= Player.Queue.Position) continue;
|
||||
// var y = Queue[i2];
|
||||
// x += TimeSpan.FromSeconds(y.Length);
|
||||
// i2++;
|
||||
// }
|
||||
// x -= Player.CurrentTime;
|
||||
// TimeRemaining = x;
|
||||
//});
|
||||
var remainingTime = new TimeSpan();
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
|
||||
TimeSpan x = new();
|
||||
int i = 1;
|
||||
int i2 = 0;
|
||||
foreach (var track in Player.Queue.Queue)
|
||||
for (int i = 0; i < Player.Queue.Queue.Count; i++)
|
||||
{
|
||||
i++;
|
||||
if (i <= Player.Queue.Position) continue;
|
||||
var y = Queue[i2];
|
||||
x += TimeSpan.FromSeconds(y.Length);
|
||||
i2++;
|
||||
if ((i + 1) < Player.Queue.Position) continue;
|
||||
var track = Queue[i];
|
||||
if (i != (Player.Queue.Queue.Count - 1)) remainingTime += TimeSpan.FromSeconds(track.Length);
|
||||
}
|
||||
x -= Player.CurrentTime;
|
||||
TimeRemaining = x;
|
||||
remainingTime += (Player.TotalTime - Player.CurrentTime);
|
||||
TimeRemaining = remainingTime;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,13 @@
|
|||
</Grid.RowDefinitions>
|
||||
|
||||
<ScrollViewer Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
||||
<TextBlock Text="{Binding Text}" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center"/>
|
||||
<StackPanel VerticalAlignment="Center">
|
||||
<TextBlock Text="{Binding TextMinus2}" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" Foreground="{DynamicResource SecondaryTextColor}"/>
|
||||
<TextBlock Text="{Binding TextMinus1}" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" Foreground="{DynamicResource SecondaryTextColor}"/>
|
||||
<TextBlock Text="{Binding Text}" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" FontWeight="Bold"/>
|
||||
<TextBlock Text="{Binding TextPlus1}" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" Foreground="{DynamicResource SecondaryTextColor}"/>
|
||||
<TextBlock Text="{Binding TextPlus2}" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" Foreground="{DynamicResource SecondaryTextColor}"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
|
|
|
@ -32,39 +32,43 @@
|
|||
</DockPanel>
|
||||
|
||||
|
||||
<ListBox Grid.Column="0" Grid.Row="1" Items="{Binding Queue}" Margin="5,0,5,5" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectionMode="AlwaysSelected" VirtualizationMode="Simple" HorizontalAlignment="Stretch" Focusable="False">
|
||||
<ListBox Grid.Column="0" Grid.Row="1" Items="{Binding Queue}" Margin="0,0,0,5" Background="Transparent" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectionMode="Toggle" VirtualizationMode="Simple" HorizontalAlignment="Stretch" Focusable="False">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="Padding" Value="10,2"/>
|
||||
<Setter Property="Margin" Value="0"/>
|
||||
</Style>
|
||||
</ListBox.Styles>
|
||||
<ListBox.DataTemplates>
|
||||
<DataTemplate>
|
||||
<Grid Margin="-5" Height="25" Background="Transparent" HorizontalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Margin="0,0,5,0" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<TextBlock Text="{Binding Position}" HorizontalAlignment="Stretch" Grid.Column="0" FontWeight="Bold" FontSize="16" IsVisible="{Binding !IsCurrentTrack}"/>
|
||||
<TextBlock Text=">" FontWeight="Bold" HorizontalAlignment="Stretch" Grid.Column="0" FontSize="16" IsVisible="{Binding IsCurrentTrack}"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Title}" HorizontalAlignment="Stretch" TextTrimming="CharacterEllipsis" FontSize="15" FontWeight="Bold"/>
|
||||
<TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Artist}" HorizontalAlignment="Stretch" FontSize="10"/>
|
||||
<StackPanel Grid.Column="2" Grid.RowSpan="2" VerticalAlignment="Center" HorizontalAlignment="Right" Height="38" Margin="0,-27,0,-30" Orientation="Horizontal">
|
||||
<Button IsVisible="{Binding $parent[1].IsPointerOver}" Click="OnJumpToButtonClick" VerticalAlignment="Center">
|
||||
<Image Source="{DynamicResource Play}"/>
|
||||
</Button>
|
||||
<Button IsVisible="{Binding $parent[1].IsPointerOver}" Click="OnRemoveButtonClick" VerticalAlignment="Center">
|
||||
<Image Source="{DynamicResource Delete}"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Border CornerRadius="2" BorderBrush="{DynamicResource ForegroundColor}" Background="{DynamicResource ForegroundColor}" BorderThickness="1">
|
||||
<Grid RowDefinitions="1*,Auto" ColumnDefinitions="Auto,1*,Auto" Margin="5,0">
|
||||
<StackPanel Grid.RowSpan="2" Grid.Column="0" VerticalAlignment="Center" Margin="2,0,5,0">
|
||||
<TextBlock Text="{Binding Position}" HorizontalAlignment="Stretch" Grid.Column="0" FontWeight="Bold" FontSize="16" IsVisible="{Binding !IsCurrentTrack}"/>
|
||||
<TextBlock Text=">" FontWeight="Bold" HorizontalAlignment="Stretch" Grid.Column="0" FontSize="16" IsVisible="{Binding IsCurrentTrack}"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Title}" FontSize="16" TextTrimming="CharacterEllipsis" Margin="0,2,0,0"/>
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" Margin="0,0,0,2">
|
||||
<TextBlock Text="{Binding Artist}" FontSize="9" Foreground="{DynamicResource SecondaryTextColor}"/>
|
||||
<TextBlock Text="・ " FontSize="9" Foreground="{DynamicResource SecondaryTextColor}"/>
|
||||
<TextBlock Text="{Binding Album}" FontSize="9" Foreground="{DynamicResource SecondaryTextColor}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.RowSpan="2" Grid.Column="2" Orientation="Horizontal">
|
||||
<Button IsVisible="{Binding $parent[2].IsPointerOver}" Click="OnJumpToButtonClick" VerticalAlignment="Center" Width="30" Height="30" Margin="0,-5">
|
||||
<Image Source="{DynamicResource Play}"/>
|
||||
</Button>
|
||||
<Button IsVisible="{Binding $parent[2].IsPointerOver}" Click="OnRemoveButtonClick" VerticalAlignment="Center" Width="30" Height="30" Margin="0,-5">
|
||||
<Image Source="{DynamicResource Delete}"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.DataTemplates>
|
||||
</ListBox>
|
||||
|
||||
<StackPanel Grid.Row="2" Grid.RowSpan="3" HorizontalAlignment="Center" Orientation="Horizontal" Margin="0,0,0,5" IsVisible="{Binding $parent[1].IsPointerOver}">
|
||||
<StackPanel Grid.Row="2" Grid.RowSpan="3" HorizontalAlignment="Center" Orientation="Horizontal" Margin="0,0,0,5" IsVisible="{Binding $parent[2].IsPointerOver}">
|
||||
<Button Content="{x:Static resx:Resources.QueueManagement_AddTrack}" Command="{Binding AddTrackCommand}"/>
|
||||
<Button Content="{x:Static resx:Resources.QueueManagement_AddPlaylist}" Command="{Binding AddPlaylistCommand}"/>
|
||||
<Button Content="{x:Static resx:Resources.QueueManagement_ClearQueue}" Command="{Binding ClearQueueCommand}" Foreground="Red"/>
|
||||
|
|
|
@ -24,24 +24,50 @@
|
|||
<DockPanel>
|
||||
<!--Menu-->
|
||||
<DockPanel x:Name="MainBar" Height="25" DockPanel.Dock="Top" Background="{StaticResource NavBarColor}" >
|
||||
<TextBlock x:Name="TracksTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_TRACKS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0,10,0" MouseDown="TracksTab_MouseDown" Cursor="Hand" SnapsToDevicePixels="True">
|
||||
<Button Content="Tracks" Margin="10,2,0,2" TextBlock.FontSize="14"/>
|
||||
<Button Content="Artists" Margin="10,2,0,2" TextBlock.FontSize="14"/>
|
||||
<Button Content="Albums" Margin="10,2,0,2" TextBlock.FontSize="14"/>
|
||||
<Button Content="Playlists" Margin="10,2,0,2" TextBlock.FontSize="14"/>
|
||||
<Button Content="Import" Margin="10,2,0,2" TextBlock.FontSize="14"/>
|
||||
<TextBlock x:Name="TracksTab" Visibility="Collapsed" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_TRACKS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0,10,0" MouseDown="TracksTab_MouseDown" Cursor="Hand" SnapsToDevicePixels="True">
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="ArtistsTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_ARTISTS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0" MouseDown="ArtistsTab_MouseDown" Cursor="Hand" SnapsToDevicePixels="True">
|
||||
<TextBlock x:Name="ArtistsTab" Visibility="Collapsed" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_ARTISTS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0" MouseDown="ArtistsTab_MouseDown" Cursor="Hand" SnapsToDevicePixels="True">
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="AlbumsTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_ALBUMS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0" MouseDown="AlbumsTab_MouseDown" Cursor="Hand" SnapsToDevicePixels="True">
|
||||
<TextBlock x:Name="AlbumsTab" Visibility="Collapsed" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_ALBUMS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0" MouseDown="AlbumsTab_MouseDown" Cursor="Hand" SnapsToDevicePixels="True">
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="PlaylistsTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_PLAYLISTS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0" MouseDown="PlaylistsTab_MouseDown" Cursor="Hand" SnapsToDevicePixels="True">
|
||||
<TextBlock x:Name="PlaylistsTab" Visibility="Collapsed" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_PLAYLISTS}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0" MouseDown="PlaylistsTab_MouseDown" Cursor="Hand" SnapsToDevicePixels="True">
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="ImportTab" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_IMPORT}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0" MouseDown="ImportTab_MouseDown" Cursor="Hand" SnapsToDevicePixels="True">
|
||||
<TextBlock x:Name="ImportTab" Visibility="Collapsed" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_IMPORT}" FontSize="16" VerticalAlignment="Center" Foreground="{StaticResource PrimaryTextColor}" DockPanel.Dock="Left" Margin="10,0" MouseDown="ImportTab_MouseDown" Cursor="Hand" SnapsToDevicePixels="True">
|
||||
</TextBlock>
|
||||
|
||||
<Border x:Name="SettingsButton" Background="Transparent" Width="22" Height="22" DockPanel.Dock="Right" Margin="0,-0.75,15,0" MouseDown="SettingsButton_Click" Cursor="Hand">
|
||||
<Button DockPanel.Dock="Right" Margin="0,2,10,2" Width="30">
|
||||
<Viewbox Margin="-1, -1, 0, 1">
|
||||
<Path Data="{StaticResource SettingsIcon}" Fill="{StaticResource PrimaryTextColor}"/>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button DockPanel.Dock="Right" Margin="0,2,10,2" Width="30">
|
||||
<Viewbox Margin="-2, -2, 0, 2">
|
||||
<Path Data="{StaticResource QueueIcon}" Fill="{StaticResource PrimaryTextColor}"/>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button DockPanel.Dock="Right" Margin="0,2,10,2" Width="30">
|
||||
<Viewbox Margin="-2, 0, 0, 1">
|
||||
<Path Data="{StaticResource NotificationIcon}" Fill="{StaticResource PrimaryTextColor}"/>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button DockPanel.Dock="Right" Margin="0,2,10,2" Width="30">
|
||||
<Viewbox Margin="-2, -1, 0, 1">
|
||||
<Path Data="{StaticResource SearchIcon}" Fill="{StaticResource PrimaryTextColor}"/>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
|
||||
<Border x:Name="SettingsButton" Visibility="Collapsed" Background="Transparent" Width="22" Height="22" DockPanel.Dock="Right" Margin="0,-0.75,15,0" MouseDown="SettingsButton_Click" Cursor="Hand">
|
||||
<!---some manual corrections were applied to keep the icons visually correct-->
|
||||
<Canvas>
|
||||
<Path Data="{StaticResource SettingsIcon}" Fill="{StaticResource PrimaryTextColor}"/>
|
||||
</Canvas>
|
||||
</Border>
|
||||
<Border x:Name="QueueManagementButton" Background="Transparent" Width="22" Height="22" DockPanel.Dock="Right" Margin="0,-0.75,15,0" MouseDown="QueueManagementButton_Click" Cursor="Hand">
|
||||
<Border x:Name="QueueManagementButton" Visibility="Collapsed" Background="Transparent" Width="22" Height="22" DockPanel.Dock="Right" Margin="0,-0.75,15,0" MouseDown="QueueManagementButton_Click" Cursor="Hand">
|
||||
<!---some manual corrections were applied to keep the icons visually correct-->
|
||||
<Canvas>
|
||||
<Path Data="{StaticResource QueueIcon}" Fill="{StaticResource PrimaryTextColor}"/>
|
||||
|
@ -54,7 +80,7 @@
|
|||
<Path Data="{StaticResource NotificationIcon}" Fill="{StaticResource PrimaryTextColor}"/>
|
||||
</Canvas>
|
||||
</Border>
|
||||
<Border x:Name="SearchButton" Background="Transparent" Width="20" DockPanel.Dock="Right" Margin="0,2,15,0" HorizontalAlignment="Right" MouseDown="SearchButton_Click" Height="20" VerticalAlignment="Top" Cursor="Hand">
|
||||
<Border x:Name="SearchButton" Visibility="Collapsed" Background="Transparent" Width="20" DockPanel.Dock="Right" Margin="0,2,15,0" HorizontalAlignment="Right" MouseDown="SearchButton_Click" Height="20" VerticalAlignment="Top" Cursor="Hand">
|
||||
<Canvas>
|
||||
<Path Data="{StaticResource SearchIcon}" Fill="{StaticResource PrimaryTextColor}"/>
|
||||
</Canvas>
|
||||
|
|
Loading…
Reference in a new issue