2021-12-22 23:15:14 -05:00
|
|
|
using Avalonia;
|
|
|
|
using PatchGenerator.Models;
|
|
|
|
using ReactiveUI;
|
2021-12-28 19:44:25 -05:00
|
|
|
using System.Reactive;
|
|
|
|
using System.Reactive.Disposables;
|
2021-12-11 21:47:59 -05:00
|
|
|
|
|
|
|
namespace PatchGenerator.ViewModels
|
|
|
|
{
|
2021-12-28 19:44:25 -05:00
|
|
|
public class MainWindowViewModel : ReactiveObject, IActivatableViewModel, IScreen
|
2021-12-11 21:47:59 -05:00
|
|
|
{
|
2021-12-28 19:44:25 -05:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-12-25 20:24:00 -05:00
|
|
|
public MainWindowViewModel(GenStartupArgs genArgs = null)
|
2021-12-22 23:15:14 -05:00
|
|
|
{
|
2021-12-28 19:44:25 -05:00
|
|
|
this.WhenActivated((CompositeDisposable disposables) =>
|
2021-12-25 20:24:00 -05:00
|
|
|
{
|
|
|
|
|
2021-12-28 19:44:25 -05:00
|
|
|
if (genArgs != null && genArgs.ReadyToRun)
|
|
|
|
{
|
|
|
|
PatchGenInfo genInfo = new PatchGenInfo();
|
2021-12-25 20:24:00 -05:00
|
|
|
|
2021-12-28 19:44:25 -05:00
|
|
|
genInfo.TargetFolderPath = genArgs.TargetFolderPath;
|
|
|
|
genInfo.SourceFolderPath = genArgs.SourceFolderPath;
|
|
|
|
genInfo.PatchName = genArgs.OutputFolderName;
|
|
|
|
genInfo.AutoZip = genArgs.AutoZip;
|
2022-05-16 17:33:37 -04:00
|
|
|
genInfo.AutoClose = genArgs.AutoClose;
|
2021-12-28 19:44:25 -05:00
|
|
|
|
|
|
|
Router.Navigate.Execute(new PatchGenerationViewModel(this, genInfo));
|
|
|
|
return;
|
|
|
|
}
|
2021-12-25 20:24:00 -05:00
|
|
|
|
2021-12-28 19:44:25 -05:00
|
|
|
Router.Navigate.Execute(new OptionsViewModel(this));
|
|
|
|
});
|
2021-12-22 23:15:14 -05:00
|
|
|
}
|
2021-12-11 21:47:59 -05:00
|
|
|
}
|
|
|
|
}
|