89 lines
2.3 KiB
C#
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 = "下一步";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|