diff --git a/CRSim.ScreenSimulator/Assets/Zibo/ExitScreen.png b/CRSim.ScreenSimulator/Assets/Zibo/ExitScreen.png new file mode 100644 index 0000000..034bd39 Binary files /dev/null and b/CRSim.ScreenSimulator/Assets/Zibo/ExitScreen.png differ diff --git a/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj b/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj index 68d3d6e..34c10de 100644 --- a/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj +++ b/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj @@ -152,6 +152,7 @@ + \ No newline at end of file diff --git a/CRSim.ScreenSimulator/Converters/TrainStateColorConverter.cs b/CRSim.ScreenSimulator/Converters/TrainStateColorConverter.cs index b560312..1e8c7d6 100644 --- a/CRSim.ScreenSimulator/Converters/TrainStateColorConverter.cs +++ b/CRSim.ScreenSimulator/Converters/TrainStateColorConverter.cs @@ -16,9 +16,12 @@ namespace CRSim.ScreenSimulator.Converters /* Normal: 标准显示。 Alternating_Row_Colors: 候车状态隔行异色显示(第4个参数控制行号)。 + Arrive: 到达屏显示 */ public List WaitingColorList { get; set; } = []; + public SolidColorBrush ArrivedText { get; set; } = new(Colors.LightGreen); + public SolidColorBrush ArrivingText { get; set; } = new(Colors.White); public SolidColorBrush WaitingColor { get; set; } = new(Colors.White); public SolidColorBrush CheckInColor { get; set; } = new(Colors.LightGreen); public SolidColorBrush StopCheckInColor { get; set; } = new(Colors.Red); @@ -27,6 +30,14 @@ namespace CRSim.ScreenSimulator.Converters var serviceProvider = (IServiceProvider)Application.Current.Resources["ServiceProvider"]; _timeService = serviceProvider.GetRequiredService(); _settings = serviceProvider.GetRequiredService().GetSettings(); + if (DisplayMode == "Arrive" || ( values.Length > 1 && values[1] == null)) + { + if (values[0] is DateTime arriveTime) + { + return _timeService.GetDateTimeNow() >= arriveTime ? ArrivedText : ArrivingText; + } + return string.Empty; + } if (values[0] != null && values[1] == null) { return WaitingColor; diff --git a/CRSim.ScreenSimulator/Converters/TrainStateConverter.cs b/CRSim.ScreenSimulator/Converters/TrainStateConverter.cs index a9f3394..43c3ddf 100644 --- a/CRSim.ScreenSimulator/Converters/TrainStateConverter.cs +++ b/CRSim.ScreenSimulator/Converters/TrainStateConverter.cs @@ -26,7 +26,7 @@ namespace CRSim.ScreenSimulator.Converters { if (values[0] is DateTime arriveTime) { - return _timeService.GetDateTimeNow() > arriveTime ? ArrivedText : ArrivingText; + return _timeService.GetDateTimeNow() >= arriveTime ? ArrivedText : ArrivingText; } return string.Empty; } diff --git a/CRSim.ScreenSimulator/Models/StylesInfoData.json b/CRSim.ScreenSimulator/Models/StylesInfoData.json index 51c562f..3587ec1 100644 --- a/CRSim.ScreenSimulator/Models/StylesInfoData.json +++ b/CRSim.ScreenSimulator/Models/StylesInfoData.json @@ -242,6 +242,17 @@ "Location" ] }, + { + "UniqueId": "Zibo.ExitScreen", + "Title": "淄博站出站口看板", + "Region": "淄博", + "Author": "wxl0430", + "Type": "出站口屏", + "Parameters": [ + "Station", + "Text" + ] + }, { "UniqueId": "Jinanxi.SmallScreen", "Title": "济南西站小屏看板", diff --git a/CRSim.ScreenSimulator/ViewModels/ScreenViewModel.cs b/CRSim.ScreenSimulator/ViewModels/ScreenViewModel.cs index f87eb34..7365baf 100644 --- a/CRSim.ScreenSimulator/ViewModels/ScreenViewModel.cs +++ b/CRSim.ScreenSimulator/ViewModels/ScreenViewModel.cs @@ -142,7 +142,14 @@ namespace CRSim.ScreenSimulator.ViewModels } } - TrainInfo = [.. TrainInfo.OrderBy(x => x.DepartureTime??x.ArrivalTime)]; + if(StationType == StationType.Arrival) + { + TrainInfo = [.. TrainInfo.OrderBy(x => x.ArrivalTime??x.DepartureTime)]; + } + else + { + TrainInfo = [.. TrainInfo.OrderBy(x => x.DepartureTime??x.ArrivalTime)]; + } RefreshData(null, null); DataLoaded.SetResult(true); } diff --git a/CRSim.ScreenSimulator/ViewModels/Zibo/ExitScreenViewModel.cs b/CRSim.ScreenSimulator/ViewModels/Zibo/ExitScreenViewModel.cs new file mode 100644 index 0000000..a600924 --- /dev/null +++ b/CRSim.ScreenSimulator/ViewModels/Zibo/ExitScreenViewModel.cs @@ -0,0 +1,48 @@ +using CRSim.Core.Services; +using CRSim.Core.Models; +using CRSim.ScreenSimulator.Models; +using System.Windows; +namespace CRSim.ScreenSimulator.ViewModels.Zibo +{ + public class ExitScreenViewModel : ScreenViewModel + { + public ExitScreenViewModel(ITimeService timeService, ISettingsService settingsService) + : base(timeService, settingsService) + { + Text = $"温馨提示:请接站的旅客在出站口外耐心等候"; + ItemsPerPage = 6; + ScreenCount = 2; + StationType = StationType.Arrival; + } + public override void RefreshDisplay(object? sender, EventArgs? e) + { + Application.Current.Dispatcher.Invoke(() => + { + int pageCount = (int)Math.Ceiling((double)TrainInfo.Count / (ItemsPerPage * ScreenCount.Value)); + ScreenA.Clear(); + ScreenB.Clear(); + int startIndex = CurrentPageIndex * ItemsPerPage * ScreenCount.Value; + var ItemsToShow = TrainInfo.Skip(startIndex).Take(ItemsPerPage * ScreenCount.Value).ToList(); + var leftItems = ItemsToShow.Where((item, index) => index % 2 == 0).ToList(); + var rightItems = ItemsToShow.Where((item, index) => index % 2 == 1).ToList(); + while (leftItems.Count < ItemsPerPage) + { + leftItems.Add(new TrainInfo()); + } + while (rightItems.Count < ItemsPerPage) + { + rightItems.Add(new TrainInfo()); + } + foreach (var item in leftItems) + { + ScreenA.Add(item); + } + foreach (var item in rightItems) + { + ScreenB.Add(item); + } + CurrentPageIndex = CurrentPageIndex + 1 >= Math.Min(_settings.MaxPages, pageCount) ? 0 : CurrentPageIndex + 1; + }); + } + } +} diff --git a/CRSim.ScreenSimulator/Views/Zibo/ExitScreenView.xaml b/CRSim.ScreenSimulator/Views/Zibo/ExitScreenView.xaml new file mode 100644 index 0000000..e7dfff1 --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Zibo/ExitScreenView.xaml @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim.ScreenSimulator/Views/Zibo/ExitScreenView.xaml.cs b/CRSim.ScreenSimulator/Views/Zibo/ExitScreenView.xaml.cs new file mode 100644 index 0000000..e0140b9 --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Zibo/ExitScreenView.xaml.cs @@ -0,0 +1,18 @@ +using CRSim.ScreenSimulator.ViewModels.Zibo; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; + +namespace CRSim.ScreenSimulator.Views.Zibo +{ + public partial class ExitScreenView : BaseScreenView + { + public ExitScreenViewModel ViewModel { get; } + public ExitScreenView(ExitScreenViewModel viewModel) + { + InitializeComponent(); + ViewModel = viewModel; + DataContext = viewModel; + } + } +}