доработаный
This commit is contained in:
@@ -1,11 +1,43 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using SpotXInstaller.ViewModels;
|
||||
|
||||
namespace SpotXInstaller.Views;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private bool _allowClose;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Closing += MainWindow_Closing;
|
||||
}
|
||||
}
|
||||
|
||||
private async void MainWindow_Closing(
|
||||
object? sender,
|
||||
WindowClosingEventArgs e)
|
||||
{
|
||||
if (_allowClose)
|
||||
return;
|
||||
|
||||
if (DataContext is not MainViewModel vm)
|
||||
return;
|
||||
|
||||
if (!vm.IsInstalling)
|
||||
return;
|
||||
|
||||
// Не закрываем окно мгновенно.
|
||||
// Сначала отменяем установку и убиваем process tree.
|
||||
e.Cancel = true;
|
||||
|
||||
await vm.CancelInstallationAsync();
|
||||
|
||||
_allowClose = true;
|
||||
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user