mirror of
https://github.com/denglihong2007/CRSim
synced 2026-08-09 19:15:59 +08:00
feat: #113 添加仅加载当日车次
This commit is contained in:
@@ -25,5 +25,6 @@ namespace CRSim.Core.Models
|
||||
public int MaxPages { get; set; } = 3;
|
||||
public int SwitchPageSeconds { get; set; } = 20;
|
||||
public string UserKey { get; set; } = "";
|
||||
public bool LoadTodayOnly { get; set; } = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace CRSim.Core.Services
|
||||
_key.SetValue("PassingCheckInAdvanceDuration", (int)_settings.PassingCheckInAdvanceDuration.TotalMinutes);
|
||||
_key.SetValue("DepartureCheckInAdvanceDuration", (int)_settings.DepartureCheckInAdvanceDuration.TotalMinutes);
|
||||
_key.SetValue("UserKey", _settings.UserKey);
|
||||
_key.SetValue("LoadTodayOnly", _settings.LoadTodayOnly);
|
||||
}
|
||||
private void LoadSettings()
|
||||
{
|
||||
@@ -45,6 +46,7 @@ namespace CRSim.Core.Services
|
||||
if (_key.GetValue("PassingCheckInAdvanceDuration") != null) _settings.PassingCheckInAdvanceDuration = TimeSpan.FromMinutes((int)_key.GetValue("PassingCheckInAdvanceDuration"));
|
||||
if (_key.GetValue("DepartureCheckInAdvanceDuration") != null) _settings.DepartureCheckInAdvanceDuration = TimeSpan.FromMinutes((int)_key.GetValue("DepartureCheckInAdvanceDuration"));
|
||||
if (_key.GetValue("UserKey") != null) _settings.UserKey = (string)_key.GetValue("UserKey");
|
||||
if (_key.GetValue("LoadTodayOnly") != null) _settings.LoadTodayOnly = bool.Parse((string)_key.GetValue("LoadTodayOnly"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
public string _switchPageSeconds;
|
||||
[ObservableProperty]
|
||||
public string _userKey;
|
||||
[ObservableProperty]
|
||||
public bool _loadTodayOnly;
|
||||
#endregion
|
||||
public SettingsPageViewModel(ISettingsService settingsService, IDatabaseService databaseService, IDialogService dialogService)
|
||||
{
|
||||
@@ -53,6 +55,7 @@
|
||||
MaxPages = _settings.MaxPages.ToString();
|
||||
SwitchPageSeconds = _settings.SwitchPageSeconds.ToString();
|
||||
UserKey = _settings.UserKey;
|
||||
LoadTodayOnly = _settings.LoadTodayOnly;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -67,6 +70,7 @@
|
||||
UpdateSettings(MaxPages, false, value => _settings.MaxPages = value);
|
||||
UpdateSettings(SwitchPageSeconds, false, value => _settings.SwitchPageSeconds = value);
|
||||
_settings.UserKey = UserKey;
|
||||
_settings.LoadTodayOnly = LoadTodayOnly;
|
||||
_settingsService.SaveSettings();
|
||||
}
|
||||
private void UpdateSettings(string input,bool allowNegative, Action<int> updateAction)
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
<StackPanel Grid.Column="1" Margin="12" Orientation="Vertical">
|
||||
<TextBlock Text="显示" Style="{StaticResource BodyTextBlockStyle}"/>
|
||||
<TextBlock Opacity="0.7" Style="{StaticResource CaptionTextBlockStyle}">
|
||||
设置最大页数、切换时长
|
||||
设置最大页数、切换时长等
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
@@ -158,6 +158,18 @@
|
||||
<Expander.Content>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Border Style="{StaticResource TopSettingsCardStyle}">
|
||||
<Grid Margin="48,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="只加载当日车次" Style="{StaticResource BodyTextBlockStyle}" VerticalAlignment="Center"
|
||||
Grid.Column="0"/>
|
||||
<CheckBox Grid.Column="2" VerticalAlignment="Center" IsChecked="{Binding ViewModel.LoadTodayOnly, Mode=TwoWay}" Padding="0"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border Style="{StaticResource SettingsCardStyle}">
|
||||
<Grid Margin="48,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
@@ -208,7 +220,7 @@
|
||||
Text="" FontSize="20"/>
|
||||
|
||||
<StackPanel Grid.Column="1" Margin="12" Orientation="Vertical">
|
||||
<TextBlock Text="检票口" Style="{StaticResource BodyTextBlockStyle}"/>
|
||||
<TextBlock Text="检票" Style="{StaticResource BodyTextBlockStyle}"/>
|
||||
<TextBlock Opacity="0.7" Style="{StaticResource CaptionTextBlockStyle}">
|
||||
设置检票时长、停检时间等
|
||||
</TextBlock>
|
||||
|
||||
Reference in New Issue
Block a user