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

46 lines
1.7 KiB
C#
Raw Normal View History

2021-12-22 23:15:14 -05:00
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(() =>
2021-12-22 23:15:14 -05:00
{
if (Application.Current.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktopApp)
{
desktopApp.MainWindow.Close();
}
});
public MainWindowViewModel(GenStartupArgs genArgs = null)
2021-12-22 23:15:14 -05:00
{
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;
2024-05-04 10:56:49 -04:00
// issues with auto zip, but it's not really used anymore so just disabling for now
genInfo.AutoZip = false;
genInfo.AutoClose = genArgs.AutoClose;
Router.Navigate.Execute(new PatchGenerationViewModel(this, genInfo));
return;
}
Router.Navigate.Execute(new OptionsViewModel(this));
});
2021-12-22 23:15:14 -05:00
}
}
}