Handle no title for song and stop state
This commit is contained in:
parent
48b5bc5d28
commit
2c8696155a
@ -17,7 +17,7 @@
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid Background="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}" MinHeight="270">
|
||||
<Grid Background="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}" MinHeight="270" MinWidth="650">
|
||||
<Grid x:Name="TopLayout" Margin="10,0,10,0" VerticalAlignment="Stretch" Width="Auto" Height="Auto">
|
||||
<Grid x:Name="Display" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="225,0,0,0" Height="Auto" Width="Auto">
|
||||
<GroupBox Height="220" VerticalAlignment="Center">
|
||||
@ -32,10 +32,10 @@
|
||||
<TextBlock x:Name="SongTitle" TextWrapping="Wrap" TextAlignment="Center" FontWeight="Normal" FontSize="20" Text="Title"/>
|
||||
<TextBlock x:Name="SongArtist" TextWrapping="Wrap" TextAlignment="Center" FontWeight="Bold" FontSize="18" Text="Artist"/>
|
||||
<TextBlock x:Name="SongAlbum" TextWrapping="Wrap" TextAlignment="Center" FontWeight="Normal" FontSize="16" Text="Album"/>
|
||||
<TextBlock TextWrapping="Wrap" TextAlignment="Center" FontWeight="Normal" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" Margin="0,2,0,0">
|
||||
<TextBlock x:Name="SongInfo" TextWrapping="Wrap" TextAlignment="Center" FontWeight="Normal" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" Margin="0,2,0,0">
|
||||
<Run x:Name="SongGenre"/>
|
||||
<Run> – </Run>
|
||||
<Run x:Name="Format"/>
|
||||
<Run x:Name="SongInfoDash"> – </Run>
|
||||
<Run x:Name="SongFormat"/>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
@ -61,7 +61,7 @@
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<Grid VerticalAlignment="Stretch" Margin="0,18,0,0">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,2,0,0">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="10,2,10,0">
|
||||
<TextBlock FontFamily="Segoe MDL2 Assets" Text="" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="16"/>
|
||||
<Slider x:Name="VolumeSlider" Maximum="100" Value="50" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" MinWidth="180" FlowDirection="LeftToRight" PreviewMouseUp="VolumeSlider_DragCompleted" FocusVisualStyle="{x:Null}"/>
|
||||
<TextBlock FontFamily="Segoe MDL2 Assets" Text="" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="7.5,0,0,0" FontSize="16"/>
|
||||
|
@ -52,19 +52,32 @@ namespace unison
|
||||
if (_mpd.GetCurrentSong() == null)
|
||||
return;
|
||||
|
||||
if (!_mpd.GetCurrentSong().HasName)
|
||||
if (_mpd.GetCurrentSong().HasTitle && _mpd.GetCurrentSong().Title.Length > 0)
|
||||
SongTitle.Text = _mpd.GetCurrentSong().Title;
|
||||
else
|
||||
else if (_mpd.GetCurrentSong().HasName && _mpd.GetCurrentSong().Name.Length > 0)
|
||||
SongTitle.Text = _mpd.GetCurrentSong().Name;
|
||||
else
|
||||
{
|
||||
int start = _mpd.GetCurrentSong().Path.LastIndexOf("/") + 1;
|
||||
int end = _mpd.GetCurrentSong().Path.LastIndexOf(".");
|
||||
SongTitle.Text = _mpd.GetCurrentSong().Path.Substring(start, end - start);
|
||||
}
|
||||
|
||||
SongTitle.ToolTip = _mpd.GetCurrentSong().Path;
|
||||
SongArtist.Text = _mpd.GetCurrentSong().Artist;
|
||||
SongAlbum.Text = _mpd.GetCurrentSong().Album;
|
||||
SongGenre.Text = _mpd.GetCurrentSong().Genre;
|
||||
|
||||
if (_mpd.GetCurrentSong().Date != null)
|
||||
SongAlbum.Text += $" ({ _mpd.GetCurrentSong().Date})";
|
||||
Format.Text = _mpd.GetCurrentSong().Path.Substring(_mpd.GetCurrentSong().Path.LastIndexOf(".") + 1);
|
||||
|
||||
SongGenre.Text = _mpd.GetCurrentSong().Genre;
|
||||
SongFormat.Text = _mpd.GetCurrentSong().Path.Substring(_mpd.GetCurrentSong().Path.LastIndexOf(".") + 1);
|
||||
if (SongGenre.Text.Length == 0 || SongFormat.Text.Length == 0)
|
||||
SongInfoDash.Text = "";
|
||||
else
|
||||
SongInfoDash.Text = " – ";
|
||||
|
||||
TimeSlider.IsEnabled = true;
|
||||
if (_mpd.GetCurrentSong().Time == -1)
|
||||
{
|
||||
CurrentTime.Text = "";
|
||||
@ -92,15 +105,37 @@ namespace unison
|
||||
VolumeSlider.ToolTip = _mpd.GetStatus().Volume;
|
||||
}
|
||||
|
||||
if (_mpd.IsPlaying())
|
||||
PlayPause.Text = "\xedb4";
|
||||
else
|
||||
PlayPause.Text = "\xedb5";
|
||||
|
||||
UpdateButton(ref BorderRandom, _mpd.GetStatus().Random);
|
||||
UpdateButton(ref BorderRepeat, _mpd.GetStatus().Repeat);
|
||||
UpdateButton(ref BorderSingle, _mpd.GetStatus().Single);
|
||||
UpdateButton(ref BorderConsume, _mpd.GetStatus().Consume);
|
||||
|
||||
if (_mpd.IsPlaying())
|
||||
PlayPause.Text = "\xedb4";
|
||||
else
|
||||
{
|
||||
PlayPause.Text = "\xedb5";
|
||||
if (_mpd.GetStatus().State == MpcNET.MpdState.Stop)
|
||||
{
|
||||
DefaultState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DefaultState()
|
||||
{
|
||||
SongTitle.Text = "";
|
||||
SongArtist.Text = "";
|
||||
SongAlbum.Text = "";
|
||||
SongGenre.Text = "";
|
||||
SongInfoDash.Text = "";
|
||||
SongFormat.Text = "";
|
||||
CurrentTime.Text = "";
|
||||
EndTime.Text = "";
|
||||
TimeSlider.Value = 50;
|
||||
TimeSlider.IsEnabled = false;
|
||||
NoCover.Visibility = Visibility.Visible;
|
||||
Cover.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public void OnCoverChanged(object sender, EventArgs e)
|
||||
|
Loading…
Reference in New Issue
Block a user