mirror of
https://github.com/denglihong2007/CRSim
synced 2026-08-06 01:06:27 +08:00
feat: 添加大庆东站站台屏和哈尔滨西站站台屏
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
using CRSim.Core.Services;
|
||||
using CRSim.ScreenSimulator.Models;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
namespace CRSim.ScreenSimulator.ViewModels.DaqingDong
|
||||
{
|
||||
public class PlatformScreenViewModel : ScreenViewModel
|
||||
{
|
||||
private ITimeService _timeService;
|
||||
public ObservableCollection<TrainInfo> Screen { get; set; } = [];
|
||||
public PlatformScreenViewModel(ITimeService timeService, ISettingsService settingsService)
|
||||
: base(timeService, settingsService)
|
||||
{
|
||||
_timeService = timeService;
|
||||
timeService.RefreshSecondsElapsed += RefreshDisplay;
|
||||
Text = $"请站在白色安全线以内排队候车";
|
||||
Initialize();
|
||||
}
|
||||
private async void Initialize()
|
||||
{
|
||||
await WaitForDataLoadAsync();
|
||||
RefreshDisplay(null,null);
|
||||
}
|
||||
private void RefreshDisplay(object? sender, EventArgs e)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Screen.Add(TrainInfo.Count > 0 ? TrainInfo[0] : new());
|
||||
if (Screen.Count == 1) return;
|
||||
Screen.RemoveAt(0);
|
||||
});
|
||||
}
|
||||
public override void RefreshData(object? sender, EventArgs e)
|
||||
{
|
||||
if (CurrentPageIndex == 0)
|
||||
{
|
||||
List<TrainInfo> itemsToRemove = [];
|
||||
foreach (TrainInfo trainInfo in TrainInfo)
|
||||
{
|
||||
if (trainInfo.DepartureTime == null)
|
||||
{
|
||||
if (trainInfo.ArrivalTime.Value.Add(_settings.StopDisplayFromArrivalDuration) < _timeService.GetDateTimeNow())
|
||||
{
|
||||
itemsToRemove.Add(trainInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (trainInfo.DepartureTime.Value < _timeService.GetDateTimeNow())
|
||||
{
|
||||
itemsToRemove.Add(trainInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var item in itemsToRemove)
|
||||
{
|
||||
TrainInfo.Remove(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using CRSim.Core.Services;
|
||||
using CRSim.ScreenSimulator.Models;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
namespace CRSim.ScreenSimulator.ViewModels.HarbinXi
|
||||
{
|
||||
public class PlatformScreenViewModel : ScreenViewModel
|
||||
{
|
||||
private ITimeService _timeService;
|
||||
public ObservableCollection<TrainInfo> Screen { get; set; } = [];
|
||||
public PlatformScreenViewModel(ITimeService timeService, ISettingsService settingsService)
|
||||
: base(timeService, settingsService)
|
||||
{
|
||||
_timeService = timeService;
|
||||
timeService.RefreshSecondsElapsed += RefreshDisplay;
|
||||
Text = $"请在白线内行走,乘降列车时注意脚下站台与列车之间的空隙,看护好老人和儿童。";
|
||||
Initialize();
|
||||
}
|
||||
private async void Initialize()
|
||||
{
|
||||
await WaitForDataLoadAsync();
|
||||
RefreshDisplay(null,null);
|
||||
}
|
||||
private void RefreshDisplay(object? sender, EventArgs e)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Screen.Add(TrainInfo.Count > 0 ? TrainInfo[0] : new());
|
||||
if (Screen.Count == 1) return;
|
||||
Screen.RemoveAt(0);
|
||||
});
|
||||
}
|
||||
public override void RefreshData(object? sender, EventArgs e)
|
||||
{
|
||||
if (CurrentPageIndex == 0)
|
||||
{
|
||||
List<TrainInfo> itemsToRemove = [];
|
||||
foreach (TrainInfo trainInfo in TrainInfo)
|
||||
{
|
||||
if (trainInfo.DepartureTime == null)
|
||||
{
|
||||
if (trainInfo.ArrivalTime.Value.Add(_settings.StopDisplayFromArrivalDuration) < _timeService.GetDateTimeNow())
|
||||
{
|
||||
itemsToRemove.Add(trainInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (trainInfo.DepartureTime.Value < _timeService.GetDateTimeNow())
|
||||
{
|
||||
itemsToRemove.Add(trainInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var item in itemsToRemove)
|
||||
{
|
||||
TrainInfo.Remove(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user