2021-12-19 21:37:31 -05:00
|
|
|
using Avalonia;
|
|
|
|
using ReactiveUI;
|
2021-12-28 19:44:25 -05:00
|
|
|
using System.Reactive.Disposables;
|
2021-12-19 21:37:31 -05:00
|
|
|
using System.Windows.Input;
|
2021-12-11 21:47:59 -05:00
|
|
|
|
|
|
|
namespace PatchClient.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 ViewModelActivator Activator { get; } = new ViewModelActivator();
|
|
|
|
public RoutingState Router { get; } = new RoutingState();
|
|
|
|
|
2021-12-19 21:37:31 -05:00
|
|
|
public ICommand CloseCommand => ReactiveCommand.Create(() =>
|
|
|
|
{
|
2021-12-25 01:17:01 -05:00
|
|
|
if (Application.Current.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktopApp)
|
2021-12-19 21:37:31 -05:00
|
|
|
{
|
|
|
|
desktopApp.MainWindow.Close();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-05-15 17:36:16 -04:00
|
|
|
public MainWindowViewModel(bool autoClose)
|
2021-12-11 21:47:59 -05:00
|
|
|
{
|
2021-12-28 19:44:25 -05:00
|
|
|
this.WhenActivated((CompositeDisposable disposable) =>
|
|
|
|
{
|
2022-05-15 17:36:16 -04:00
|
|
|
Router.Navigate.Execute(new PatcherViewModel(this, autoClose));
|
2021-12-28 19:44:25 -05:00
|
|
|
});
|
2021-12-11 21:47:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|