Files
Better-Seewo/Installer/Pages/CompletePage.xaml.cs

110 lines
3.3 KiB
C#
Raw Normal View History

/*
* CompletePage.xaml.cs - Better-Seewo
*
*
*/
using System;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Controls;
namespace Better_Seewo.Installer.Pages
{
/// <summary>
/// CompletePage 的交互逻辑 - 安装向导完成页面
/// </summary>
public partial class CompletePage : Page
{
/// <summary>
/// 构造函数,初始化页面组件并填充安装摘要
/// </summary>
public CompletePage()
{
InitializeComponent();
// 填充安装摘要信息
LoadInstallSummary();
}
/// <summary>
/// 加载安装摘要信息到界面
/// </summary>
private void LoadInstallSummary()
{
// 版本号
TxtVersion.Text = $"v{App.AppVersion}";
// 安装路径
TxtInstallPath.Text = App.InstallPath;
// 安装时间
if (App.InstallStartTime != DateTime.MinValue)
{
var duration = DateTime.Now - App.InstallStartTime;
TxtInstallTime.Text = $"{App.InstallStartTime:yyyy-MM-dd HH:mm:ss} (耗时 {duration.TotalSeconds:F1} 秒)";
}
else
{
TxtInstallTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
}
/// <summary>
/// 启动管理器按钮点击 - 尝试启动 Better-Seewo Manager
/// </summary>
private void BtnLaunchManager_Click(object sender, RoutedEventArgs e)
{
try
{
// 尝试查找并启动管理器可执行文件
string managerPath = Path.Combine(
Path.GetDirectoryName(App.InstallPath),
"Better-Seewo.Manager.exe"
);
if (File.Exists(managerPath))
{
// 启动管理器
Process.Start(new ProcessStartInfo
{
FileName = managerPath,
UseShellExecute = true
});
// 关闭安装程序
Application.Current.Shutdown();
}
else
{
// 管理器文件不存在,提示用户
MessageBox.Show(
"未找到管理器程序。您可以稍后手动启动 Better-Seewo 管理器。",
"Better-Seewo 安装程序",
MessageBoxButton.OK,
MessageBoxImage.Information
);
}
}
catch (Exception ex)
{
MessageBox.Show(
$"启动管理器失败:{ex.Message}",
"Better-Seewo 安装程序",
MessageBoxButton.OK,
MessageBoxImage.Warning
);
}
}
/// <summary>
/// 关闭按钮点击 - 关闭安装程序
/// </summary>
private void BtnClose_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
}
}