using System.Diagnostics; using System.Windows; namespace LumaTunnel.Client.Installer; public partial class MainWindow : Window { public MainWindow() => InitializeComponent(); private async void OnInstall(object sender, RoutedEventArgs e) { InstallButton.IsEnabled = false; try { Progress.Value = 20; StatusText.Text = "正在复制文件…"; var executable = await InstallerActions.InstallAsync(ShortcutBox.IsChecked == true); Progress.Value = 100; StatusText.Text = "安装完成"; InstallButton.Content = "启动 LumaTunnel"; InstallButton.IsEnabled = true; InstallButton.Click -= OnInstall; InstallButton.Click += (_, _) => { Process.Start(new ProcessStartInfo(executable) { UseShellExecute = true }); Close(); }; } catch (Exception exception) { StatusText.Text = "安装失败:" + exception.Message; InstallButton.IsEnabled = true; } } }