diff --git a/CRSim/App.xaml.cs b/CRSim/App.xaml.cs index 5bd9e9c..e0a018a 100644 --- a/CRSim/App.xaml.cs +++ b/CRSim/App.xaml.cs @@ -55,6 +55,8 @@ services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); }).Build(); [STAThread] diff --git a/CRSim/Assets/StyleImages/Jinanxi/SmallScreen.png b/CRSim/Assets/StyleImages/Jinanxi/SmallScreen.png new file mode 100644 index 0000000..c43e197 Binary files /dev/null and b/CRSim/Assets/StyleImages/Jinanxi/SmallScreen.png differ diff --git a/CRSim/CRSim.csproj b/CRSim/CRSim.csproj index 80f527f..6070c73 100644 --- a/CRSim/CRSim.csproj +++ b/CRSim/CRSim.csproj @@ -14,13 +14,7 @@ - - - - - - - + PreserveNewest @@ -46,6 +40,7 @@ + @@ -98,6 +93,9 @@ Code + + Code + diff --git a/CRSim/Models/StylesInfoData.json b/CRSim/Models/StylesInfoData.json index fe5ab4e..58a1cb4 100644 --- a/CRSim/Models/StylesInfoData.json +++ b/CRSim/Models/StylesInfoData.json @@ -105,5 +105,15 @@ "Parameters": [ "Station" ] + }, + { + "UniqueId": "Jinanxi SmallScreen", + "Title": "济南西站小屏看板", + "Station": "Jinanxi", + "StyleName": "SmallScreenView", + "ImagePath": "Assets/StyleImages/Jinanxi/SmallScreen.png", + "Parameters": [ + "Station" + ] } ] \ No newline at end of file diff --git a/CRSim/ViewModels/Windows/ScreenViewModel.cs b/CRSim/ViewModels/Windows/ScreenViewModel.cs index a6521b9..d5d2dca 100644 --- a/CRSim/ViewModels/Windows/ScreenViewModel.cs +++ b/CRSim/ViewModels/Windows/ScreenViewModel.cs @@ -15,6 +15,8 @@ namespace CRSim.ViewModels private string _currentSecond; [ObservableProperty] private string _text = ""; + [ObservableProperty] + private Station _thisStation; public event PropertyChangedEventHandler PropertyChanged; public List TrainInfo { get; set; } = []; @@ -56,6 +58,7 @@ namespace CRSim.ViewModels public void LoadData(Station station,string ticketCheck,string platform) { + ThisStation = station; var trains = station.StationStops; foreach (var trainNumber in trains) { diff --git a/CRSim/ViewModels/Windows/Stations/Jinanxi/SmallScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/Jinanxi/SmallScreenViewModel.cs new file mode 100644 index 0000000..66db7f0 --- /dev/null +++ b/CRSim/ViewModels/Windows/Stations/Jinanxi/SmallScreenViewModel.cs @@ -0,0 +1,41 @@ +namespace CRSim.ViewModels.Jinanxi +{ + public class SmallScreenViewModel : ScreenViewModel + { + public ObservableCollection Screen { get; private set; } = []; + public SmallScreenViewModel(ITimeService timeService, ISettingsService settingsService) + : base(timeService, settingsService) + { + ItemsPerPage = 9; + PageCount = 1; + timeService.RefreshSecondsElapsed += RefreshDisplay; + Initialize(); + } + private async void Initialize() + { + await WaitForDataLoadAsync(); + Text = $"{string.Join(" ", ThisStation.Name.ToCharArray())} 站 欢 迎 您"; + RefreshDisplay(null,null); + } + private void RefreshDisplay(object? sender, EventArgs e) + { + Application.Current.Dispatcher.Invoke(() => + { + int pageCount = (int)Math.Ceiling((double)TrainInfo.Count / (ItemsPerPage * PageCount)); + Screen.Clear(); + int startIndex = CurrentPageIndex * ItemsPerPage * PageCount; + var Items = TrainInfo.Skip(startIndex).Take(ItemsPerPage).ToList(); + while (Items.Count < ItemsPerPage) // Fill up with new object() if not enough items + { + Items.Add(new TrainInfo()); + } + foreach (var item in Items) + { + Screen.Add(item); + } + + CurrentPageIndex = CurrentPageIndex + 1 >= Math.Min(_settings.MaxPages, pageCount) ? 0 : CurrentPageIndex + 1; + }); + } + } +} diff --git a/CRSim/Views/Windows/Stations/Jinanxi/SmallScreenView.xaml b/CRSim/Views/Windows/Stations/Jinanxi/SmallScreenView.xaml new file mode 100644 index 0000000..2b40ab1 --- /dev/null +++ b/CRSim/Views/Windows/Stations/Jinanxi/SmallScreenView.xaml @@ -0,0 +1,214 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim/Views/Windows/Stations/Jinanxi/SmallScreenView.xaml.cs b/CRSim/Views/Windows/Stations/Jinanxi/SmallScreenView.xaml.cs new file mode 100644 index 0000000..f48da0d --- /dev/null +++ b/CRSim/Views/Windows/Stations/Jinanxi/SmallScreenView.xaml.cs @@ -0,0 +1,33 @@ +using CRSim.ViewModels.Jinanxi; + +namespace CRSim.Views.Jinanxi +{ + /// + /// SecondaryScreen.xaml 的交互逻辑 + /// + public partial class SmallScreenView : Window + { + public SmallScreenViewModel ViewModel { get; } + public SmallScreenView(SmallScreenViewModel 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(); + } + } + } +}