diff --git a/CRSim.ScreenSimulator/Converters/TrainInfoToTicketCheckTimeConverter.cs b/CRSim.ScreenSimulator/Converters/TrainInfoToTicketCheckTimeConverter.cs new file mode 100644 index 0000000..e50885e --- /dev/null +++ b/CRSim.ScreenSimulator/Converters/TrainInfoToTicketCheckTimeConverter.cs @@ -0,0 +1,35 @@ +using CRSim.Core.Models; +using CRSim.Core.Services; +using CRSim.ScreenSimulator.Models; +using Microsoft.Extensions.DependencyInjection; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace CRSim.ScreenSimulator.Converters +{ + public class TrainInfoToTicketCheckTimeConverter : IValueConverter + { + private ITimeService _timeService; + private Settings _settings; + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is TrainInfo trainInfo && trainInfo.DepartureTime!=null) + { + var serviceProvider = (IServiceProvider)Application.Current.Resources["ServiceProvider"]; + _timeService = serviceProvider.GetRequiredService(); + _settings = serviceProvider.GetRequiredService().GetSettings(); + if (trainInfo.ArrivalTime == null) + { + return trainInfo.DepartureTime.Value.Subtract(_settings.DepartureCheckInAdvanceDuration).ToString("HH:mm");//始发车 + } + return trainInfo.DepartureTime.Value.Subtract(_settings.PassingCheckInAdvanceDuration).ToString("HH:mm");//过路车 + } + return string.Empty; + } + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/CRSim.ScreenSimulator/ViewModels/Windows/Stations/FuzhouNan/TicketCheckScreenViewModel.cs b/CRSim.ScreenSimulator/ViewModels/Windows/Stations/FuzhouNan/TicketCheckScreenViewModel.cs new file mode 100644 index 0000000..21455e3 --- /dev/null +++ b/CRSim.ScreenSimulator/ViewModels/Windows/Stations/FuzhouNan/TicketCheckScreenViewModel.cs @@ -0,0 +1,37 @@ +using CRSim.Core.Services; +using CRSim.ScreenSimulator.Models; +using System.Collections.ObjectModel; +using CRSim.Core.Models; +using System.Windows; +namespace CRSim.ScreenSimulator.ViewModels.FuzhouNan +{ + public class TicketCheckScreenViewModel : ScreenViewModel + { + public ObservableCollection Screen { get; set; } = []; + public TicketCheckScreenViewModel(ITimeService timeService, ISettingsService settingsService) + : base(timeService, settingsService) + { + Text = $"开车前{settingsService.GetSettings().StopCheckInAdvanceDuration.TotalMinutes}分钟停止检票"; + StationType = StationType.Departure; + timeService.RefreshSecondsElapsed += RefreshDisplay; + Initialize(); + } + private async void Initialize() + { + ItemsPerPage = 6; + await WaitForDataLoadAsync(); + RefreshDisplay(null,null); + } + private void RefreshDisplay(object? sender, EventArgs e) + { + Application.Current.Dispatcher.Invoke(() => + { + Screen.Clear(); + for (int i = 0; i < ItemsPerPage; i++) + { + Screen.Add(TrainInfo.Count > i ? TrainInfo[i] : new()); + } + }); + } + } +} diff --git a/CRSim.ScreenSimulator/Views/Windows/Stations/FuzhouNan/TicketCheckScreenView.xaml b/CRSim.ScreenSimulator/Views/Windows/Stations/FuzhouNan/TicketCheckScreenView.xaml new file mode 100644 index 0000000..c04c7f2 --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Windows/Stations/FuzhouNan/TicketCheckScreenView.xaml @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim.ScreenSimulator/Views/Windows/Stations/FuzhouNan/TicketCheckScreenView.xaml.cs b/CRSim.ScreenSimulator/Views/Windows/Stations/FuzhouNan/TicketCheckScreenView.xaml.cs new file mode 100644 index 0000000..d5ac3cd --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Windows/Stations/FuzhouNan/TicketCheckScreenView.xaml.cs @@ -0,0 +1,37 @@ +using CRSim.ScreenSimulator.ViewModels.FuzhouNan; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; + +namespace CRSim.ScreenSimulator.Views.FuzhouNan +{ + /// + /// SecondaryScreen.xaml 的交互逻辑 + /// + public partial class TicketCheckScreenView : Window + { + public TicketCheckScreenViewModel ViewModel { get; } + public TicketCheckScreenView(TicketCheckScreenViewModel viewModel) + { + InitializeComponent(); + RenderOptions.SetEdgeMode(this, EdgeMode.Aliased); + ViewModel = viewModel; + DataContext = viewModel; + } + 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(); + } + } + } +} diff --git a/CRSim/App.xaml.cs b/CRSim/App.xaml.cs index 6c37647..9343b68 100644 --- a/CRSim/App.xaml.cs +++ b/CRSim/App.xaml.cs @@ -73,6 +73,8 @@ services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); }).Build(); diff --git a/CRSim/Assets/StyleImages/FuzhouNan/TicketCheckScreen.png b/CRSim/Assets/StyleImages/FuzhouNan/TicketCheckScreen.png new file mode 100644 index 0000000..44f7cef Binary files /dev/null and b/CRSim/Assets/StyleImages/FuzhouNan/TicketCheckScreen.png differ diff --git a/CRSim/CRSim.csproj b/CRSim/CRSim.csproj index 36ef8c2..30c848f 100644 --- a/CRSim/CRSim.csproj +++ b/CRSim/CRSim.csproj @@ -17,6 +17,7 @@ + @@ -43,6 +44,7 @@ + diff --git a/CRSim/Models/StylesInfoData.json b/CRSim/Models/StylesInfoData.json index 84fc035..e55373a 100644 --- a/CRSim/Models/StylesInfoData.json +++ b/CRSim/Models/StylesInfoData.json @@ -34,6 +34,18 @@ "Text" ] }, + { + "UniqueId": "FuzhouNan TicketCheckScreen", + "Title": "福州南站检票口看板", + "Station": "FuzhouNan", + "StyleName": "TicketCheckScreenView", + "ImagePath": "Assets/StyleImages/FuzhouNan/TicketCheckScreen.png", + "Parameters": [ + "Station", + "TicketCheck", + "Text" + ] + }, { "UniqueId": "BeijingXi PrimaryScreen", "Title": "北京西站主要看板",