diff --git a/CRSim.ScreenSimulator/Converters/LocationToStringConverter.cs b/CRSim.ScreenSimulator/Converters/LocationToStringConverter.cs index f1e6b75..e174223 100644 --- a/CRSim.ScreenSimulator/Converters/LocationToStringConverter.cs +++ b/CRSim.ScreenSimulator/Converters/LocationToStringConverter.cs @@ -5,23 +5,44 @@ namespace CRSim.ScreenSimulator.Converters { public class LocationToStringConverter : IMultiValueConverter { + public string DisplayMode { get; set; } = "normal"; object IMultiValueConverter.Convert(object[] values, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { - if (values[0] is int Length&& values[1] is int Location) + if (values[0] is int Length && values[1] is int Location) { - if (Location > Length) + if (DisplayMode == "less") { - return $"当前无车,1-{Length}车向后。"; + if (Location > Length) + { + return $"当前无车厢,1~{Length}车厢向前。"; + } + if (Location == Length) + { + return $"当前{Length}车厢,1车厢向前。"; + } + if (Location == 1) + { + return $"当前1车厢,{Length}车厢向后。"; + } + return $"1车厢向前,{Length}车厢向后。"; } - if (Location == Length) + if (DisplayMode == "normal") { - return $"当前{Length}车,1-{Length-1}车向后。"; + if (Location > Length) + { + return $"当前无车,1-{Length}车向后。"; + } + if (Location == Length) + { + return $"当前{Length}车,1-{Length-1}车向后。"; + } + if (Location == 1) + { + return $"当前1车,2-{Length}车向前。"; + } + return $"当前{Location}车,1-{Location - 1}车向前,{Location + 1}-{Length}车向后。"; } - if (Location == 1) - { - return $"当前1车,2-{Length}车向前。"; - } - return $"当前{Location}车,1-{Location - 1}车向前,{Location + 1}-{Length}车向后。"; + return string.Empty; } return string.Empty; } diff --git a/CRSim.ScreenSimulator/ViewModels/Windows/Stations/Zibo/PlatformScreenViewModel.cs b/CRSim.ScreenSimulator/ViewModels/Windows/Stations/Zibo/PlatformScreenViewModel.cs new file mode 100644 index 0000000..4369b11 --- /dev/null +++ b/CRSim.ScreenSimulator/ViewModels/Windows/Stations/Zibo/PlatformScreenViewModel.cs @@ -0,0 +1,62 @@ +using CRSim.Core.Services; +using CRSim.ScreenSimulator.Models; +using System.Collections.ObjectModel; +using System.Windows; +namespace CRSim.ScreenSimulator.ViewModels.Zibo +{ + public class PlatformScreenViewModel : ScreenViewModel + { + private ITimeService _timeService; + public ObservableCollection Screen { get; set; } = []; + public PlatformScreenViewModel(ITimeService timeService, ISettingsService settingsService) + : base(timeService, settingsService) + { + _timeService = timeService; + timeService.RefreshSecondsElapsed += RefreshDisplay; + Text = $"请站在白色安全线以内排队候车"; + Initialize(); + } + private async void Initialize() + { + await WaitForDataLoadAsync(); + RefreshDisplay(null,null); + } + private void RefreshDisplay(object? sender, EventArgs e) + { + Application.Current.Dispatcher.Invoke(() => + { + Screen.Add(TrainInfo.Count > 0 ? TrainInfo[0] : new()); + if (Screen.Count == 1) return; + Screen.RemoveAt(0); + }); + } + public override void RefreshData(object? sender, EventArgs e) + { + if (CurrentPageIndex == 0) + { + 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/Views/Windows/Stations/Zibo/PlatformScreenView.xaml b/CRSim.ScreenSimulator/Views/Windows/Stations/Zibo/PlatformScreenView.xaml new file mode 100644 index 0000000..47d41e1 --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Windows/Stations/Zibo/PlatformScreenView.xaml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim.ScreenSimulator/Views/Windows/Stations/Zibo/PlatformScreenView.xaml.cs b/CRSim.ScreenSimulator/Views/Windows/Stations/Zibo/PlatformScreenView.xaml.cs new file mode 100644 index 0000000..82619b7 --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Windows/Stations/Zibo/PlatformScreenView.xaml.cs @@ -0,0 +1,38 @@ +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 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 73ba7f0..6c37647 100644 --- a/CRSim/App.xaml.cs +++ b/CRSim/App.xaml.cs @@ -61,6 +61,8 @@ services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/CRSim/Assets/StyleImages/Zibo/PlatformScreen.png b/CRSim/Assets/StyleImages/Zibo/PlatformScreen.png new file mode 100644 index 0000000..de53c91 Binary files /dev/null and b/CRSim/Assets/StyleImages/Zibo/PlatformScreen.png differ diff --git a/CRSim/CRSim.csproj b/CRSim/CRSim.csproj index 8a6b043..36ef8c2 100644 --- a/CRSim/CRSim.csproj +++ b/CRSim/CRSim.csproj @@ -57,6 +57,7 @@ + diff --git a/CRSim/Models/StylesInfoData.json b/CRSim/Models/StylesInfoData.json index 66a3738..84fc035 100644 --- a/CRSim/Models/StylesInfoData.json +++ b/CRSim/Models/StylesInfoData.json @@ -144,6 +144,31 @@ "Station" ] }, + { + "UniqueId": "Zibo TicketCheckScreen", + "Title": "淄博站检票口看板", + "Station": "Zibo", + "StyleName": "TicketCheckScreenView", + "ImagePath": "Assets/StyleImages/Zibo/TicketCheckScreen.png", + "Parameters": [ + "Station", + "TicketCheck", + "Text" + ] + }, + { + "UniqueId": "Zibo PlatformScreen", + "Title": "淄博站站台看板", + "Station": "Zibo", + "StyleName": "PlatformScreenView", + "ImagePath": "Assets/StyleImages/Zibo/PlatformScreen.png", + "Parameters": [ + "Station", + "Platform", + "Location", + "Text" + ] + }, { "UniqueId": "Jinanxi SmallScreen", "Title": "济南西站小屏看板", @@ -175,17 +200,5 @@ "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