diff --git a/CRSim/App.xaml.cs b/CRSim/App.xaml.cs index 5ad7ec5..bcfddd1 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/Assets/StyleImages/ZiBo/PrimaryScreen.png b/CRSim/Assets/StyleImages/ZiBo/PrimaryScreen.png new file mode 100644 index 0000000..10c76a8 Binary files /dev/null and b/CRSim/Assets/StyleImages/ZiBo/PrimaryScreen.png differ diff --git a/CRSim/Assets/StyleImages/Zibo/PrimaryScreen.png b/CRSim/Assets/StyleImages/Zibo/PrimaryScreen.png new file mode 100644 index 0000000..10c76a8 Binary files /dev/null and b/CRSim/Assets/StyleImages/Zibo/PrimaryScreen.png differ diff --git a/CRSim/CRSim.csproj b/CRSim/CRSim.csproj index 0848a31..2ead31b 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.4 @@ -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/Converters/TrainStateColorConverter.cs b/CRSim/Converters/TrainStateColorConverter.cs index d991d9e..60cb4ff 100644 --- a/CRSim/Converters/TrainStateColorConverter.cs +++ b/CRSim/Converters/TrainStateColorConverter.cs @@ -5,6 +5,8 @@ private ITimeService _timeService; private Settings _settings; public SolidColorBrush WaitingColor { get; set; } = new(Colors.White); + public SolidColorBrush CheckingTicketsColor { get; set; } = new(Colors.LightGreen); + public SolidColorBrush StopCheckingTicketsColor { get; set; } = new(Colors.Red); object IMultiValueConverter.Convert(object[] values, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { var serviceProvider = (IServiceProvider)Application.Current.Resources["ServiceProvider"]; @@ -17,7 +19,7 @@ //过路站 if (_timeService.GetDateTimeNow() > departureTime.Subtract(_settings.PassingCheckInAdvanceDuration) && _timeService.GetDateTimeNow() < departureTime.Subtract(_settings.StopCheckInAdvanceDuration)) { - return new SolidColorBrush(Colors.LightGreen); + return CheckingTicketsColor; } } else @@ -25,16 +27,16 @@ //始发站 if (_timeService.GetDateTimeNow() > departureTime.Subtract(_settings.DepartureCheckInAdvanceDuration) && _timeService.GetDateTimeNow() < departureTime.Subtract(_settings.StopCheckInAdvanceDuration)) { - return new SolidColorBrush(Colors.LightGreen); + return CheckingTicketsColor; } } if (_timeService.GetDateTimeNow() > departureTime.Subtract(_settings.StopCheckInAdvanceDuration)) { - return new SolidColorBrush(Colors.Red); + return StopCheckingTicketsColor; } if (values[2] is TimeSpan state && state.TotalMinutes > 0) { - return new SolidColorBrush(Colors.Red); + return StopCheckingTicketsColor; } return WaitingColor; } diff --git a/CRSim/Models/StylesInfoData.json b/CRSim/Models/StylesInfoData.json index 91023ac..80a6588 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; + }); + } + } +} diff --git a/CRSim/ViewModels/Windows/Stations/Zibo/PrimaryScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/Zibo/PrimaryScreenViewModel.cs new file mode 100644 index 0000000..e53e3e7 --- /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; + }); + } + } +} diff --git a/CRSim/Views/Windows/Stations/ZiBo/PrimaryScreenView.xaml b/CRSim/Views/Windows/Stations/ZiBo/PrimaryScreenView.xaml new file mode 100644 index 0000000..2be472c --- /dev/null +++ b/CRSim/Views/Windows/Stations/ZiBo/PrimaryScreenView.xaml @@ -0,0 +1,395 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim/Views/Windows/Stations/ZiBo/PrimaryScreenView.xaml.cs b/CRSim/Views/Windows/Stations/ZiBo/PrimaryScreenView.xaml.cs new file mode 100644 index 0000000..85ab92c --- /dev/null +++ b/CRSim/Views/Windows/Stations/ZiBo/PrimaryScreenView.xaml.cs @@ -0,0 +1,33 @@ +using CRSim.ViewModels.ZiBo; + +namespace CRSim.Views.ZiBo +{ + /// + /// PrimaryScreen.xaml 的交互逻辑 + /// + public partial class PrimaryScreenView : Window + { + public PrimaryScreenViewModel ViewModel { get; } + public PrimaryScreenView(PrimaryScreenViewModel 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(); + } + } + } +} diff --git a/CRSim/Views/Windows/Stations/Zibo/PrimaryScreenView.xaml b/CRSim/Views/Windows/Stations/Zibo/PrimaryScreenView.xaml new file mode 100644 index 0000000..9b7388f --- /dev/null +++ b/CRSim/Views/Windows/Stations/Zibo/PrimaryScreenView.xaml @@ -0,0 +1,395 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim/Views/Windows/Stations/Zibo/PrimaryScreenView.xaml.cs b/CRSim/Views/Windows/Stations/Zibo/PrimaryScreenView.xaml.cs new file mode 100644 index 0000000..a276d94 --- /dev/null +++ b/CRSim/Views/Windows/Stations/Zibo/PrimaryScreenView.xaml.cs @@ -0,0 +1,33 @@ +using CRSim.ViewModels.Zibo; + +namespace CRSim.Views.Zibo +{ + /// + /// PrimaryScreen.xaml 的交互逻辑 + /// + public partial class PrimaryScreenView : Window + { + public PrimaryScreenViewModel ViewModel { get; } + public PrimaryScreenView(PrimaryScreenViewModel 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(); + } + } + } +}