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/Design/Views/Songs/SongsViewModel.cs

113 lines
2.5 KiB
C#
Raw Normal View History

2019-05-20 00:21:54 +00:00
using System.Collections.ObjectModel;
2019-07-05 18:17:09 +00:00
using Aurora.Models.Media;
using Aurora.Services;
using Xamarin.Forms;
2019-07-05 18:17:09 +00:00
namespace Aurora.Design.Views.Songs
{
public class SongsViewModel : BaseViewModel
{
#region Fields
private ObservableCollection<BaseMedia> _songsList;
private BaseMedia _selectedSong;
#endregion Fields
#region Constructor
public SongsViewModel()
{
_songsList = new ObservableCollection<BaseMedia>();
DoubleClickCommand = new Command(OnDoubleClickExecute, OnDoubleClickCanExecute);
Initialize();
}
#endregion Constructor
#region Properties
public ObservableCollection<BaseMedia> SongsList
{
get { return _songsList; }
set { SetProperty(ref _songsList, value); }
}
public BaseMedia SelectedSong
{
get { return _selectedSong; }
set { SetProperty(ref _selectedSong, value); }
}
public Command DoubleClickCommand { get; private set; }
#endregion Properties
#region Methods
public void Initialize()
{
2019-05-20 00:21:54 +00:00
SongsList = LibraryService.Instance.GetLibrary();
}
#endregion Methods
#region Commmands
2020-01-18 23:07:31 +00:00
public override bool CanPreviousButtonCommandExecute()
{
return true;
}
public override void OnPreviousButtonExecute()
{
}
2020-01-18 23:07:31 +00:00
public override bool CanPlayButtonCommandExecute()
2019-05-22 22:59:15 +00:00
{
return true;
2019-05-22 22:59:15 +00:00
}
2020-01-18 23:07:31 +00:00
public override void OnPlayButtonCommandExecute()
{
if (_selectedSong == null)
{
return;
}
if (base.IsPlaying())
{
base.ChangePlayerState(_selectedSong, Main.PlayAction.Pause);
}
else
{
base.ChangePlayerState(_selectedSong, Main.PlayAction.Play);
}
}
2020-01-18 23:07:31 +00:00
public override bool CanNextButtonCommandExecute()
{
return true;
}
public override void OnNextButtonExecute()
{
}
public void OnDoubleClickExecute()
{
if (_selectedSong == null)
{
return;
}
base.ChangePlayerState(_selectedSong, Main.PlayAction.Play);
}
public bool OnDoubleClickCanExecute()
{
return true;
}
#endregion Commands
}
}