XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEToolBox

【WPF】XFE工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
using CommunityToolkit.Mvvm.Input;
using System.Diagnostics;
using System.IO;
using XFEToolBox.Client.Installer.Profiles;
using XFEToolBox.Client.Installer.Utilities;
using XFEToolBox.Client.Installer.ViewModel.Windows;
using XFEToolBox.Client.Installer.Views.Pages;

namespace XFEToolBox.Client.Installer.ViewModel.Pages
{
    public partial class InstallProgressPageViewModel(InstallProgressPage viewPage) : ViewModelBase
    {
        public InstallProgressPage ViewPage { get; set; } = viewPage;

        [RelayCommand]
        void ConfirmSuccess()
        {
            var executablePath = Path.Combine(SystemProfile.InstallPath, SystemProfile.ApplicationExecutableName);
            if (!File.Exists(executablePath))
            {
                PopupHelper.ShowConfirmDialog($"无法启动 XFEToolBox:未找到 {SystemProfile.ApplicationExecutableName}。", confirmText: "确定");
                return;
            }

            try
            {
                var startInfo = new ProcessStartInfo(executablePath)
                {
                    UseShellExecute = true,
                    WorkingDirectory = SystemProfile.InstallPath
                };
                if (Process.Start(startInfo) is null)
                    throw new InvalidOperationException("系统未能创建应用进程。");
                MainWindowViewModel.CloseWindow();
            }
            catch (Exception exception)
            {
                PopupHelper.ShowConfirmDialog($"无法启动 XFEToolBox:\n{exception.Message}", confirmText: "确定");
            }
        }
    }
}