feat: 优化流程
This commit is contained in:
57
PetWashControl/Views/CompletionDialog.xaml.cs
Normal file
57
PetWashControl/Views/CompletionDialog.xaml.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace PetWashControl.Views
|
||||
{
|
||||
public partial class CompletionDialog : Window
|
||||
{
|
||||
private DispatcherTimer? _countdownTimer;
|
||||
private int _remainingSeconds = 30;
|
||||
|
||||
public CompletionDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
StartCountdown();
|
||||
}
|
||||
|
||||
private void StartCountdown()
|
||||
{
|
||||
_countdownTimer = new DispatcherTimer
|
||||
{
|
||||
Interval = TimeSpan.FromSeconds(1)
|
||||
};
|
||||
_countdownTimer.Tick += CountdownTimer_Tick;
|
||||
_countdownTimer.Start();
|
||||
}
|
||||
|
||||
private void CountdownTimer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
_remainingSeconds--;
|
||||
|
||||
if (_remainingSeconds > 0)
|
||||
{
|
||||
CountdownText.Text = $"{_remainingSeconds}秒后自动返回首页";
|
||||
}
|
||||
else
|
||||
{
|
||||
_countdownTimer?.Stop();
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void OkButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_countdownTimer?.Stop();
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
_countdownTimer?.Stop();
|
||||
base.OnClosed(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user