This repository has been archived on 2020-12-20. You can view files and clone it, but cannot push or open issues or pull requests.
aurora-sharp-desktop/Aurora/Frontend/Views/Songs/SongsViewModel.cs

64 lines
1.4 KiB
C#

using System.Collections.ObjectModel;
using Aurora.Backend.Models;
using Aurora.Backend.Services;
using Aurora.Backend.Services.PlayerService;
using Xamarin.Forms;
namespace Aurora.Frontend.Views.Songs
{
public class SongsViewModel : BaseViewModel
{
#region Fields
private ObservableCollection<BaseSong> _songsList;
private BaseSong _selectedSong;
#endregion Fields
#region Constructor
public SongsViewModel()
{
_songsList = new ObservableCollection<BaseSong>();
PlayCommand = new Command(PlayExecute);
Initialize();
}
#endregion Constructor
#region Properties
public ObservableCollection<BaseSong> SongsList
{
get { return _songsList; }
set { SetProperty(ref _songsList, value); }
}
public BaseSong SelectedSong
{
get { return _selectedSong; }
set { SetProperty(ref _selectedSong, value); }
}
public Command PlayCommand { get; private set; }
#endregion Properties
#region Methods
public void Initialize()
{
SongsList = LibraryService.Instance.GetLibrary();
}
private void PlayExecute()
{
if (_selectedSong != null)
{
PlayerService.Instance.Play(_selectedSong);
}
}
#endregion Methods
}
}