35 lines
987 B
C#
Raw Permalink 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;
public IProgressableTask CurrentTask
2023-05-11 23:11:39 -04:00
{
get => _currentTask;
set => this.RaiseAndSetIfChanged(ref _currentTask, value);
}
2023-05-11 23:11:39 -04:00
public ObservableCollection<InstallerTaskBase> MyTasks { get; set; } = new(ServiceHelper.GetAll<InstallerTaskBase>());
2023-05-11 23:11:39 -04:00
public InstallViewModel(IScreen host) : base(host)
{
var installer = ServiceHelper.Get<InstallController>();
2023-05-11 23:11:39 -04:00
installer.TaskChanged += (sender, task) => CurrentTask = task;
2023-05-11 23:11:39 -04:00
Task.Run(async () =>
{
var result = await installer.RunTasks();
2023-05-11 23:11:39 -04:00
NavigateTo(new MessageViewModel(HostScreen, result));
});
2023-05-11 23:11:39 -04:00
}
}