0
0
mirror of https://github.com/sp-tarkov/patcher.git synced 2025-02-13 07:50:49 -05:00
patcher/Patcher/PatchGenerator/ViewModels/MainWindowViewModel.cs

46 lines
1.6 KiB
C#

using Avalonia;
using PatchGenerator.Models;
using ReactiveUI;
using System.Reactive;
using System.Reactive.Disposables;
namespace PatchGenerator.ViewModels
{
public class MainWindowViewModel : ReactiveObject, IActivatableViewModel, IScreen
{
public RoutingState Router { get; } = new RoutingState();
public ViewModelActivator Activator { get; } = new ViewModelActivator();
public ReactiveCommand<Unit, Unit> CloseCommand => ReactiveCommand.Create(() =>
{
if (Application.Current.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktopApp)
{
desktopApp.MainWindow.Close();
}
});
public MainWindowViewModel(GenStartupArgs genArgs = null)
{
this.WhenActivated((CompositeDisposable disposables) =>
{
if (genArgs != null && genArgs.ReadyToRun)
{
PatchGenInfo genInfo = new PatchGenInfo();
genInfo.TargetFolderPath = genArgs.TargetFolderPath;
genInfo.SourceFolderPath = genArgs.SourceFolderPath;
genInfo.PatchName = genArgs.OutputFolderName;
genInfo.AutoZip = genArgs.AutoZip;
genInfo.AutoClose = genArgs.AutoClose;
Router.Navigate.Execute(new PatchGenerationViewModel(this, genInfo));
return;
}
Router.Navigate.Execute(new OptionsViewModel(this));
});
}
}
}