aurora/Aurora/Design/Views/BaseViewModel.cs

77 lines
1.7 KiB
C#
Raw Normal View History

using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Aurora.Models.Media;
using Xamarin.Forms;
2019-07-05 18:17:09 +00:00
namespace Aurora.Design.Views
{
public class BaseViewModel : INotifyPropertyChanged
{
public BaseViewModel()
{
}
#region Player
public virtual void PlayExecute()
{
}
public virtual bool PlayCanExecute()
{
return true;
}
public virtual void NextExecute()
{
}
public virtual bool NextCanExecute()
{
return true;
}
public virtual void PreviousExecute()
{
}
public virtual bool PreviousCanExecute()
{
return true;
}
public BaseMedia Media { get; set; }
#endregion Player
#region Lifecycle
public virtual void OnActive() { }
public virtual void OnInactive() { }
#endregion
#region INotifyPropertyChanged Implementation
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;
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
if (PropertyChanged == null)
return;
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
}