ui process update

This commit is contained in:
rmbgame
2021-03-02 04:51:43 +08:00
parent 0770a32145
commit 7aa74eae94
26 changed files with 489 additions and 31 deletions
@@ -0,0 +1,31 @@
using ReactiveUI;
namespace System.Application.UI.ViewModels
{
public class ItemViewModel : ViewModelBase
{
#region IsSelected 変更通知
private bool _IsSelected;
public virtual bool IsSelected
{
get => _IsSelected;
set => this.RaiseAndSetIfChanged(ref _IsSelected, value);
}
#endregion
#region IsShowTab 変更通知
private bool _IsShowTab = true;
public virtual bool IsShowTab
{
get => _IsShowTab;
set => this.RaiseAndSetIfChanged(ref _IsShowTab, value);
}
#endregion
}
}
@@ -0,0 +1,59 @@
using ReactiveUI;
using StatefulModel.EventListeners;
using System.Application.UI.Resx;
using System.Threading.Tasks;
namespace System.Application.UI.ViewModels
{
public abstract class TabItemViewModel : ItemViewModel
{
#region Name 変更通知
public abstract string Name { get; protected set; }
#endregion
#region Badge 変更通知
private int? _Badge;
public virtual int? Badge
{
get => _Badge;
protected set => this.RaiseAndSetIfChanged(ref _Badge, value);
}
#endregion
#region Status 変更通知
private ViewModelBase? _Status;
/// <summary>
/// 获取状态栏中显示的状态
/// </summary>
public virtual ViewModelBase? Status
{
get => _Status;
protected set => this.RaiseAndSetIfChanged(ref _Status, value);
}
#endregion
protected TabItemViewModel()
{
if (IsInDesignMode) return;
this.CompositeDisposable?.Add(new PropertyChangedEventListener(R.Current)
{
(sender, args) => this.RaisePropertyChanged(nameof(this.Name)),
});
}
internal async virtual Task Initialize()
{
await Task.CompletedTask;
}
}
}
@@ -5,7 +5,18 @@ namespace System.Application.UI.ViewModels
{
public class ViewModelBase : ReactiveObject, IDisposable
{
[NonSerialized] CompositeDisposable? _compositeDisposable;
[NonSerialized] private CompositeDisposable? _compositeDisposable = new CompositeDisposable();
public CompositeDisposable? CompositeDisposable
{
get => _compositeDisposable;
set
{
if (_compositeDisposable != value)
{
_compositeDisposable = value;
}
}
}
[NonSerialized] bool _disposed;
@@ -14,6 +25,7 @@ namespace System.Application.UI.ViewModels
/// </summary>
public static bool IsInDesignMode { get; set; }
/// <summary>
/// 释放该实例使用的所有资源
/// </summary>
@@ -26,7 +38,7 @@ namespace System.Application.UI.ViewModels
protected virtual void Dispose(bool disposing)
{
if (_disposed) return;
if (disposing) _compositeDisposable?.Dispose();
if (disposing) CompositeDisposable?.Dispose();
_disposed = true;
}
}
@@ -11,5 +11,10 @@ namespace System.Application.UI.ViewModels
get => title;
set => this.RaiseAndSetIfChanged(ref title, value);
}
protected void InvokeOnUIDispatcher(Action action)
{
MainThreadDesktop.BeginInvokeOnMainThread(action);
}
}
}