diff --git a/CRSim.ScreenSimulator/Assets/ChengduDong/PillarTicketCheckScreen.png b/CRSim.ScreenSimulator/Assets/ChengduDong/PillarTicketCheckScreen.png new file mode 100644 index 0000000..e6a8b97 Binary files /dev/null and b/CRSim.ScreenSimulator/Assets/ChengduDong/PillarTicketCheckScreen.png differ diff --git a/CRSim.ScreenSimulator/Assets/ChengduDong/TicketCheck.png b/CRSim.ScreenSimulator/Assets/ChengduDong/TicketCheck.png new file mode 100644 index 0000000..f029b30 Binary files /dev/null and b/CRSim.ScreenSimulator/Assets/ChengduDong/TicketCheck.png differ diff --git a/CRSim.ScreenSimulator/Assets/ChengduDong/cdcz.png b/CRSim.ScreenSimulator/Assets/ChengduDong/cdcz.png new file mode 100644 index 0000000..81107b6 Binary files /dev/null and b/CRSim.ScreenSimulator/Assets/ChengduDong/cdcz.png differ diff --git a/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj b/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj index 5ba60b0..0dcd201 100644 --- a/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj +++ b/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj @@ -7,6 +7,12 @@ enable + + + + + + PreserveNewest @@ -38,6 +44,9 @@ Code + + Code + Code @@ -86,8 +95,11 @@ + + + diff --git a/CRSim.ScreenSimulator/Models/StylesInfoData.json b/CRSim.ScreenSimulator/Models/StylesInfoData.json index c268a50..c2847b4 100644 --- a/CRSim.ScreenSimulator/Models/StylesInfoData.json +++ b/CRSim.ScreenSimulator/Models/StylesInfoData.json @@ -22,6 +22,17 @@ "Text" ] }, + { + "UniqueId": "ChengduDong.PillarTicketCheckScreen", + "Title": "成都东站检票口立柱看板", + "Station": "成都东", + "Author": "电排骨", + "Type": "检票口屏", + "Parameters": [ + "Station", + "TicketCheck" + ] + }, { "UniqueId": "Fuzhou.TicketCheckScreen", "Title": "福州站检票口看板", diff --git a/CRSim.ScreenSimulator/ViewModels/ChengduDong/PillarTicketCheckScreenViewModel.cs b/CRSim.ScreenSimulator/ViewModels/ChengduDong/PillarTicketCheckScreenViewModel.cs new file mode 100644 index 0000000..469225e --- /dev/null +++ b/CRSim.ScreenSimulator/ViewModels/ChengduDong/PillarTicketCheckScreenViewModel.cs @@ -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); + } + }); + } + } +} diff --git a/CRSim.ScreenSimulator/ViewModels/ScreenViewModel.cs b/CRSim.ScreenSimulator/ViewModels/ScreenViewModel.cs index 29312ab..cc2b1ea 100644 --- a/CRSim.ScreenSimulator/ViewModels/ScreenViewModel.cs +++ b/CRSim.ScreenSimulator/ViewModels/ScreenViewModel.cs @@ -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 _dataLoaded = new(); [ObservableProperty] diff --git a/CRSim.ScreenSimulator/Views/ChengduDong/PillarTicketCheckScreenView.xaml b/CRSim.ScreenSimulator/Views/ChengduDong/PillarTicketCheckScreenView.xaml new file mode 100644 index 0000000..ab0ef6b --- /dev/null +++ b/CRSim.ScreenSimulator/Views/ChengduDong/PillarTicketCheckScreenView.xaml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim.ScreenSimulator/Views/ChengduDong/PillarTicketCheckScreenView.xaml.cs b/CRSim.ScreenSimulator/Views/ChengduDong/PillarTicketCheckScreenView.xaml.cs new file mode 100644 index 0000000..76f7db3 --- /dev/null +++ b/CRSim.ScreenSimulator/Views/ChengduDong/PillarTicketCheckScreenView.xaml.cs @@ -0,0 +1,37 @@ +using CRSim.ScreenSimulator.ViewModels.ChengduDong; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; + +namespace CRSim.ScreenSimulator.Views.ChengduDong +{ + /// + /// SecondaryScreen.xaml 的交互逻辑 + /// + public partial class PillarTicketCheckScreenView : Window + { + public PillarTicketCheckScreenViewModel ViewModel { get; } + public PillarTicketCheckScreenView(PillarTicketCheckScreenViewModel viewModel) + { + InitializeComponent(); + ViewModel = viewModel; + RenderOptions.SetEdgeMode(this, EdgeMode.Aliased); + DataContext = this; + } + private void Window_MouseDown(object sender, MouseButtonEventArgs e) + { + if (e.ChangedButton == MouseButton.Left) + { + DragMove(); + } + } + + private void Window_KeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Escape) + { + Close(); + } + } + } +}