mirror of
https://github.com/denglihong2007/CRSim
synced 2026-08-11 04:05:36 +08:00
feat: 添加徐州地铁站台看板
This commit is contained in:
@@ -16,7 +16,7 @@ namespace CRSim.ScreenSimulator.ViewModels.ChengduMetro
|
||||
[ObservableProperty]
|
||||
private string _text = "不吃火锅,就吃烤匠。 建设成渝地区双城经济圈,共同唱好新时代西部“双城记”。 2018年2月8日,复兴号列车首次担当G89次列车,正式开进四川,标志着“复兴号”高速列车正式走上蜀道。然而,在行驶至西安北站时,发生了突发设备故障,车轴出现过热报警,导致车号为CR400BF-5033的复兴号列车被迫停运并进行检修。相关工作人员迅速展开故障排查,并确保乘客安全无虞。";
|
||||
[ObservableProperty]
|
||||
private Uri _video = new("Assets\\Advertisement.mp4", UriKind.Relative);
|
||||
private Uri _video = new("Assets\\Advertisement-1.mp4", UriKind.Relative);
|
||||
|
||||
public List<TrainInfo> TrainInfos { get; set; } = [];
|
||||
public PlatformScreenViewModel(ITimeService timeService)
|
||||
@@ -24,12 +24,12 @@ namespace CRSim.ScreenSimulator.ViewModels.ChengduMetro
|
||||
_timeService = timeService;
|
||||
timeService.OneSecondElapsed += RefreshDisplay;
|
||||
}
|
||||
public void LoadData(Station station,string _ticketCheck,string _platform)
|
||||
public void LoadData(Station station,string _ticketCheck,string platform)
|
||||
{
|
||||
var trains = station.TrainStops;
|
||||
foreach (var trainNumber in trains)
|
||||
{
|
||||
if (trainNumber != null && trainNumber.DepartureTime != null)
|
||||
if (trainNumber != null && trainNumber.DepartureTime != null && trainNumber.Platform==platform)
|
||||
{
|
||||
var now = _timeService.GetDateTimeNow();
|
||||
var today = now.Date;
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CRSim.Core.Models;
|
||||
using CRSim.Core.Services;
|
||||
using CRSim.ScreenSimulator.Models;
|
||||
namespace CRSim.ScreenSimulator.ViewModels.XuzhouMetro
|
||||
{
|
||||
public partial class PlatformScreenViewModel : ObservableObject
|
||||
{
|
||||
private readonly ITimeService _timeService;
|
||||
[ObservableProperty]
|
||||
private DateTime _currentTime = new();
|
||||
[ObservableProperty]
|
||||
private TrainInfo _firstTrain = new();
|
||||
[ObservableProperty]
|
||||
private TrainInfo _secondTrain = new();
|
||||
[ObservableProperty]
|
||||
private string _text = "徐州,一座镌刻华夏文明印记的英雄之城。这里是大汉王朝的摇篮,楚风汉韵流淌在云龙山水间,龟山汉墓诉说着千年的传奇,汉画像石馆定格了古人的智慧光影。九里山前古战场,戏马台边秋风烈,历史的豪情从未褪色。作为五省通衢的枢纽,徐州以开放的胸怀连接南北,高铁飞驰、运河如练,现代脉动与古朴底蕴在此交融。登云龙山俯瞰一城青山半城湖,泛舟云龙湖感受水墨诗意;户部山的街巷藏着老徐州的烟火气,回龙窝的灯火点亮了夜色温柔。从地锅鸡的鲜香到饣它汤的醇厚,从酥脆的烙馍到清甜的蜜三刀,舌尖上的彭城满是热情滋味。这里是淮海之芯,用智造之光照亮未来,用楚汉气魄续写新章——徐州,等你共赴一场跨越时空的约定!";
|
||||
[ObservableProperty]
|
||||
private Uri _video = new("Assets\\Advertisement-2.mp4", UriKind.Relative);
|
||||
|
||||
public List<TrainInfo> TrainInfos { get; set; } = [];
|
||||
public PlatformScreenViewModel(ITimeService timeService)
|
||||
{
|
||||
_timeService = timeService;
|
||||
timeService.OneSecondElapsed += RefreshDisplay;
|
||||
}
|
||||
public void LoadData(Station station,string _ticketCheck,string platform)
|
||||
{
|
||||
var trains = station.TrainStops;
|
||||
foreach (var trainNumber in trains)
|
||||
{
|
||||
if (trainNumber != null && trainNumber.DepartureTime != null && trainNumber.Platform==platform)
|
||||
{
|
||||
var now = _timeService.GetDateTimeNow();
|
||||
var today = now.Date;
|
||||
|
||||
DateTime? AdjustTime(TimeSpan? time) =>
|
||||
time.HasValue ? (today.Add(time.Value) > now ? today.Add(time.Value) : today.Add(time.Value).AddDays(1)) : null;
|
||||
|
||||
TrainInfos.Add(new TrainInfo
|
||||
{
|
||||
TrainNumber = trainNumber.Number,
|
||||
Terminal = trainNumber.Terminal,
|
||||
ArrivalTime = AdjustTime(trainNumber.ArrivalTime),
|
||||
DepartureTime = AdjustTime(trainNumber.DepartureTime),
|
||||
State = TimeSpan.Zero
|
||||
});
|
||||
}
|
||||
}
|
||||
TrainInfos = [.. TrainInfos.OrderBy(x => x.ArrivalTime ?? x.DepartureTime)];
|
||||
}
|
||||
|
||||
private void RefreshDisplay(object? sender, EventArgs e)
|
||||
{
|
||||
CurrentTime = _timeService.GetDateTimeNow();
|
||||
List<TrainInfo> itemsToRemove = [.. TrainInfos.Where(info => info.DepartureTime < _timeService.GetDateTimeNow())];
|
||||
foreach (var item in itemsToRemove)
|
||||
{
|
||||
TrainInfos.Remove(item);
|
||||
}
|
||||
FirstTrain = TrainInfos.Count > 0 ? TrainInfos[0] : new();
|
||||
SecondTrain = TrainInfos.Count > 1 ? TrainInfos[1] : new();
|
||||
|
||||
OnPropertyChanged(nameof(FirstTrain));
|
||||
OnPropertyChanged(nameof(SecondTrain));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user