feat: 优化UI

This commit is contained in:
GukSang.Jin
2026-02-26 13:49:38 +08:00
parent 5f52b06ac2
commit 76c594e14a
4 changed files with 102 additions and 6 deletions

View File

@@ -71,6 +71,23 @@ public partial class MainViewModel : ObservableObject
[ObservableProperty]
private double _roomTemperature = 25.0;
[ObservableProperty]
private string _currentCarouselImage = "/Images/dog.png";
[ObservableProperty]
private string _deviceNumber = "设备编号: PW-001";
[ObservableProperty]
private string _currentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
[ObservableProperty]
private string _currentDayOfWeek = DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("zh-CN"));
private readonly System.Timers.Timer _carouselTimer;
private readonly System.Timers.Timer _clockTimer;
private readonly string[] _carouselImages = { "/Images/dog.png", "/Images/dog1.jpg" };
private int _currentImageIndex = 0;
public MainViewModel()
{
_config = new ConfigurationService();
@@ -81,6 +98,31 @@ public partial class MainViewModel : ObservableObject
// 初始化洗护步骤
InitializeWashSteps();
// 初始化图片轮播定时器每5秒切换
_carouselTimer = new System.Timers.Timer(5000);
_carouselTimer.Elapsed += (s, e) =>
{
Application.Current.Dispatcher.Invoke(() =>
{
_currentImageIndex = (_currentImageIndex + 1) % _carouselImages.Length;
CurrentCarouselImage = _carouselImages[_currentImageIndex];
});
};
_carouselTimer.Start();
// 初始化时钟定时器(每秒更新)
_clockTimer = new System.Timers.Timer(1000);
_clockTimer.Elapsed += (s, e) =>
{
Application.Current.Dispatcher.Invoke(() =>
{
var now = DateTime.Now;
CurrentDateTime = now.ToString("yyyy-MM-dd HH:mm:ss");
CurrentDayOfWeek = now.ToString("dddd", new System.Globalization.CultureInfo("zh-CN"));
});
};
_clockTimer.Start();
}
private void InitializeWashSteps()