diff --git a/CRSim/App.xaml.cs b/CRSim/App.xaml.cs index e0a018a..0b737d0 100644 --- a/CRSim/App.xaml.cs +++ b/CRSim/App.xaml.cs @@ -57,6 +57,8 @@ services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); }).Build(); [STAThread] diff --git a/CRSim/Assets/StyleImages/GuangdongIntercity/SecondaryScreen.png b/CRSim/Assets/StyleImages/GuangdongIntercity/SecondaryScreen.png new file mode 100644 index 0000000..6f92dc0 Binary files /dev/null and b/CRSim/Assets/StyleImages/GuangdongIntercity/SecondaryScreen.png differ diff --git a/CRSim/CRSim.csproj b/CRSim/CRSim.csproj index 6070c73..d7cea1b 100644 --- a/CRSim/CRSim.csproj +++ b/CRSim/CRSim.csproj @@ -14,7 +14,6 @@ - PreserveNewest @@ -36,6 +35,7 @@ + @@ -93,7 +93,10 @@ Code - + + Code + + Code diff --git a/CRSim/Models/StylesInfoData.json b/CRSim/Models/StylesInfoData.json index 58a1cb4..926d596 100644 --- a/CRSim/Models/StylesInfoData.json +++ b/CRSim/Models/StylesInfoData.json @@ -115,5 +115,15 @@ "Parameters": [ "Station" ] + }, + { + "UniqueId": "GuangdongIntercity SecondaryScreen", + "Title": "广东城际次要看板", + "Station": "GuangdongIntercity", + "StyleName": "SecondaryScreenView", + "ImagePath": "Assets/StyleImages/GuangdongIntercity/SecondaryScreen.png", + "Parameters": [ + "Station" + ] } ] \ No newline at end of file diff --git a/CRSim/ViewModels/Windows/ScreenViewModel.cs b/CRSim/ViewModels/Windows/ScreenViewModel.cs index 79dce1b..6c24227 100644 --- a/CRSim/ViewModels/Windows/ScreenViewModel.cs +++ b/CRSim/ViewModels/Windows/ScreenViewModel.cs @@ -1,4 +1,6 @@ using System.Linq; +using System; +using System.Globalization; namespace CRSim.ViewModels { diff --git a/CRSim/ViewModels/Windows/Stations/GuangdongIntercity/SecondaryScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/GuangdongIntercity/SecondaryScreenViewModel.cs new file mode 100644 index 0000000..1e1810c --- /dev/null +++ b/CRSim/ViewModels/Windows/Stations/GuangdongIntercity/SecondaryScreenViewModel.cs @@ -0,0 +1,41 @@ +namespace CRSim.ViewModels.GuangdongIntercity +{ + public class SecondaryScreenViewModel : ScreenViewModel + { + public ObservableCollection Screen { get; private set; } = []; + public SecondaryScreenViewModel(ITimeService timeService, ISettingsService settingsService) + : base(timeService, settingsService) + { + ItemsPerPage = 8; + PageCount = 1; + timeService.RefreshSecondsElapsed += RefreshDisplay; + Initialize(); + } + private async void Initialize() + { + await WaitForDataLoadAsync(); + Text = $"列 车 到 发 信 息"; + RefreshDisplay(null,null); + } + private void RefreshDisplay(object? sender, EventArgs e) + { + Application.Current.Dispatcher.Invoke(() => + { + int pageCount = (int)Math.Ceiling((double)TrainInfo.Count / (ItemsPerPage * PageCount)); + Screen.Clear(); + int startIndex = CurrentPageIndex * ItemsPerPage * PageCount; + var Items = TrainInfo.Skip(startIndex).Take(ItemsPerPage).ToList(); + while (Items.Count < ItemsPerPage) // Fill up with new object() if not enough items + { + Items.Add(new TrainInfo()); + } + foreach (var item in Items) + { + Screen.Add(item); + } + + CurrentPageIndex = CurrentPageIndex + 1 >= Math.Min(_settings.MaxPages, pageCount) ? 0 : CurrentPageIndex + 1; + }); + } + } +} diff --git a/CRSim/Views/Windows/Stations/GuangdongIntercity/SecondaryScreenView.xaml b/CRSim/Views/Windows/Stations/GuangdongIntercity/SecondaryScreenView.xaml new file mode 100644 index 0000000..435b9ea --- /dev/null +++ b/CRSim/Views/Windows/Stations/GuangdongIntercity/SecondaryScreenView.xaml @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim/Views/Windows/Stations/GuangdongIntercity/SecondaryScreenView.xaml.cs b/CRSim/Views/Windows/Stations/GuangdongIntercity/SecondaryScreenView.xaml.cs new file mode 100644 index 0000000..c39b045 --- /dev/null +++ b/CRSim/Views/Windows/Stations/GuangdongIntercity/SecondaryScreenView.xaml.cs @@ -0,0 +1,33 @@ +using CRSim.ViewModels.GuangdongIntercity; + +namespace CRSim.Views.GuangdongIntercity +{ + /// + /// SecondaryScreen.xaml 的交互逻辑 + /// + public partial class SecondaryScreenView : Window + { + public SecondaryScreenViewModel ViewModel { get; } + public SecondaryScreenView(SecondaryScreenViewModel viewModel) + { + InitializeComponent(); + 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(); + } + } + } +}