diff --git a/CRSim.ScreenSimulator/Converters/LocationToStringConverter.cs b/CRSim.ScreenSimulator/Converters/LocationToStringConverter.cs index ea2c844..699530c 100644 --- a/CRSim.ScreenSimulator/Converters/LocationToStringConverter.cs +++ b/CRSim.ScreenSimulator/Converters/LocationToStringConverter.cs @@ -13,11 +13,9 @@ namespace CRSim.ScreenSimulator.Converters */ object IMultiValueConverter.Convert(object[] values, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { - // return $"{values[0]},{values[1]},{values[2]}"; if (values[0] is int Length && values[1] is int Location) { if(DisplayMode == "least" && values[2] is string Direction){ - // return Direction; if(Direction == "left") { if(Location <= Length) 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..25206ba --- /dev/null +++ b/CRSim.ScreenSimulator/ViewModels/Beijing/ArrivalScreenViewModel.cs @@ -0,0 +1,63 @@ +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 + { + private ITimeService _timeService; + public ObservableCollection Screen { get; set; } = []; + public ArrivalScreenViewModel(ITimeService timeService, ISettingsService settingsService) + : base(timeService, settingsService) + { + _timeService = timeService; + StationType = StationType.Arrival; + 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()); + } + }); + } + public override void RefreshData(object? sender, EventArgs e) + { + List itemsToRemove = []; + foreach (TrainInfo trainInfo in TrainInfo) + { + if (trainInfo.DepartureTime == null) + { + if (trainInfo.ArrivalTime.Value.Add(_settings.StopDisplayFromArrivalDuration) < _timeService.GetDateTimeNow()) + { + itemsToRemove.Add(trainInfo); + } + } + else + { + if (trainInfo.DepartureTime.Value < _timeService.GetDateTimeNow()) + { + itemsToRemove.Add(trainInfo); + } + } + } + foreach (var item in itemsToRemove) + { + TrainInfo.Remove(item); + } + } + } +} diff --git a/CRSim.ScreenSimulator/ViewModels/DaqingDong/ConcourseBridgeScreen.cs b/CRSim.ScreenSimulator/ViewModels/DaqingDong/ConcourseBridgeScreen.cs new file mode 100644 index 0000000..c33ccbd --- /dev/null +++ b/CRSim.ScreenSimulator/ViewModels/DaqingDong/ConcourseBridgeScreen.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 ConcourseBridgeScreenViewModel : ScreenViewModel + { + public ObservableCollection Screen { get; set; } = []; + public ConcourseBridgeScreenViewModel(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..73023a5 --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Beijing/ArrivalScreenView.xaml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ConcourseBridgeScreen.xaml b/CRSim.ScreenSimulator/Views/DaqingDong/ConcourseBridgeScreen.xaml new file mode 100644 index 0000000..6e25c1c --- /dev/null +++ b/CRSim.ScreenSimulator/Views/DaqingDong/ConcourseBridgeScreen.xaml @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim.ScreenSimulator/Views/DaqingDong/ConcourseBridgeScreen.xaml.cs b/CRSim.ScreenSimulator/Views/DaqingDong/ConcourseBridgeScreen.xaml.cs new file mode 100644 index 0000000..3e38aab --- /dev/null +++ b/CRSim.ScreenSimulator/Views/DaqingDong/ConcourseBridgeScreen.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 ConcourseBridgeScreenView : Window + { + public ConcourseBridgeScreenViewModel ViewModel { get; } + public ConcourseBridgeScreenView(ConcourseBridgeScreenViewModel 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/Zibo/ConcourseBridgeScreenView.xaml b/CRSim.ScreenSimulator/Views/Zibo/ConcourseBridgeScreenView.xaml index cb75ddf..86690bd 100644 --- a/CRSim.ScreenSimulator/Views/Zibo/ConcourseBridgeScreenView.xaml +++ b/CRSim.ScreenSimulator/Views/Zibo/ConcourseBridgeScreenView.xaml @@ -31,27 +31,25 @@ - - - - - - - - + + + - + - - - + + + + + - + IsReadOnly="True" GridLinesVisibility="None" RowHeight="34" Foreground="White" + HeadersVisibility="Column" IsEnabled="False" Margin="0,4"> @@ -155,20 +153,18 @@ - - - - - + + - + - - - - - - + + + + + + diff --git a/CRSim/App.xaml.cs b/CRSim/App.xaml.cs index d6b57c4..eed0b9c 100644 --- a/CRSim/App.xaml.cs +++ b/CRSim/App.xaml.cs @@ -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/ConcourseBridgeScreen.png b/CRSim/Assets/StyleImages/DaqingDong/ConcourseBridgeScreen.png new file mode 100644 index 0000000..4db2890 Binary files /dev/null and b/CRSim/Assets/StyleImages/DaqingDong/ConcourseBridgeScreen.png differ diff --git a/CRSim/CRSim.csproj b/CRSim/CRSim.csproj index d130a36..af84505 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..8f67d11 100644 --- a/CRSim/Models/StylesInfoData.json +++ b/CRSim/Models/StylesInfoData.json @@ -217,7 +217,7 @@ "Title": "淄博站廊桥看板", "Station": "淄博", "Author": "wxl0430", - "Type": "站台屏", + "Type": "走廊出发屏", "ImagePath": "Assets/StyleImages/Zibo/ConcourseBridgeScreen.png", "Parameters": [ "Station", @@ -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.ConcourseBridgeScreen", + "Title": "大庆东站廊桥看板", + "Station": "大庆东", + "Author": "wxl0430", + "Type": "走廊出发屏", + "ImagePath": "Assets/StyleImages/DaqingDong/ConcourseBridgeScreen.png", + "Parameters": [ + "Station", + "Platform", + "Location" + ] } ] \ No newline at end of file