mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-21 09:02:26 +08:00
ui process update
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using System.Application.UI.ViewModels;
|
||||
|
||||
namespace System.Application
|
||||
{
|
||||
public static class ViewModelExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="IDisposable"/> 将对象添加到<see cref="ViewModelBase"/> 的<see cref="ViewModelBase.CompositeDisposable"/>中
|
||||
/// </summary>
|
||||
public static T AddTo<T>(this T disposable, ViewModelBase vm) where T : IDisposable
|
||||
{
|
||||
if (vm == null)
|
||||
{
|
||||
disposable.Dispose();
|
||||
return disposable;
|
||||
}
|
||||
|
||||
vm.CompositeDisposable.Add(disposable);
|
||||
return disposable;
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -61,6 +61,12 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Scripts\*.js">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="UI\ViewModels\Pages\" />
|
||||
<Folder Include="UI\ViewModels\Windows\" />
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,20 +9,55 @@ namespace System.Application.UI.ViewModels
|
||||
{
|
||||
public class MainWindowViewModel : WindowViewModel
|
||||
{
|
||||
bool mTopmost;
|
||||
#region 更改通知
|
||||
|
||||
bool mTopmost;
|
||||
public bool Topmost
|
||||
{
|
||||
get => mTopmost;
|
||||
set => this.RaiseAndSetIfChanged(ref mTopmost, value);
|
||||
}
|
||||
public SettingsPageViewModel SettingsPage { get; }
|
||||
|
||||
private TabItemViewModel _SelectedItem;
|
||||
public TabItemViewModel SelectedItem
|
||||
{
|
||||
get => _SelectedItem;
|
||||
set => this.RaiseAndSetIfChanged(ref _SelectedItem, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public StartPageViewModel StartPage { get; }
|
||||
public GameListPageViewModel GameListPage { get; }
|
||||
public SteamAccountPageViewModel SteamAccountPage { get; }
|
||||
|
||||
|
||||
public IList<TabItemViewModel> TabItems { get; set; }
|
||||
|
||||
|
||||
|
||||
public MainWindowViewModel() : base()
|
||||
{
|
||||
Title = ThisAssembly.AssemblyTrademark;
|
||||
SettingsPage = new SettingsPageViewModel();
|
||||
|
||||
this.TabItems = new List<TabItemViewModel>
|
||||
{
|
||||
(this.StartPage = new StartPageViewModel().AddTo(this)),
|
||||
(this.SteamAccountPage = new SteamAccountPageViewModel().AddTo(this)),
|
||||
(this.GameListPage = new GameListPageViewModel().AddTo(this)),
|
||||
|
||||
|
||||
|
||||
#region SystemTab
|
||||
SettingsPageViewModel.Instance,
|
||||
AboutPageViewModel.Instance,
|
||||
#if DEBUG
|
||||
new DebugPageViewModel().AddTo(this),
|
||||
#endif
|
||||
#endregion
|
||||
};
|
||||
|
||||
this.SelectedItem = this.TabItems.First();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
using System.Application.UI.Resx;
|
||||
|
||||
namespace System.Application.UI.ViewModels
|
||||
{
|
||||
public class AboutPageViewModel : TabItemViewModel
|
||||
{
|
||||
public static AboutPageViewModel Instance { get; } = new AboutPageViewModel();
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get => AppResources.About;
|
||||
protected set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
using ReactiveUI;
|
||||
using System.Application.UI.Resx;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace System.Application.UI.ViewModels
|
||||
{
|
||||
public class DebugPageViewModel : TabItemViewModel
|
||||
{
|
||||
public override string Name
|
||||
{
|
||||
get => "Debug";
|
||||
protected set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
private string _DebugString = string.Empty;
|
||||
public string DebugString
|
||||
{
|
||||
get => _DebugString;
|
||||
protected set => this.RaiseAndSetIfChanged(ref _DebugString, value);
|
||||
}
|
||||
|
||||
public DebugPageViewModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void DebugButton_Click()
|
||||
{
|
||||
DebugString += "Test Command" + Environment.NewLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using System.Application.UI.Resx;
|
||||
|
||||
namespace System.Application.UI.ViewModels
|
||||
{
|
||||
public class GameListPageViewModel : TabItemViewModel
|
||||
{
|
||||
public override string Name
|
||||
{
|
||||
get => AppResources.GameList;
|
||||
protected set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+9
-1
@@ -5,8 +5,16 @@ using System.Linq;
|
||||
|
||||
namespace System.Application.UI.ViewModels
|
||||
{
|
||||
public class SettingsPageViewModel : ViewModelBase
|
||||
public class SettingsPageViewModel : TabItemViewModel
|
||||
{
|
||||
public static SettingsPageViewModel Instance { get; } = new SettingsPageViewModel();
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get => AppResources.Settings;
|
||||
protected set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public SettingsPageViewModel()
|
||||
{
|
||||
//Languages = R.Languages.Select(Convert).ToList();
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using System.Application.UI.Resx;
|
||||
|
||||
namespace System.Application.UI.ViewModels
|
||||
{
|
||||
public class StartPageViewModel : TabItemViewModel
|
||||
{
|
||||
public override string Name
|
||||
{
|
||||
get => AppResources.Welcome;
|
||||
protected set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using System.Application.UI.Resx;
|
||||
|
||||
namespace System.Application.UI.ViewModels
|
||||
{
|
||||
public class SteamAccountPageViewModel : TabItemViewModel
|
||||
{
|
||||
public override string Name
|
||||
{
|
||||
get => AppResources.UserFastChange;
|
||||
protected set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user