From afd8742fcb89871cbca40726da968f279b5bcfd1 Mon Sep 17 00:00:00 2001 From: wxl0430 <141288415+wxl0430@users.noreply.github.com> Date: Sun, 2 Mar 2025 14:32:37 +0800 Subject: [PATCH] Add files via upload --- CRSim/App.xaml.cs | 2 + CRSim/CRSim.csproj | 10 +++- CRSim/Controls/TileGallery.xaml | 4 +- CRSim/Models/StylesInfoData.json | 10 ++++ .../Stations/ZiBo/PrimaryScreenViewModel.cs | 50 +++++++++++++++++++ 5 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 CRSim/ViewModels/Windows/Stations/ZiBo/PrimaryScreenViewModel.cs diff --git a/CRSim/App.xaml.cs b/CRSim/App.xaml.cs index 5ad7ec5..35a8ed1 100644 --- a/CRSim/App.xaml.cs +++ b/CRSim/App.xaml.cs @@ -51,6 +51,8 @@ services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); }).Build(); [STAThread] diff --git a/CRSim/CRSim.csproj b/CRSim/CRSim.csproj index 0848a31..1c08749 100644 --- a/CRSim/CRSim.csproj +++ b/CRSim/CRSim.csproj @@ -9,7 +9,7 @@ 13.0 CRSim.App Assets\CRSimIcon.ico - 1.2.3.3 + 1.2.3.1 @@ -45,6 +45,7 @@ + @@ -88,6 +89,13 @@ Code + + Code + + + + + diff --git a/CRSim/Controls/TileGallery.xaml b/CRSim/Controls/TileGallery.xaml index 07b1562..ea389d9 100644 --- a/CRSim/Controls/TileGallery.xaml +++ b/CRSim/Controls/TileGallery.xaml @@ -36,7 +36,7 @@ @@ -65,7 +65,7 @@ diff --git a/CRSim/Models/StylesInfoData.json b/CRSim/Models/StylesInfoData.json index 91023ac..93d213c 100644 --- a/CRSim/Models/StylesInfoData.json +++ b/CRSim/Models/StylesInfoData.json @@ -85,5 +85,15 @@ "Station", "Platform" ] + }, + { + "UniqueId": "ZiBo PrimaryScreen", + "Title": "淄博站主要看板", + "Station": "ZiBo", + "StyleName": "PrimaryScreenView", + "ImagePath": "Assets/StyleImages/ZiBo/PrimaryScreen.png", + "Parameters": [ + "Station" + ] } ] \ No newline at end of file diff --git a/CRSim/ViewModels/Windows/Stations/ZiBo/PrimaryScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/ZiBo/PrimaryScreenViewModel.cs new file mode 100644 index 0000000..803156c --- /dev/null +++ b/CRSim/ViewModels/Windows/Stations/ZiBo/PrimaryScreenViewModel.cs @@ -0,0 +1,50 @@ +namespace CRSim.ViewModels.ZiBo +{ + public class PrimaryScreenViewModel : ScreenViewModel + { + public ObservableCollection LeftScreen { get; private set; } = []; + public ObservableCollection RightScreen { get; private set; } = []; + public PrimaryScreenViewModel(ITimeService timeService, ISettingsService settingsService) + : base(timeService, settingsService) + { + ItemsPerPage = 8; + PageCount = 2; + 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) + { + leftItems.Add(new TrainInfo()); + } + foreach (var item in leftItems) + { + LeftScreen.Add(item); + } + var rightItems = TrainInfo.Skip(startIndex + ItemsPerPage).Take(ItemsPerPage).ToList(); + while (rightItems.Count < ItemsPerPage) + { + rightItems.Add(new TrainInfo()); + } + foreach (var item in rightItems) + { + RightScreen.Add(item); + } + CurrentPageIndex = CurrentPageIndex + 1 >= Math.Min(_settings.MaxPages, pageCount) ? 0 : CurrentPageIndex + 1; + }); + } + } +}