VaultSmpInstaller/Views/ProfileWindow1.axaml.cs

43 lines
1.4 KiB
C#

using System;
using System.Threading.Tasks;
using Avalonia.ReactiveUI;
using Avalonia.Threading;
using ReactiveUI;
using VaultSmpInstaller.ViewModels;
namespace VaultSmpInstaller.Views;
public partial class ProfileWindow1 : ReactiveWindow<ProfileWindow1ViewModel>
{
public ProfileWindow1()
{
InitializeComponent();
this.WhenActivated(d => d(ViewModel!.UseCurseforgeCommand.Subscribe(Close)));
this.WhenActivated(d => d(ViewModel!.UsePrismCommand.Subscribe(Close)));
this.WhenActivated(action => action(ViewModel!.ShowProfileSelectionDialog.RegisterHandler(DoShowDialogAsync)));
this.WhenActivated(_ =>
{
if (ViewModel!.IsOverwolfInstalled)
{
var removeOverwolfWindow = new RemoveOverwolfWindow();
removeOverwolfWindow.DataContext = new ThemeViewModel();
Dispatcher.UIThread.Invoke( () =>
{
removeOverwolfWindow.ShowDialog(this);
});
}
});
}
private async Task DoShowDialogAsync(InteractionContext<ProfileWindow2ViewModel, ProfileWindow2ViewModel.InstanceInfo?> interaction)
{
var dialog = new ProfileWindow2();
dialog.DataContext = interaction.Input;
var result = await dialog.ShowDialog<ProfileWindow2ViewModel.InstanceInfo?>(this);
interaction.SetOutput(result);
}
}