mirror of
https://github.com/denglihong2007/CRSim
synced 2026-08-11 04:05:36 +08:00
feat: #113 添加仅加载当日车次
This commit is contained in:
@@ -2,11 +2,13 @@
|
||||
using CRSim.Core.Models;
|
||||
using CRSim.Core.Services;
|
||||
using CRSim.ScreenSimulator.Models;
|
||||
using System.Runtime;
|
||||
namespace CRSim.ScreenSimulator.ViewModels.ChengduMetro
|
||||
{
|
||||
public partial class PlatformScreenViewModel : ObservableObject
|
||||
{
|
||||
private readonly ITimeService _timeService;
|
||||
public readonly Settings _settings;
|
||||
[ObservableProperty]
|
||||
private DateTime _currentTime = new();
|
||||
[ObservableProperty]
|
||||
@@ -19,9 +21,10 @@ namespace CRSim.ScreenSimulator.ViewModels.ChengduMetro
|
||||
private Uri _video = new("Assets\\Advertisement-1.mp4", UriKind.Relative);
|
||||
|
||||
public List<TrainInfo> TrainInfos { get; set; } = [];
|
||||
public PlatformScreenViewModel(ITimeService timeService)
|
||||
public PlatformScreenViewModel(ITimeService timeService, ISettingsService settingsService)
|
||||
{
|
||||
_timeService = timeService;
|
||||
_settings = settingsService.GetSettings();
|
||||
timeService.OneSecondElapsed += RefreshDisplay;
|
||||
}
|
||||
public void LoadData(Station station,string _ticketCheck,string platform)
|
||||
@@ -33,7 +36,10 @@ namespace CRSim.ScreenSimulator.ViewModels.ChengduMetro
|
||||
{
|
||||
var now = _timeService.GetDateTimeNow();
|
||||
var today = now.Date;
|
||||
|
||||
if (_settings.LoadTodayOnly && today.Add((trainNumber.DepartureTime ?? trainNumber.ArrivalTime)!.Value) < now)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
DateTime? AdjustTime(TimeSpan? time) =>
|
||||
time.HasValue ? (today.Add(time.Value) > now ? today.Add(time.Value) : today.Add(time.Value).AddDays(1)) : null;
|
||||
|
||||
|
||||
@@ -97,6 +97,11 @@ namespace CRSim.ScreenSimulator.ViewModels
|
||||
var now = _timeService.GetDateTimeNow();
|
||||
var today = now.Date;
|
||||
|
||||
if (_settings.LoadTodayOnly && today.Add((trainNumber.DepartureTime??trainNumber.ArrivalTime)!.Value) < now)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
DateTime? AdjustTime(TimeSpan? time) =>
|
||||
time.HasValue ? (today.Add(time.Value) > now ? today.Add(time.Value) : today.Add(time.Value).AddDays(1)) : null;
|
||||
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
using CRSim.Core.Models;
|
||||
using CRSim.Core.Services;
|
||||
using CRSim.ScreenSimulator.Models;
|
||||
using System.Runtime;
|
||||
namespace CRSim.ScreenSimulator.ViewModels.XuzhouMetro
|
||||
{
|
||||
public partial class PlatformScreenViewModel : ObservableObject
|
||||
{
|
||||
private readonly ITimeService _timeService;
|
||||
public readonly Settings _settings;
|
||||
[ObservableProperty]
|
||||
private DateTime _currentTime = new();
|
||||
[ObservableProperty]
|
||||
@@ -19,9 +21,10 @@ namespace CRSim.ScreenSimulator.ViewModels.XuzhouMetro
|
||||
private Uri _video = new("Assets\\Advertisement-2.mp4", UriKind.Relative);
|
||||
|
||||
public List<TrainInfo> TrainInfos { get; set; } = [];
|
||||
public PlatformScreenViewModel(ITimeService timeService)
|
||||
public PlatformScreenViewModel(ITimeService timeService, ISettingsService settingsService)
|
||||
{
|
||||
_timeService = timeService;
|
||||
_settings = settingsService.GetSettings();
|
||||
timeService.OneSecondElapsed += RefreshDisplay;
|
||||
}
|
||||
public void LoadData(Station station,string _ticketCheck,string platform)
|
||||
@@ -33,7 +36,10 @@ namespace CRSim.ScreenSimulator.ViewModels.XuzhouMetro
|
||||
{
|
||||
var now = _timeService.GetDateTimeNow();
|
||||
var today = now.Date;
|
||||
|
||||
if (_settings.LoadTodayOnly && today.Add((trainNumber.DepartureTime ?? trainNumber.ArrivalTime)!.Value) < now)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
DateTime? AdjustTime(TimeSpan? time) =>
|
||||
time.HasValue ? (today.Add(time.Value) > now ? today.Add(time.Value) : today.Add(time.Value).AddDays(1)) : null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user