diff --git a/CRSim.ScreenSimulator/Converters/LocationToStringConverter.cs b/CRSim.ScreenSimulator/Converters/LocationToStringConverter.cs index b666a0d..ea2c844 100644 --- a/CRSim.ScreenSimulator/Converters/LocationToStringConverter.cs +++ b/CRSim.ScreenSimulator/Converters/LocationToStringConverter.cs @@ -6,10 +6,48 @@ namespace CRSim.ScreenSimulator.Converters public class LocationToStringConverter : IMultiValueConverter { public string DisplayMode { get; set; } = "normal"; + /* + normal: 正常 + less: 简化 + least:极简(适用于廊桥屏幕) + */ 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) + { + return $"←1~{Location}"; + } + else if(Length == 1) + { + return "←1"; + } + else + { + return $"←1~{Length}"; + } + } + if(Direction == "right") + { + if(Location+1 > Length){ + return string.Empty; + } + else if(Location+1 == Length) + { + return $"{Length}→"; + } + else{ + return $"{Location+1}~{Length}→"; + } + } + return string.Empty; + } if (DisplayMode == "less") { if (Location > Length) diff --git a/CRSim.ScreenSimulator/ViewModels/Zibo/ConcourseBridgeScreenViewModel.cs b/CRSim.ScreenSimulator/ViewModels/Zibo/ConcourseBridgeScreenViewModel.cs new file mode 100644 index 0000000..66d16ef --- /dev/null +++ b/CRSim.ScreenSimulator/ViewModels/Zibo/ConcourseBridgeScreenViewModel.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.Zibo +{ + 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 = 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/Views/Zibo/ConcourseBridgeScreenView.xaml b/CRSim.ScreenSimulator/Views/Zibo/ConcourseBridgeScreenView.xaml new file mode 100644 index 0000000..cb75ddf --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Zibo/ConcourseBridgeScreenView.xaml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim.ScreenSimulator/Views/Zibo/ConcourseBridgeScreenView.xaml.cs b/CRSim.ScreenSimulator/Views/Zibo/ConcourseBridgeScreenView.xaml.cs new file mode 100644 index 0000000..16d6f6d --- /dev/null +++ b/CRSim.ScreenSimulator/Views/Zibo/ConcourseBridgeScreenView.xaml.cs @@ -0,0 +1,36 @@ +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 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/App.xaml.cs b/CRSim/App.xaml.cs index 965347c..d6b57c4 100644 --- a/CRSim/App.xaml.cs +++ b/CRSim/App.xaml.cs @@ -65,6 +65,8 @@ services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/CRSim/Assets/StyleImages/Zibo/ConcourseBridgeScreen.png b/CRSim/Assets/StyleImages/Zibo/ConcourseBridgeScreen.png new file mode 100644 index 0000000..3b90777 Binary files /dev/null and b/CRSim/Assets/StyleImages/Zibo/ConcourseBridgeScreen.png differ diff --git a/CRSim/CRSim.csproj b/CRSim/CRSim.csproj index 8b9cc6b..d130a36 100644 --- a/CRSim/CRSim.csproj +++ b/CRSim/CRSim.csproj @@ -71,6 +71,7 @@ + diff --git a/CRSim/Models/StylesInfoData.json b/CRSim/Models/StylesInfoData.json index bdc42e2..71a59c0 100644 --- a/CRSim/Models/StylesInfoData.json +++ b/CRSim/Models/StylesInfoData.json @@ -212,6 +212,19 @@ "Text" ] }, + { + "UniqueId": "Zibo.ConcourseBridgeScreen", + "Title": "淄博站廊桥看板", + "Station": "淄博", + "Author": "wxl0430", + "Type": "站台屏", + "ImagePath": "Assets/StyleImages/Zibo/ConcourseBridgeScreen.png", + "Parameters": [ + "Station", + "Platform", + "Location" + ] + }, { "UniqueId": "Jinanxi.SmallScreen", "Title": "济南西站小屏看板",