diff --git a/CRSim.ScreenSimulator/Assets/Niuzhou/PrimaryScreen.png b/CRSim.ScreenSimulator/Assets/Niuzhou/PrimaryScreen.png new file mode 100644 index 0000000..10c01fb Binary files /dev/null and b/CRSim.ScreenSimulator/Assets/Niuzhou/PrimaryScreen.png differ diff --git a/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj b/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj index 290fdc2..0c58670 100644 --- a/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj +++ b/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj @@ -11,6 +11,7 @@ + @@ -53,6 +54,9 @@ Code + + Code + Code @@ -114,6 +118,7 @@ + diff --git a/CRSim.ScreenSimulator/Models/StylesInfoData.json b/CRSim.ScreenSimulator/Models/StylesInfoData.json index c2847b4..7c0fc92 100644 --- a/CRSim.ScreenSimulator/Models/StylesInfoData.json +++ b/CRSim.ScreenSimulator/Models/StylesInfoData.json @@ -250,6 +250,17 @@ "Text" ] }, + { + "UniqueId": "Niuzhou.PrimaryScreen", + "Title": "柳州站主要看板", + "Station": "柳州", + "Author": "电排骨", + "Type": "车站大屏", + "Parameters": [ + "Station", + "Text" + ] + }, { "UniqueId": "Beijing.ArrivalScreen", "Title": "北京站地道到达看板", diff --git a/CRSim.ScreenSimulator/ViewModels/Niuzhou/PrimaryScreenViewModel.cs b/CRSim.ScreenSimulator/ViewModels/Niuzhou/PrimaryScreenViewModel.cs new file mode 100644 index 0000000..1d2f86d --- /dev/null +++ b/CRSim.ScreenSimulator/ViewModels/Niuzhou/PrimaryScreenViewModel.cs @@ -0,0 +1,46 @@ +using CRSim.Core.Models; +using CRSim.Core.Services; +using CRSim.ScreenSimulator.Models; +using System.Collections.ObjectModel; +using System.Windows; +namespace CRSim.ScreenSimulator.ViewModels.Niuzhou +{ + public class PrimaryScreenViewModel : ScreenViewModel + { + public ObservableCollection LeftScreen { get; private set; } = []; + public PrimaryScreenViewModel(ITimeService timeService, ISettingsService settingsService) + : base(timeService, settingsService) + { + Text = $"开车前{settingsService.GetSettings().PassingCheckInAdvanceDuration.TotalMinutes}分钟开始检票,开车前{settingsService.GetSettings().StopCheckInAdvanceDuration.TotalMinutes}分钟停止检票。"; + ItemsPerPage = 10; + PageCount = 1; + 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(() => + { + int pageCount = (int)Math.Ceiling((double)TrainInfo.Count / (ItemsPerPage * PageCount)); + LeftScreen.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); + } + CurrentPageIndex = CurrentPageIndex + 1 >= Math.Min(_settings.MaxPages, pageCount) ? 0 : CurrentPageIndex + 1; + }); + } + } +} diff --git a/CRSim.ScreenSimulator/Views/Niuzhou/PrimaryScreenView.xaml b/CRSim.ScreenSimulator/Views/Niuzhou/PrimaryScreenView.xaml new file mode 100644 index 0000000..c039afe --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Niuzhou/PrimaryScreenView.xaml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim.ScreenSimulator/Views/Niuzhou/PrimaryScreenView.xaml.cs b/CRSim.ScreenSimulator/Views/Niuzhou/PrimaryScreenView.xaml.cs new file mode 100644 index 0000000..72b62e2 --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Niuzhou/PrimaryScreenView.xaml.cs @@ -0,0 +1,15 @@ +using CRSim.ScreenSimulator.ViewModels.Niuzhou; + +namespace CRSim.ScreenSimulator.Views.Niuzhou +{ + public partial class PrimaryScreenView : BaseScreenView + { + public PrimaryScreenViewModel ViewModel { get; } + public PrimaryScreenView(PrimaryScreenViewModel viewModel) + { + InitializeComponent(); + ViewModel = viewModel; + DataContext = viewModel; + } + } +}