aurora/Aurora/Frontend/Views/Songs/SongsViewModel.cs

59 lines
1.3 KiB
C#
Raw Normal View History

2019-05-19 20:21:54 -04:00
using System.Collections.ObjectModel;
using Aurora.Backend.Models;
using Aurora.Backend.Services;
using Xamarin.Forms;
namespace Aurora.Frontend.Views.Songs
{
public class SongsViewModel : BaseViewModel
{
#region Fields
2019-05-19 20:25:31 -04:00
private ObservableCollection<BaseSong> _songsList;
private BaseSong _selectedSong;
#endregion Fields
#region Constructor
public SongsViewModel()
{
2019-05-19 20:25:31 -04:00
_songsList = new ObservableCollection<BaseSong>();
PlayCommand = new Command(PlayExecute);
Initialize();
}
#endregion Constructor
#region Properties
2019-05-19 20:25:31 -04:00
public ObservableCollection<BaseSong> SongsList
{
get { return _songsList; }
set { SetProperty(ref _songsList, value); }
}
2019-05-19 20:25:31 -04:00
public BaseSong SelectedSong
{
get { return _selectedSong; }
set { SetProperty(ref _selectedSong, value); }
}
public Command PlayCommand { get; private set; }
#endregion Properties
#region Methods
public void Initialize()
{
2019-05-19 20:21:54 -04:00
SongsList = LibraryService.Instance.GetLibrary();
}
2019-05-22 18:59:15 -04:00
public void PlayExecute()
{
PlayerService.Instance.Play(_selectedSong);
}
#endregion Methods
}
}