Files
Better-Seewo/Installer/MainWindow.xaml.cs
雾启工作室 fb7b924c0d feat: 从零重建项目架构
- Better-EN5 插件:基于官方示例,注册3个右键菜单项
- Manager 管理器:横版5标签布局,深色主题 WPF 应用
- 自定义 Fluent 安装器:无边框窗口,圆角,淡入淡出动画
- 删除旧代码,移除 SDK 自动安装器
- 三个项目全部编译通过(0 错误)
2026-06-28 12:40:10 +08:00

89 lines
2.3 KiB
C#

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using BetterSeewoInstaller.Pages;
namespace BetterSeewoInstaller;
public partial class MainWindow : Window
{
private int _currentPageIndex;
private readonly Page[] _pages;
public MainWindow()
{
InitializeComponent();
_pages = new Page[]
{
new WelcomePage(),
new InstallPage(),
new CompletePage()
};
NavigateToPage(0);
}
private void TitleBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.ClickCount == 1) DragMove();
}
private void BtnClose_Click(object sender, RoutedEventArgs e) => Close();
private void BtnBack_Click(object sender, RoutedEventArgs e)
{
if (_currentPageIndex > 0) NavigateToPage(_currentPageIndex - 1);
}
private void BtnNext_Click(object sender, RoutedEventArgs e)
{
if (_currentPageIndex < _pages.Length - 1)
NavigateToPage(_currentPageIndex + 1);
}
private void NavigateToPage(int index)
{
_currentPageIndex = index;
var oldContent = PageContent.Content;
var newContent = _pages[index];
// 淡出旧页面
var fadeOut = new DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(150));
fadeOut.Completed += (_, _) =>
{
PageContent.Content = newContent;
// 淡入新页面
var fadeIn = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));
PageContent.BeginAnimation(OpacityProperty, fadeIn);
UpdateButtons();
};
PageContent.BeginAnimation(OpacityProperty, fadeOut);
}
private void UpdateButtons()
{
StepText.Text = $"第 {_currentPageIndex + 1} 步,共 {_pages.Length} 步";
BtnBack.Visibility = _currentPageIndex > 0 ? Visibility.Visible : Visibility.Collapsed;
if (_currentPageIndex == _pages.Length - 1)
{
BtnNext.Content = "完成";
}
else if (_currentPageIndex == 1)
{
BtnNext.Content = "安装";
}
else
{
BtnNext.Content = "下一步";
}
}
}