2019-05-18 21:25:36 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
2019-07-15 19:03:59 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2019-11-07 03:32:43 +00:00
|
|
|
|
using Aurora.Models.Media;
|
|
|
|
|
using Xamarin.Forms;
|
2019-11-09 00:54:51 +00:00
|
|
|
|
using Aurora.Design.Views.Main;
|
2019-05-18 21:25:36 +00:00
|
|
|
|
|
2019-07-05 18:17:09 +00:00
|
|
|
|
namespace Aurora.Design.Views
|
2019-05-18 21:25:36 +00:00
|
|
|
|
{
|
2019-11-09 00:54:51 +00:00
|
|
|
|
|
2019-05-22 14:30:41 +00:00
|
|
|
|
public class BaseViewModel : INotifyPropertyChanged
|
2019-05-18 21:25:36 +00:00
|
|
|
|
{
|
2019-11-09 00:54:51 +00:00
|
|
|
|
private BaseMedia _baseMedia;
|
2019-05-18 21:25:36 +00:00
|
|
|
|
public BaseViewModel()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-07 03:32:43 +00:00
|
|
|
|
#region Player
|
|
|
|
|
|
2019-11-09 00:54:51 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Command event handler for player play button
|
|
|
|
|
/// </summary>
|
2019-11-09 19:55:09 +00:00
|
|
|
|
public virtual void OnPlayButtonExecute() { }
|
|
|
|
|
public virtual bool CanPlayButtonExecute()
|
2019-11-07 03:32:43 +00:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-09 00:54:51 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Command event handler for player next button
|
|
|
|
|
/// </summary>
|
2019-11-09 19:55:09 +00:00
|
|
|
|
public virtual void OnNextButtonExecute() { }
|
|
|
|
|
public virtual bool CanNextButtonExecute()
|
2019-11-07 03:32:43 +00:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-09 00:54:51 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Command event handler for player previous button
|
|
|
|
|
/// </summary>
|
2019-11-09 19:55:09 +00:00
|
|
|
|
public virtual void OnPreviousButtonExecute() { }
|
|
|
|
|
public virtual bool CanPreviousButtonExecute()
|
2019-11-07 03:32:43 +00:00
|
|
|
|
{
|
2019-11-09 00:54:51 +00:00
|
|
|
|
return true;
|
2019-11-07 03:32:43 +00:00
|
|
|
|
}
|
2019-11-09 00:54:51 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Model for the currently playing music.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value></value>
|
|
|
|
|
public BaseMedia Media
|
2019-11-07 03:32:43 +00:00
|
|
|
|
{
|
2019-11-09 00:54:51 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this._baseMedia;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != _baseMedia)
|
|
|
|
|
{
|
|
|
|
|
_baseMedia = value;
|
|
|
|
|
if (this.SetPlayerMetadata != null)
|
|
|
|
|
{
|
|
|
|
|
SetPlayerMetadata.Invoke(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-07 03:32:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-09 00:54:51 +00:00
|
|
|
|
public SetPlayerMetadataDelegate SetPlayerMetadata { get; set; }
|
2019-11-07 03:32:43 +00:00
|
|
|
|
|
2019-11-09 19:55:09 +00:00
|
|
|
|
public SetPlayerVisibleDelegate SetPlayerVisible { get; set; }
|
|
|
|
|
|
2019-11-07 03:32:43 +00:00
|
|
|
|
#endregion Player
|
|
|
|
|
|
2019-07-15 19:03:59 +00:00
|
|
|
|
#region Lifecycle
|
|
|
|
|
public virtual void OnActive() { }
|
|
|
|
|
|
|
|
|
|
public virtual void OnInactive() { }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2019-05-18 21:25:36 +00:00
|
|
|
|
#region INotifyPropertyChanged Implementation
|
2019-05-22 14:30:41 +00:00
|
|
|
|
public bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
|
|
|
|
|
{
|
|
|
|
|
if (Object.Equals(storage, value))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
storage = value;
|
|
|
|
|
OnPropertyChanged(propertyName);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-18 21:25:36 +00:00
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
public void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
|
|
|
|
{
|
|
|
|
|
if (PropertyChanged == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|