mirror of
https://github.com/denglihong2007/CRSim
synced 2026-08-11 20:29:45 +08:00
feat: 新增成都东站检票口立柱看板
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CRSim.Core.Models;
|
||||
using CRSim.Core.Services;
|
||||
using CRSim.ScreenSimulator.Models;
|
||||
using System.Windows;
|
||||
namespace CRSim.ScreenSimulator.ViewModels.ChengduDong
|
||||
{
|
||||
public partial class PillarTicketCheckScreenViewModel : ScreenViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private TrainInfo _firstTrain = new();
|
||||
[ObservableProperty]
|
||||
private TrainInfo _secondTrain = new();
|
||||
[ObservableProperty]
|
||||
private TrainInfo _checkingTrain = new();
|
||||
public PillarTicketCheckScreenViewModel(ITimeService timeService, ISettingsService settingsService)
|
||||
: base(timeService, settingsService)
|
||||
{
|
||||
StationType = StationType.Departure;
|
||||
timeService.RefreshSecondsElapsed += RefreshDisplay;
|
||||
Initialize();
|
||||
}
|
||||
private async void Initialize()
|
||||
{
|
||||
await WaitForDataLoadAsync();
|
||||
RefreshDisplay(null, null);
|
||||
}
|
||||
private void RefreshDisplay(object? sender, EventArgs e)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
var now = _timeService.GetDateTimeNow();
|
||||
var departureTime = TrainInfo[0].DepartureTime!.Value;
|
||||
|
||||
TimeSpan checkInStartOffset = TrainInfo[0].ArrivalTime is DateTime
|
||||
? _settings.PassingCheckInAdvanceDuration // 过路站
|
||||
: _settings.DepartureCheckInAdvanceDuration; // 始发站
|
||||
|
||||
bool checking = now > departureTime - checkInStartOffset && now < departureTime - _settings.StopCheckInAdvanceDuration;
|
||||
|
||||
if (checking)
|
||||
{
|
||||
CheckingTrain = TrainInfo[0];
|
||||
FirstTrain = TrainInfo.ElementAtOrDefault(1);
|
||||
SecondTrain = TrainInfo.ElementAtOrDefault(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckingTrain = null;
|
||||
FirstTrain = TrainInfo.ElementAtOrDefault(0);
|
||||
SecondTrain = TrainInfo.ElementAtOrDefault(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace CRSim.ScreenSimulator.ViewModels
|
||||
{
|
||||
public partial class ScreenViewModel : ObservableObject
|
||||
{
|
||||
private readonly ITimeService _timeService;
|
||||
public readonly ITimeService _timeService;
|
||||
public readonly Settings _settings;
|
||||
private readonly TaskCompletionSource<bool> _dataLoaded = new();
|
||||
[ObservableProperty]
|
||||
|
||||
Reference in New Issue
Block a user