diff --git a/CRSim.ScreenSimulator/ViewModels/Windows/Stations/Zibo/TicketCheckScreenViewModel.cs b/CRSim.ScreenSimulator/ViewModels/Windows/Stations/Zibo/TicketCheckScreenViewModel.cs new file mode 100644 index 0000000..9e2e38c --- /dev/null +++ b/CRSim.ScreenSimulator/ViewModels/Windows/Stations/Zibo/TicketCheckScreenViewModel.cs @@ -0,0 +1,58 @@ +using CRSim.Core.Models; +using CRSim.Core.Services; +using CRSim.ScreenSimulator.Models; +using System.Collections.ObjectModel; +using System.Windows; +namespace CRSim.ScreenSimulator.ViewModels.Zibo +{ + public class TicketCheckScreenViewModel : ScreenViewModel + { + public ObservableCollection LeftScreen { get; private set; } = []; + public ObservableCollection RightScreen { get; private set; } = []; + public TicketCheckScreenViewModel(ITimeService timeService, ISettingsService settingsService) + : base(timeService, settingsService) + { + Text = $" 开车前{settingsService.GetSettings().StopCheckInAdvanceDuration.TotalMinutes}分钟停止检票"; + StationType = StationType.Departure; + timeService.RefreshSecondsElapsed += RefreshDisplay; + Initialize(); + } + private async void Initialize() + { + ItemsPerPage = 5; + PageCount = 2; + 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 ItemsToShow = TrainInfo.Skip(startIndex).Take(ItemsPerPage * PageCount).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) + { + LeftScreen.Add(item); + } + foreach (var item in rightItems) + { + RightScreen.Add(item); + } + CurrentPageIndex = CurrentPageIndex + 1 >= Math.Min(_settings.MaxPages, pageCount) ? 0 : CurrentPageIndex + 1; + }); + } + } +} diff --git a/CRSim.ScreenSimulator/Views/Windows/Stations/Zibo/TicketCheckScreenView.xaml b/CRSim.ScreenSimulator/Views/Windows/Stations/Zibo/TicketCheckScreenView.xaml new file mode 100644 index 0000000..179fe2a --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Windows/Stations/Zibo/TicketCheckScreenView.xaml @@ -0,0 +1,389 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim.ScreenSimulator/Views/Windows/Stations/Zibo/TicketCheckScreenView.xaml.cs b/CRSim.ScreenSimulator/Views/Windows/Stations/Zibo/TicketCheckScreenView.xaml.cs new file mode 100644 index 0000000..ea05351 --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Windows/Stations/Zibo/TicketCheckScreenView.xaml.cs @@ -0,0 +1,36 @@ +using CRSim.ScreenSimulator.ViewModels.Zibo; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; +namespace CRSim.ScreenSimulator.Views.Zibo +{ + /// + /// SecondaryScreen.xaml 的交互逻辑 + /// + public partial class TicketCheckScreenView : Window + { + public TicketCheckScreenViewModel ViewModel { get; } + public TicketCheckScreenView(TicketCheckScreenViewModel 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/App.xaml.cs b/CRSim/App.xaml.cs index 4568024..9d4bda6 100644 --- a/CRSim/App.xaml.cs +++ b/CRSim/App.xaml.cs @@ -59,6 +59,8 @@ namespace CRSim services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/CRSim/Assets/StyleImages/Zibo/TicketCheckScreen.png b/CRSim/Assets/StyleImages/Zibo/TicketCheckScreen.png new file mode 100644 index 0000000..e0e2090 Binary files /dev/null and b/CRSim/Assets/StyleImages/Zibo/TicketCheckScreen.png differ diff --git a/CRSim/CRSim.csproj b/CRSim/CRSim.csproj index 97a3fab..8305d0c 100644 --- a/CRSim/CRSim.csproj +++ b/CRSim/CRSim.csproj @@ -52,6 +52,7 @@ + diff --git a/CRSim/Models/StylesInfoData.json b/CRSim/Models/StylesInfoData.json index 8330820..9912fbc 100644 --- a/CRSim/Models/StylesInfoData.json +++ b/CRSim/Models/StylesInfoData.json @@ -163,5 +163,17 @@ "Station", "Text" ] + }, + { + "UniqueId": "Zibo TicketCheckScreen", + "Title": "淄博站检票口看板", + "Station": "Zibo", + "StyleName": "TicketCheckScreenView", + "ImagePath": "Assets/StyleImages/Zibo/TicketCheckScreen.png", + "Parameters": [ + "Station", + "TicketCheck", + "Text" + ] } ] \ No newline at end of file