diff --git a/CRSim.ScreenSimulator/Converters/TrainStateConverter.cs b/CRSim.ScreenSimulator/Converters/TrainStateConverter.cs index 87ebd50..a9f3394 100644 --- a/CRSim.ScreenSimulator/Converters/TrainStateConverter.cs +++ b/CRSim.ScreenSimulator/Converters/TrainStateConverter.cs @@ -22,12 +22,13 @@ namespace CRSim.ScreenSimulator.Converters var serviceProvider = (IServiceProvider)Application.Current.Resources["ServiceProvider"]; _timeService = serviceProvider.GetRequiredService(); _settings = serviceProvider.GetRequiredService().GetSettings(); - if (DisplayMode == "Arrive" || values[1] == null) + if (DisplayMode == "Arrive" || ( values.Length > 1 && values[1] == null)) { if (values[0] is DateTime arriveTime) { return _timeService.GetDateTimeNow() > arriveTime ? ArrivedText : ArrivingText; } + return string.Empty; } if (values[1] is DateTime departureTime && departureTime != new DateTime()) { @@ -66,4 +67,4 @@ namespace CRSim.ScreenSimulator.Converters return null; } } -} +} \ No newline at end of file diff --git a/CRSim.ScreenSimulator/ViewModels/Beijing/ArrivalScreenViewModel.cs b/CRSim.ScreenSimulator/ViewModels/Beijing/ArrivalScreenViewModel.cs new file mode 100644 index 0000000..0bccc48 --- /dev/null +++ b/CRSim.ScreenSimulator/ViewModels/Beijing/ArrivalScreenViewModel.cs @@ -0,0 +1,36 @@ +using CRSim.Core.Models; +using CRSim.Core.Services; +using CRSim.ScreenSimulator.Models; +using System.Collections.ObjectModel; +using System.Windows; +namespace CRSim.ScreenSimulator.ViewModels.Beijing +{ + public class ArrivalScreenViewModel : ScreenViewModel + { + public ObservableCollection Screen { get; set; } = []; + public ArrivalScreenViewModel(ITimeService timeService, ISettingsService settingsService) + : base(timeService, settingsService) + { + StationType = StationType.Departure; + timeService.RefreshSecondsElapsed += RefreshDisplay; + Initialize(); + } + private async void Initialize() + { + ItemsPerPage = 2; + await WaitForDataLoadAsync(); + RefreshDisplay(null,null); + } + private void RefreshDisplay(object? sender, EventArgs e) + { + Application.Current.Dispatcher.Invoke(() => + { + Screen.Clear(); + for (int i = 0; i < ItemsPerPage; i++) + { + Screen.Add(TrainInfo.Count > i ? TrainInfo[i] : new()); + } + }); + } + } +} diff --git a/CRSim.ScreenSimulator/ViewModels/Daqingdong/PlatfromScreenViewModel.cs b/CRSim.ScreenSimulator/ViewModels/Daqingdong/PlatfromScreenViewModel.cs new file mode 100644 index 0000000..f2a2e15 --- /dev/null +++ b/CRSim.ScreenSimulator/ViewModels/Daqingdong/PlatfromScreenViewModel.cs @@ -0,0 +1,36 @@ +using CRSim.Core.Models; +using CRSim.Core.Services; +using CRSim.ScreenSimulator.Models; +using System.Collections.ObjectModel; +using System.Windows; +namespace CRSim.ScreenSimulator.ViewModels.Daqingdong +{ + public class PlatformScreenViewModel : ScreenViewModel + { + public ObservableCollection Screen { get; set; } = []; + public PlatformScreenViewModel(ITimeService timeService, ISettingsService settingsService) + : base(timeService, settingsService) + { + StationType = StationType.Departure; + timeService.RefreshSecondsElapsed += RefreshDisplay; + Initialize(); + } + private async void Initialize() + { + ItemsPerPage = 3; + await WaitForDataLoadAsync(); + RefreshDisplay(null,null); + } + private void RefreshDisplay(object? sender, EventArgs e) + { + Application.Current.Dispatcher.Invoke(() => + { + Screen.Clear(); + for (int i = 0; i < ItemsPerPage; i++) + { + Screen.Add(TrainInfo.Count > i ? TrainInfo[i] : new()); + } + }); + } + } +} diff --git a/CRSim.ScreenSimulator/Views/Beijing/ArrivalScreenView.xaml b/CRSim.ScreenSimulator/Views/Beijing/ArrivalScreenView.xaml new file mode 100644 index 0000000..2a797df --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Beijing/ArrivalScreenView.xaml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim.ScreenSimulator/Views/Beijing/ArrivalScreenView.xaml.cs b/CRSim.ScreenSimulator/Views/Beijing/ArrivalScreenView.xaml.cs new file mode 100644 index 0000000..0cedb4a --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Beijing/ArrivalScreenView.xaml.cs @@ -0,0 +1,36 @@ +using CRSim.ScreenSimulator.ViewModels.Beijing; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; +namespace CRSim.ScreenSimulator.Views.Beijing +{ + /// + /// SecondaryScreen.xaml 的交互逻辑 + /// + public partial class ArrivalScreenView : Window + { + public ArrivalScreenViewModel ViewModel { get; } + public ArrivalScreenView(ArrivalScreenViewModel 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.ScreenSimulator/Views/Daqingdong/PlatformScreenView.xaml b/CRSim.ScreenSimulator/Views/Daqingdong/PlatformScreenView.xaml new file mode 100644 index 0000000..7dc9031 --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Daqingdong/PlatformScreenView.xaml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim.ScreenSimulator/Views/Daqingdong/PlatformScreenView.xaml.cs b/CRSim.ScreenSimulator/Views/Daqingdong/PlatformScreenView.xaml.cs new file mode 100644 index 0000000..0a7e272 --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Daqingdong/PlatformScreenView.xaml.cs @@ -0,0 +1,36 @@ +using CRSim.ScreenSimulator.ViewModels.Daqingdong; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; +namespace CRSim.ScreenSimulator.Views.Daqingdong +{ + /// + /// SecondaryScreen.xaml 的交互逻辑 + /// + public partial class PlatformScreenView : Window + { + public PlatformScreenViewModel ViewModel { get; } + public PlatformScreenView(PlatformScreenViewModel 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 d6b57c4..a387260 100644 --- a/CRSim/App.xaml.cs +++ b/CRSim/App.xaml.cs @@ -67,7 +67,7 @@ services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -81,6 +81,10 @@ services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); }).Build(); [STAThread] diff --git a/CRSim/Assets/StyleImages/Beijing/ArrivalScreen.png b/CRSim/Assets/StyleImages/Beijing/ArrivalScreen.png new file mode 100644 index 0000000..a4b261a Binary files /dev/null and b/CRSim/Assets/StyleImages/Beijing/ArrivalScreen.png differ diff --git a/CRSim/Assets/StyleImages/Daqingdong/PlatformScreen.png b/CRSim/Assets/StyleImages/Daqingdong/PlatformScreen.png new file mode 100644 index 0000000..4db2890 Binary files /dev/null and b/CRSim/Assets/StyleImages/Daqingdong/PlatformScreen.png differ diff --git a/CRSim/CRSim.csproj b/CRSim/CRSim.csproj index d130a36..3355b5b 100644 --- a/CRSim/CRSim.csproj +++ b/CRSim/CRSim.csproj @@ -72,6 +72,8 @@ + + diff --git a/CRSim/Models/StylesInfoData.json b/CRSim/Models/StylesInfoData.json index 71a59c0..f15868e 100644 --- a/CRSim/Models/StylesInfoData.json +++ b/CRSim/Models/StylesInfoData.json @@ -259,5 +259,30 @@ "Station", "Text" ] + }, + { + "UniqueId": "Beijing.ArrivalScreen", + "Title": "北京站到达看板", + "Station": "北京", + "Author": "wxl0430", + "Type": "到达屏(站台)", + "ImagePath": "Assets/StyleImages/Beijing/ArrivalScreen.png", + "Parameters": [ + "Station", + "Platform" + ] + }, + { + "UniqueId": "Daqingdong.PlatformScreen", + "Title": "大庆东站站台看板", + "Station": "大庆东", + "Author": "wxl0430", + "Type": "站台屏", + "ImagePath": "Assets/StyleImages/Daqingdong/PlatformScreen.png", + "Parameters": [ + "Station", + "Platform", + "Location" + ] } ] \ No newline at end of file