зеркало из https://github.com/DeGsoft/maui-linux.git
120 строки
2.7 KiB
C#
120 строки
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace Xamarin.Forms.Controls
|
|
{
|
|
public class HBaseViewModel : INotifyPropertyChanged
|
|
{
|
|
public HBaseViewModel()
|
|
{
|
|
}
|
|
|
|
private string title = string.Empty;
|
|
public const string TitlePropertyName = "Title";
|
|
|
|
/// <summary>
|
|
/// Gets or sets the "Title" property
|
|
/// </summary>
|
|
/// <value>The title.</value>
|
|
public string Title
|
|
{
|
|
get { return title; }
|
|
set { SetProperty(ref title, value); }
|
|
}
|
|
|
|
private string subtitle = string.Empty;
|
|
/// <summary>
|
|
/// Gets or sets the "Subtitle" property
|
|
/// </summary>
|
|
public const string SubtitlePropertyName = "Subtitle";
|
|
public string Subtitle
|
|
{
|
|
get { return subtitle; }
|
|
set { SetProperty(ref subtitle, value); }
|
|
}
|
|
|
|
private string icon = null;
|
|
/// <summary>
|
|
/// Gets or sets the "Icon" of the viewmodel
|
|
/// </summary>
|
|
public const string IconPropertyName = "Icon";
|
|
public string Icon
|
|
{
|
|
get { return icon; }
|
|
set { SetProperty(ref icon, value); }
|
|
}
|
|
|
|
bool isBusy;
|
|
|
|
/// <summary>
|
|
/// Gets or sets a value indicating whether this instance is busy.
|
|
/// </summary>
|
|
/// <value><c>true</c> if this instance is busy; otherwise, <c>false</c>.</value>
|
|
public bool IsBusy
|
|
{
|
|
get { return isBusy; }
|
|
set
|
|
{
|
|
if (SetProperty(ref isBusy, value))
|
|
IsNotBusy = !isBusy;
|
|
}
|
|
}
|
|
|
|
bool isNotBusy = true;
|
|
|
|
/// <summary>
|
|
/// Gets or sets a value indicating whether this instance is not busy.
|
|
/// </summary>
|
|
/// <value><c>true</c> if this instance is not busy; otherwise, <c>false</c>.</value>
|
|
public bool IsNotBusy
|
|
{
|
|
get { return isNotBusy; }
|
|
private set { SetProperty(ref isNotBusy, value); }
|
|
}
|
|
|
|
private bool canLoadMore = true;
|
|
/// <summary>
|
|
/// Gets or sets if we can load more.
|
|
/// </summary>
|
|
public const string CanLoadMorePropertyName = "CanLoadMore";
|
|
public bool CanLoadMore
|
|
{
|
|
get { return canLoadMore; }
|
|
set { SetProperty(ref canLoadMore, value); }
|
|
}
|
|
|
|
protected bool SetProperty<T>(
|
|
ref T backingStore, T value,
|
|
[CallerMemberName]string propertyName = "",
|
|
Action onChanged = null)
|
|
{
|
|
|
|
|
|
if (EqualityComparer<T>.Default.Equals(backingStore, value))
|
|
return false;
|
|
|
|
backingStore = value;
|
|
|
|
if (onChanged != null)
|
|
onChanged();
|
|
|
|
OnPropertyChanged(propertyName);
|
|
return true;
|
|
}
|
|
|
|
#region INotifyPropertyChanged implementation
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
#endregion
|
|
|
|
public void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
|
{
|
|
var changed = PropertyChanged;
|
|
if (changed == null)
|
|
return;
|
|
|
|
changed(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|
|
} |