Fixed playlist song pasting logic, so that songs can be pasted into an empty playlist (or a playlist with no selected songs).
This commit is contained in:
@@ -595,7 +595,7 @@ public partial class PlaylistDetailViewModel : ViewModelBase
|
|||||||
|
|
||||||
private bool CanPasteSongs()
|
private bool CanPasteSongs()
|
||||||
{
|
{
|
||||||
if (Playlist == null || SelectedPlaylistSongs.Count == 0)
|
if (Playlist == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DataPackageView dataPackageView = Clipboard.GetContent();
|
DataPackageView dataPackageView = Clipboard.GetContent();
|
||||||
@@ -611,17 +611,21 @@ public partial class PlaylistDetailViewModel : ViewModelBase
|
|||||||
|
|
||||||
private async Task PasteSongsAsync()
|
private async Task PasteSongsAsync()
|
||||||
{
|
{
|
||||||
if (Playlist == null || SelectedPlaylistSongs.Count == 0)
|
if (Playlist == null)
|
||||||
return;
|
|
||||||
|
|
||||||
int selectedPlaylistSongIndex = Playlist.IndexOf(SelectedPlaylistSongs[0]);
|
|
||||||
|
|
||||||
if (selectedPlaylistSongIndex == -1)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Song[] songs = await GetSongsFromClipboardAsync();
|
Song[] songs = await GetSongsFromClipboardAsync();
|
||||||
|
int insertIndex = Playlist.Songs.Count;
|
||||||
|
|
||||||
Playlist.AddSongs(songs, selectedPlaylistSongIndex + 1);
|
if (SelectedPlaylistSongs.Count > 0)
|
||||||
|
{
|
||||||
|
int selectedPlaylistSongIndex = Playlist.IndexOf(SelectedPlaylistSongs[0]);
|
||||||
|
|
||||||
|
if (selectedPlaylistSongIndex >= 0)
|
||||||
|
insertIndex = selectedPlaylistSongIndex + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Playlist.AddSongs(songs, insertIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<Song[]> GetSongsFromClipboardAsync()
|
private static async Task<Song[]> GetSongsFromClipboardAsync()
|
||||||
|
|||||||
@@ -150,6 +150,9 @@
|
|||||||
<!-- Playback Actions -->
|
<!-- Playback Actions -->
|
||||||
<Grid Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center">
|
<Grid Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||||
<StackPanel Orientation="Horizontal" Spacing="16">
|
<StackPanel Orientation="Horizontal" Spacing="16">
|
||||||
|
<!--<Button Style="{StaticResource FlatButton}" Command="{Binding PreviousSongCommand}">
|
||||||
|
<Path Style="{StaticResource FlatButtonPath}" Fill="{StaticResource LightGradientBrush}" Data="{StaticResource ShuffleIcon}"></Path>
|
||||||
|
</Button>-->
|
||||||
<Button Style="{StaticResource FlatButton}" Command="{Binding PreviousSongCommand}">
|
<Button Style="{StaticResource FlatButton}" Command="{Binding PreviousSongCommand}">
|
||||||
<Path Style="{StaticResource FlatButtonPath}" Fill="{StaticResource LightGradientBrush}" Data="{StaticResource SkipStartFillIcon}"></Path>
|
<Path Style="{StaticResource FlatButtonPath}" Fill="{StaticResource LightGradientBrush}" Data="{StaticResource SkipStartFillIcon}"></Path>
|
||||||
</Button>
|
</Button>
|
||||||
@@ -207,6 +210,9 @@
|
|||||||
<Button Style="{StaticResource FlatButton}" Command="{Binding NextSongCommand}">
|
<Button Style="{StaticResource FlatButton}" Command="{Binding NextSongCommand}">
|
||||||
<Path Style="{StaticResource FlatButtonPath}" Fill="{StaticResource LightGradientBrush}" Data="{StaticResource SkipEndFillIcon}"></Path>
|
<Path Style="{StaticResource FlatButtonPath}" Fill="{StaticResource LightGradientBrush}" Data="{StaticResource SkipEndFillIcon}"></Path>
|
||||||
</Button>
|
</Button>
|
||||||
|
<!--<Button Style="{StaticResource FlatButton}" Command="{Binding NextSongCommand}">
|
||||||
|
<Path Style="{StaticResource FlatButtonPath}" Fill="{StaticResource LightGradientBrush}" Data="{StaticResource RepeatIcon}"></Path>
|
||||||
|
</Button>-->
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user