diff --git a/CRSim.ScreenSimulator/Assets/BeijingNan/PrimaryScreen.png b/CRSim.ScreenSimulator/Assets/BeijingNan/PrimaryScreen.png new file mode 100644 index 0000000..287bf34 Binary files /dev/null and b/CRSim.ScreenSimulator/Assets/BeijingNan/PrimaryScreen.png differ diff --git a/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj b/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj index d926b28..a36e0e1 100644 --- a/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj +++ b/CRSim.ScreenSimulator/CRSim.ScreenSimulator.csproj @@ -94,6 +94,7 @@ + @@ -131,4 +132,4 @@ - + \ No newline at end of file diff --git a/CRSim.ScreenSimulator/Converters/TrainStateColorConverter.cs b/CRSim.ScreenSimulator/Converters/TrainStateColorConverter.cs index dc2f02a..6e11480 100644 --- a/CRSim.ScreenSimulator/Converters/TrainStateColorConverter.cs +++ b/CRSim.ScreenSimulator/Converters/TrainStateColorConverter.cs @@ -11,6 +11,14 @@ namespace CRSim.ScreenSimulator.Converters { private ITimeService _timeService; private Settings _settings; + public string DisplayMode { get; set; } = "Normal"; + + /* + Normal: 标准显示。 + Alternating_Row_Colors: 候车状态隔行异色显示(第4个参数控制行号)。 + */ + + public List WaitingColorList { get; set; } = new List { new(Colors.White), new(Colors.Yellow) }; public SolidColorBrush WaitingColor { get; set; } = new(Colors.White); public SolidColorBrush CheckingTicketsColor { get; set; } = new(Colors.LightGreen); public SolidColorBrush StopCheckingTicketsColor { get; set; } = new(Colors.Red); @@ -49,6 +57,9 @@ namespace CRSim.ScreenSimulator.Converters { return StopCheckingTicketsColor; } + if (DisplayMode == "Alternating_Row_Colors" && values.Length > 3 && values[3] is int rowNumber){ + return WaitingColorList[rowNumber % WaitingColorList.Count]; + } return WaitingColor; } return new SolidColorBrush(Colors.Transparent); diff --git a/CRSim.ScreenSimulator/Models/StylesInfoData.json b/CRSim.ScreenSimulator/Models/StylesInfoData.json index 5eb278d..0597164 100644 --- a/CRSim.ScreenSimulator/Models/StylesInfoData.json +++ b/CRSim.ScreenSimulator/Models/StylesInfoData.json @@ -64,7 +64,7 @@ "Author": "电排骨", "Type": "车站大屏", "Parameters": [ - "Region" + "Station" ] }, { @@ -135,7 +135,7 @@ "Author": "电排骨", "Type": "车站大屏", "Parameters": [ - "Region" + "Station" ] }, { @@ -181,7 +181,7 @@ "Author": "wxl0430", "Type": "车站大屏", "Parameters": [ - "Region" + "Station" ] }, { @@ -191,7 +191,7 @@ "Author": "wxl0430", "Type": "车站大屏", "Parameters": [ - "Region" + "Station" ] }, { @@ -321,5 +321,15 @@ "Location", "Text" ] + }, + { + "UniqueId": "BeijingNan.PrimaryScreen", + "Title": "北京南站主要看板", + "Region": "北京", + "Author": "wxl0430", + "Type": "车站大屏", + "Parameters": [ + "Station" + ] } ] \ No newline at end of file diff --git a/CRSim.ScreenSimulator/ViewModels/BeijingNan/PrimaryScreenViewModel.cs b/CRSim.ScreenSimulator/ViewModels/BeijingNan/PrimaryScreenViewModel.cs new file mode 100644 index 0000000..a019772 --- /dev/null +++ b/CRSim.ScreenSimulator/ViewModels/BeijingNan/PrimaryScreenViewModel.cs @@ -0,0 +1,45 @@ +using CRSim.Core.Models; +using CRSim.Core.Services; +using CRSim.ScreenSimulator.Models; +using System.Collections.ObjectModel; +using System.Windows; +namespace CRSim.ScreenSimulator.ViewModels.BeijingNan +{ + public class PrimaryScreenViewModel : ScreenViewModel + { + public ObservableCollection LeftScreen { get; private set; } = []; + public PrimaryScreenViewModel(ITimeService timeService, ISettingsService settingsService) + : base(timeService, settingsService) + { + 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/BeijingNan/PrimaryScreenView.xaml b/CRSim.ScreenSimulator/Views/BeijingNan/PrimaryScreenView.xaml new file mode 100644 index 0000000..677e25c --- /dev/null +++ b/CRSim.ScreenSimulator/Views/BeijingNan/PrimaryScreenView.xaml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim.ScreenSimulator/Views/BeijingNan/PrimaryScreenView.xaml.cs b/CRSim.ScreenSimulator/Views/BeijingNan/PrimaryScreenView.xaml.cs new file mode 100644 index 0000000..82e2f0f --- /dev/null +++ b/CRSim.ScreenSimulator/Views/BeijingNan/PrimaryScreenView.xaml.cs @@ -0,0 +1,26 @@ +using CRSim.ScreenSimulator.ViewModels.BeijingNan; +using CRSim.ScreenSimulator.Converters; +using System.Windows; +using System.Collections.Generic; +using System.Windows.Media; + +namespace CRSim.ScreenSimulator.Views.BeijingNan +{ + public partial class PrimaryScreenView : BaseScreenView + { + public PrimaryScreenViewModel ViewModel { get; } + public PrimaryScreenView(PrimaryScreenViewModel viewModel) + { + InitializeComponent(); + ViewModel = viewModel; + DataContext = viewModel; + + var trainStateColorConverter = (TrainStateColorConverter)Resources["TrainStateColorConverter"]; + trainStateColorConverter.WaitingColorList = new List + { + new SolidColorBrush(Colors.White), + new SolidColorBrush((Color)ColorConverter.ConvertFromString("#edd16f")) + }; + } + } +}