diff --git a/CRSim.Core/Models/StationStop.cs b/CRSim.Core/Models/StationStop.cs index 0d3a553..5495765 100644 --- a/CRSim.Core/Models/StationStop.cs +++ b/CRSim.Core/Models/StationStop.cs @@ -29,5 +29,22 @@ namespace CRSim.Core.Models public string? Landmark { get; set; } public int Length { get; set; } + + [JsonIgnore] + public StationType StationType + { + get + { + if (ArrivalTime == null) + { + return StationType.Departure; + } + else if (DepartureTime == null) + { + return StationType.Arrival; + } + return StationType.Both; + } + } } } diff --git a/CRSim.Core/Models/StationType.cs b/CRSim.Core/Models/StationType.cs new file mode 100644 index 0000000..37d9183 --- /dev/null +++ b/CRSim.Core/Models/StationType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CRSim.Core.Models +{ + public enum StationType + { + Arrival, + Departure, + Both + } +} diff --git a/CRSim/App.xaml.cs b/CRSim/App.xaml.cs index 860e1ec..b934d40 100644 --- a/CRSim/App.xaml.cs +++ b/CRSim/App.xaml.cs @@ -63,6 +63,8 @@ services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); }).Build(); [STAThread] diff --git a/CRSim/Assets/StyleImages/Ankang/ExitScreen.png b/CRSim/Assets/StyleImages/Ankang/ExitScreen.png new file mode 100644 index 0000000..3b9035d Binary files /dev/null and b/CRSim/Assets/StyleImages/Ankang/ExitScreen.png differ diff --git a/CRSim/CRSim.csproj b/CRSim/CRSim.csproj index 742eb44..bd9d679 100644 --- a/CRSim/CRSim.csproj +++ b/CRSim/CRSim.csproj @@ -14,6 +14,7 @@ + @@ -33,6 +34,7 @@ + @@ -84,6 +86,9 @@ Code + + Code + Code diff --git a/CRSim/Models/StylesInfoData.json b/CRSim/Models/StylesInfoData.json index edaf1f0..b90f63a 100644 --- a/CRSim/Models/StylesInfoData.json +++ b/CRSim/Models/StylesInfoData.json @@ -151,5 +151,16 @@ "Station", "Text" ] + }, + { + "UniqueId": "Ankang ExitScreen", + "Title": "安康站出站口看板", + "Station": "Ankang", + "StyleName": "ExitScreenView", + "ImagePath": "Assets/StyleImages/Ankang/ExitScreen.png", + "Parameters": [ + "Station", + "Text" + ] } ] \ No newline at end of file diff --git a/CRSim/Models/TrainInfo.cs b/CRSim/Models/TrainInfo.cs index 2506a82..ab99261 100644 --- a/CRSim/Models/TrainInfo.cs +++ b/CRSim/Models/TrainInfo.cs @@ -6,7 +6,7 @@ public string Origin { get; set; } public string Terminal { get; set; } public DateTime? ArrivalTime { get; set; } - public DateTime DepartureTime { get; set; } + public DateTime? DepartureTime { get; set; } public List TicketChecks { get; set; } public string WaitingArea { get; set; } public string Platform { get; set; } diff --git a/CRSim/ViewModels/Windows/ScreenViewModel.cs b/CRSim/ViewModels/Windows/ScreenViewModel.cs index 7896819..7a75270 100644 --- a/CRSim/ViewModels/Windows/ScreenViewModel.cs +++ b/CRSim/ViewModels/Windows/ScreenViewModel.cs @@ -25,6 +25,8 @@ namespace CRSim.ViewModels public List TrainInfo { get; set; } = []; + public StationType StationType = StationType.Both; + protected ScreenViewModel(ITimeService timeService, ISettingsService settingsService) { @@ -42,7 +44,7 @@ namespace CRSim.ViewModels { if (CurrentPageIndex==0) { - List itemsToRemove = [.. TrainInfo.Where(info => info.DepartureTime.Subtract(_settings.StopDisplayUntilDepartureDuration) < _timeService.GetDateTimeNow())]; + List itemsToRemove = [.. TrainInfo.Where(info => (info.DepartureTime??info.ArrivalTime).Value.Subtract(_settings.StopDisplayUntilDepartureDuration) < _timeService.GetDateTimeNow())]; foreach (var item in itemsToRemove) { @@ -58,7 +60,7 @@ namespace CRSim.ViewModels public Task WaitForDataLoadAsync() => _dataLoaded.Task; - public void LoadData(Station station,string ticketCheck,string platform) + public void LoadData(Station station, string ticketCheck, string platform) { ThisStation = station; ThisPlatform = platform; @@ -67,15 +69,20 @@ namespace CRSim.ViewModels foreach (var trainNumber in trains) { - if (trainNumber != null && trainNumber.DepartureTime != null && (ticketCheck==string.Empty || trainNumber.TicketChecks.Contains(ticketCheck)) && (platform == string.Empty || trainNumber.Platform==platform)) + if (trainNumber != null && + (StationType == StationType.Both || + trainNumber.StationType == StationType.Both || + StationType == trainNumber.StationType) && + (ticketCheck == string.Empty || trainNumber.TicketChecks.Contains(ticketCheck)) && + (platform == string.Empty || trainNumber.Platform == platform)) { TrainInfo.Add(new TrainInfo { TrainNumber = trainNumber.Number, Terminal = trainNumber.Terminal, Origin = trainNumber.Origin, - ArrivalTime = trainNumber.ArrivalTime == null ? null : trainNumber.DepartureTime.Value < _timeService.GetDateTimeNow() ? trainNumber.ArrivalTime.Value.AddDays(1) : trainNumber.ArrivalTime.Value, - DepartureTime = trainNumber.DepartureTime.Value < _timeService.GetDateTimeNow() ? trainNumber.DepartureTime.Value.AddDays(1) : trainNumber.DepartureTime.Value, + ArrivalTime = trainNumber.ArrivalTime == null ? null : trainNumber.ArrivalTime, + DepartureTime = trainNumber.DepartureTime == null ? null : trainNumber.DepartureTime, TicketChecks = trainNumber.TicketChecks, WaitingArea = station.WaitingAreas.Where(x => x.TicketChecks.Intersect(trainNumber.TicketChecks).ToList().Count!=0).FirstOrDefault().Name, Platform = trainNumber.Platform, diff --git a/CRSim/ViewModels/Windows/Stations/Ankang/ExitScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/Ankang/ExitScreenViewModel.cs new file mode 100644 index 0000000..c10fd74 --- /dev/null +++ b/CRSim/ViewModels/Windows/Stations/Ankang/ExitScreenViewModel.cs @@ -0,0 +1,55 @@ +namespace CRSim.ViewModels.Ankang +{ + public class ExitScreenViewModel : ScreenViewModel + { + public ObservableCollection LeftScreen { get; private set; } = []; + public ObservableCollection RightScreen { get; private set; } = []; + public ExitScreenViewModel(ITimeService timeService, ISettingsService settingsService) + : base(timeService, settingsService) + { + Text = $"西安局集团公司推出西铁行APP站车服务产品,欢迎体验使用。"; + ItemsPerPage = 7; + PageCount = 1; + StationType = StationType.Arrival; + timeService.RefreshSecondsElapsed += RefreshDisplay; + Initialize(); + } + private async void Initialize() + { + await WaitForDataLoadAsync(); + RefreshDisplay(null,null); + } + private void RefreshDisplay(object? sender, EventArgs e) + { + Application.Current.Dispatcher.Invoke(() => + { + int pageCount = (int)Math.Ceiling((double)TrainInfo.Count / (ItemsPerPage * PageCount)); + LeftScreen.Clear(); + RightScreen.Clear(); + int startIndex = CurrentPageIndex * ItemsPerPage * PageCount; + var leftItems = TrainInfo.Skip(startIndex).Take(ItemsPerPage).ToList(); + while (leftItems.Count < ItemsPerPage) // Fill up with new object() if not enough items + { + leftItems.Add(new TrainInfo()); + } + foreach (var item in leftItems) + { + LeftScreen.Add(item); + } + + // Get the slice for the right screen (next 12) + var rightItems = TrainInfo.Skip(startIndex + ItemsPerPage).Take(ItemsPerPage).ToList(); + while (rightItems.Count < ItemsPerPage) // Fill up with new object() if not enough items + { + rightItems.Add(new TrainInfo()); + } + foreach (var item in rightItems) + { + RightScreen.Add(item); + } + + CurrentPageIndex = CurrentPageIndex + 1 >= Math.Min(_settings.MaxPages, pageCount) ? 0 : CurrentPageIndex + 1; + }); + } + } +} diff --git a/CRSim/ViewModels/Windows/Stations/BeijingXi/PrimaryScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/BeijingXi/PrimaryScreenViewModel.cs index d1fd989..e6f6f6a 100644 --- a/CRSim/ViewModels/Windows/Stations/BeijingXi/PrimaryScreenViewModel.cs +++ b/CRSim/ViewModels/Windows/Stations/BeijingXi/PrimaryScreenViewModel.cs @@ -9,6 +9,7 @@ { ItemsPerPage = 13; PageCount = 2; + StationType = StationType.Departure; timeService.RefreshSecondsElapsed += RefreshDisplay; Initialize(); } diff --git a/CRSim/ViewModels/Windows/Stations/ChengduDong/PrimaryTicketCheckScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/ChengduDong/PrimaryTicketCheckScreenViewModel.cs index 6cd0182..d530709 100644 --- a/CRSim/ViewModels/Windows/Stations/ChengduDong/PrimaryTicketCheckScreenViewModel.cs +++ b/CRSim/ViewModels/Windows/Stations/ChengduDong/PrimaryTicketCheckScreenViewModel.cs @@ -7,6 +7,7 @@ : base(timeService, settingsService) { Text = "持户口簿、护照、临时身份证的旅客,请在非居民身份证通道排队。请主动礼让老、弱、病、残、孕的旅客。"; + StationType = StationType.Departure; timeService.RefreshSecondsElapsed += RefreshDisplay; Initialize(); } diff --git a/CRSim/ViewModels/Windows/Stations/ChengduDong/SecondaryScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/ChengduDong/SecondaryScreenViewModel.cs index ad3b9a0..33131dc 100644 --- a/CRSim/ViewModels/Windows/Stations/ChengduDong/SecondaryScreenViewModel.cs +++ b/CRSim/ViewModels/Windows/Stations/ChengduDong/SecondaryScreenViewModel.cs @@ -10,6 +10,7 @@ Text = " 检票口信息请以车站显示屏信息为准。公共场所请妥善保管个人贵重物品。"; ItemsPerPage = 12; PageCount = 2; + StationType = StationType.Departure; timeService.RefreshSecondsElapsed += RefreshDisplay; Initialize(); } diff --git a/CRSim/ViewModels/Windows/Stations/Fuzhou/TicketCheckScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/Fuzhou/TicketCheckScreenViewModel.cs index b3148e8..0b2e931 100644 --- a/CRSim/ViewModels/Windows/Stations/Fuzhou/TicketCheckScreenViewModel.cs +++ b/CRSim/ViewModels/Windows/Stations/Fuzhou/TicketCheckScreenViewModel.cs @@ -7,6 +7,7 @@ : base(timeService, settingsService) { Text = $"开车前{settingsService.GetSettings().StopCheckInAdvanceDuration.TotalMinutes}分钟停止检票"; + StationType = StationType.Departure; timeService.RefreshSecondsElapsed += RefreshDisplay; Initialize(); } diff --git a/CRSim/ViewModels/Windows/Stations/Guangyuan/PrimaryScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/Guangyuan/PrimaryScreenViewModel.cs index fb0a882..9354bc1 100644 --- a/CRSim/ViewModels/Windows/Stations/Guangyuan/PrimaryScreenViewModel.cs +++ b/CRSim/ViewModels/Windows/Stations/Guangyuan/PrimaryScreenViewModel.cs @@ -9,6 +9,7 @@ Text = "成都铁路客服电话:028-12306"; ItemsPerPage = 12; PageCount = 1; + StationType = StationType.Departure; timeService.RefreshSecondsElapsed += RefreshDisplay; Initialize(); } diff --git a/CRSim/ViewModels/Windows/Stations/Harbin/PrimaryScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/Harbin/PrimaryScreenViewModel.cs index e0e29f0..09d7ec5 100644 --- a/CRSim/ViewModels/Windows/Stations/Harbin/PrimaryScreenViewModel.cs +++ b/CRSim/ViewModels/Windows/Stations/Harbin/PrimaryScreenViewModel.cs @@ -10,6 +10,7 @@ Text = $"开车前{settingsService.GetSettings().StopCheckInAdvanceDuration.TotalMinutes}分钟停止检票"; ItemsPerPage = 6; PageCount = 2; + StationType = StationType.Departure; timeService.RefreshSecondsElapsed += RefreshDisplay; Initialize(); } diff --git a/CRSim/ViewModels/Windows/Stations/Jinanxi/SmallScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/Jinanxi/SmallScreenViewModel.cs index 66db7f0..58f09af 100644 --- a/CRSim/ViewModels/Windows/Stations/Jinanxi/SmallScreenViewModel.cs +++ b/CRSim/ViewModels/Windows/Stations/Jinanxi/SmallScreenViewModel.cs @@ -8,6 +8,7 @@ { ItemsPerPage = 9; PageCount = 1; + StationType = StationType.Departure; timeService.RefreshSecondsElapsed += RefreshDisplay; Initialize(); } diff --git a/CRSim/ViewModels/Windows/Stations/Shanghai/OutsideScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/Shanghai/OutsideScreenViewModel.cs index 3deaf26..b3d0cf5 100644 --- a/CRSim/ViewModels/Windows/Stations/Shanghai/OutsideScreenViewModel.cs +++ b/CRSim/ViewModels/Windows/Stations/Shanghai/OutsideScreenViewModel.cs @@ -8,6 +8,7 @@ { ItemsPerPage = 9; PageCount = 1; + StationType = StationType.Departure; timeService.RefreshSecondsElapsed += RefreshDisplay; Initialize(); } diff --git a/CRSim/ViewModels/Windows/Stations/Zibo/PrimaryScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/Zibo/PrimaryScreenViewModel.cs index e53e3e7..3493bff 100644 --- a/CRSim/ViewModels/Windows/Stations/Zibo/PrimaryScreenViewModel.cs +++ b/CRSim/ViewModels/Windows/Stations/Zibo/PrimaryScreenViewModel.cs @@ -9,6 +9,7 @@ { ItemsPerPage = 8; PageCount = 2; + StationType = StationType.Departure; timeService.RefreshSecondsElapsed += RefreshDisplay; Initialize(); } diff --git a/CRSim/ViewModels/Windows/Stations/Zibo/SecondaryScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/Zibo/SecondaryScreenViewModel.cs index 9750834..ec9ea11 100644 --- a/CRSim/ViewModels/Windows/Stations/Zibo/SecondaryScreenViewModel.cs +++ b/CRSim/ViewModels/Windows/Stations/Zibo/SecondaryScreenViewModel.cs @@ -9,6 +9,7 @@ Text = $"开车前{settingsService.GetSettings().StopCheckInAdvanceDuration.TotalMinutes}分钟停止检票"; ItemsPerPage = 18; PageCount = 1; + StationType = StationType.Departure; timeService.RefreshSecondsElapsed += RefreshDisplay; Initialize(); } diff --git a/CRSim/Views/Windows/Stations/Ankang/ExitScreenView.xaml b/CRSim/Views/Windows/Stations/Ankang/ExitScreenView.xaml new file mode 100644 index 0000000..6e189a3 --- /dev/null +++ b/CRSim/Views/Windows/Stations/Ankang/ExitScreenView.xaml @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim/Views/Windows/Stations/Ankang/ExitScreenView.xaml.cs b/CRSim/Views/Windows/Stations/Ankang/ExitScreenView.xaml.cs new file mode 100644 index 0000000..06b3289 --- /dev/null +++ b/CRSim/Views/Windows/Stations/Ankang/ExitScreenView.xaml.cs @@ -0,0 +1,34 @@ +using CRSim.ViewModels.Ankang; + +namespace CRSim.Views.Ankang +{ + /// + /// SecondaryScreen.xaml 的交互逻辑 + /// + public partial class ExitScreenView : Window + { + public ExitScreenViewModel ViewModel { get; } + public ExitScreenView(ExitScreenViewModel 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/Views/Windows/Stations/ChengduDong/PrimaryTicketCheckScreenView.xaml b/CRSim/Views/Windows/Stations/ChengduDong/PrimaryTicketCheckScreenView.xaml index 5c55ac1..e24bec3 100644 --- a/CRSim/Views/Windows/Stations/ChengduDong/PrimaryTicketCheckScreenView.xaml +++ b/CRSim/Views/Windows/Stations/ChengduDong/PrimaryTicketCheckScreenView.xaml @@ -22,6 +22,7 @@ + @@ -96,6 +97,7 @@ + @@ -138,6 +140,7 @@