37 lines
1.0 KiB
C#
Raw Normal View History

2023-05-11 23:11:39 -04:00
using ReactiveUI;
using SPTInstaller.Controllers;
using SPTInstaller.Helpers;
using SPTInstaller.Interfaces;
using SPTInstaller.Models;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
namespace SPTInstaller.ViewModels;
public class InstallViewModel : ViewModelBase
2023-05-11 23:11:39 -04:00
{
private IProgressableTask _currentTask;
2024-05-01 10:31:55 -04:00
public IProgressableTask CurrentTask
2023-05-11 23:11:39 -04:00
{
get => _currentTask;
set => this.RaiseAndSetIfChanged(ref _currentTask, value);
}
2024-05-01 10:31:55 -04:00
public ObservableCollection<InstallerTaskBase> MyTasks { get; set; } =
new(ServiceHelper.GetAll<InstallerTaskBase>());
public InstallViewModel(IScreen host) : base(host)
{
var installer = ServiceHelper.Get<InstallController>();
2024-05-01 10:31:55 -04:00
installer.TaskChanged += (sender, task) => CurrentTask = task;
2024-05-01 10:31:55 -04:00
Task.Run(async () =>
{
var result = await installer.RunTasks();
2024-05-01 10:31:55 -04:00
NavigateTo(new MessageViewModel(HostScreen, result));
});
2023-05-11 23:11:39 -04:00
}
}