Minor updatees.
This commit is contained in:
@@ -39,7 +39,19 @@ public class PlaylistViewModel : ViewModelBase
|
||||
private Timer? _filterTimer;
|
||||
|
||||
public Playlist? Playlist { get; private set; }
|
||||
public PlaylistSong? PlayingSong => _audioPlayer.PlayingSong;
|
||||
|
||||
private PlaylistSong? _playingSong;
|
||||
public PlaylistSong? PlayingSong
|
||||
{
|
||||
get
|
||||
{
|
||||
return _playingSong;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _playingSong, value);
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<PlaylistSong> _playlistSongs = [];
|
||||
public ObservableCollection<PlaylistSong> PlaylistSongs
|
||||
@@ -79,8 +91,7 @@ public class PlaylistViewModel : ViewModelBase
|
||||
}
|
||||
set
|
||||
{
|
||||
_filteredPlaylistSongs = value;
|
||||
OnPropertyChanged();
|
||||
SetProperty(ref _filteredPlaylistSongs, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +117,6 @@ public class PlaylistViewModel : ViewModelBase
|
||||
public ICommand CopySongsCommand => new AsyncRelayCommand(CopySongsAsync, AreSongsSelected);
|
||||
public ICommand PasteSongsCommand => new AsyncRelayCommand(PasteSongsAsync, CanPasteSongs);
|
||||
public ICommand OpenFileLocationCommand => new RelayCommand(OpenFileLocation, AreSongsSelected);
|
||||
|
||||
public ICommand RefreshTagsCommand => new RelayCommand(RefreshTags);
|
||||
public ICommand RemoveMissingSongsCommand => new RelayCommand(RemoveMissingSongs);
|
||||
public ICommand RemoveDuplicateSongsCommand => new RelayCommand(RemoveDuplicateSongs);
|
||||
@@ -186,7 +196,8 @@ public class PlaylistViewModel : ViewModelBase
|
||||
|
||||
private void OnAudioPlayerPlayingSongChanged(object? sender, EventArgs e)
|
||||
{
|
||||
OnPropertyChanged(nameof(PlayingSong));
|
||||
//OnPropertyChanged(nameof(PlayingSong));
|
||||
PlayingSong = _audioPlayer.PlayingSong;
|
||||
}
|
||||
|
||||
public async Task PlaySongAsync(PlaylistSong playlistSong)
|
||||
@@ -414,60 +425,44 @@ public class PlaylistViewModel : ViewModelBase
|
||||
|
||||
private bool CanPasteSongs()
|
||||
{
|
||||
if (Playlist == null)
|
||||
return false;
|
||||
|
||||
IClipboard? clipboard = _clipboardLocator.Get();
|
||||
|
||||
if (clipboard == null)
|
||||
return false;
|
||||
|
||||
string? clipboardText = clipboard.GetTextAsync().Result;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(clipboardText))
|
||||
return false;
|
||||
|
||||
Song[] songs = [];
|
||||
|
||||
try
|
||||
{
|
||||
songs = JsonSerializer.Deserialize<Song[]>(clipboardText) ?? [];
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return songs.Length > 0;
|
||||
return GetSongsFromClipboardAsync().Result.Length > 0;
|
||||
}
|
||||
|
||||
private async Task PasteSongsAsync()
|
||||
{
|
||||
if (Playlist == null)
|
||||
if (Playlist == null || SelectedPlaylistSongs.Count == 0)
|
||||
return;
|
||||
|
||||
int selectedPlaylistSongIndex = Playlist.Songs.IndexOf(SelectedPlaylistSongs[0]);
|
||||
|
||||
if (selectedPlaylistSongIndex == -1)
|
||||
return;
|
||||
|
||||
Song[] songs = await GetSongsFromClipboardAsync();
|
||||
|
||||
Playlist.AddSongs(songs, selectedPlaylistSongIndex + 1);
|
||||
}
|
||||
|
||||
private async Task<Song[]> GetSongsFromClipboardAsync()
|
||||
{
|
||||
IClipboard? clipboard = _clipboardLocator.Get();
|
||||
|
||||
if (clipboard == null)
|
||||
return;
|
||||
return [];
|
||||
|
||||
string? clipboardText = await clipboard.GetTextAsync();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(clipboardText))
|
||||
return;
|
||||
|
||||
Song[] songs = [];
|
||||
return [];
|
||||
|
||||
try
|
||||
{
|
||||
songs = JsonSerializer.Deserialize<Song[]>(clipboardText) ?? [];
|
||||
return JsonSerializer.Deserialize<Song[]>(clipboardText) ?? [];
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
Playlist.AddSongs(songs);
|
||||
}
|
||||
|
||||
private void OpenFileLocation()
|
||||
|
||||
Reference in New Issue
Block a user