diff --git a/CRSim/App.xaml.cs b/CRSim/App.xaml.cs index e0a018a..42b79cc 100644 --- a/CRSim/App.xaml.cs +++ b/CRSim/App.xaml.cs @@ -57,6 +57,8 @@ services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); }).Build(); [STAThread] diff --git a/CRSim/Assets/StyleImages/Dongchengnan/SecondaryScreen.png b/CRSim/Assets/StyleImages/Dongchengnan/SecondaryScreen.png new file mode 100644 index 0000000..6f92dc0 Binary files /dev/null and b/CRSim/Assets/StyleImages/Dongchengnan/SecondaryScreen.png differ diff --git a/CRSim/CRSim.csproj b/CRSim/CRSim.csproj index 6070c73..cf1c4ba 100644 --- a/CRSim/CRSim.csproj +++ b/CRSim/CRSim.csproj @@ -44,6 +44,7 @@ + @@ -93,7 +94,10 @@ Code - + + Code + + Code diff --git a/CRSim/Models/StylesInfoData.json b/CRSim/Models/StylesInfoData.json index 58a1cb4..d2711fd 100644 --- a/CRSim/Models/StylesInfoData.json +++ b/CRSim/Models/StylesInfoData.json @@ -115,5 +115,15 @@ "Parameters": [ "Station" ] + }, + { + "UniqueId": "Dongchengnan SecondaryScreen", + "Title": "东城南站次要看板", + "Station": "Dongchengnan", + "StyleName": "SecondaryScreenView", + "ImagePath": "Assets/StyleImages/Dongchengnan/SecondaryScreen.png", + "Parameters": [ + "Station" + ] } ] \ No newline at end of file diff --git a/CRSim/ViewModels/Windows/ScreenViewModel.cs b/CRSim/ViewModels/Windows/ScreenViewModel.cs index 79dce1b..cfacfde 100644 --- a/CRSim/ViewModels/Windows/ScreenViewModel.cs +++ b/CRSim/ViewModels/Windows/ScreenViewModel.cs @@ -1,4 +1,6 @@ using System.Linq; +using System; +using System.Globalization; namespace CRSim.ViewModels { @@ -14,6 +16,8 @@ namespace CRSim.ViewModels [ObservableProperty] private string _currentSecond; [ObservableProperty] + private string _currentTime_Dongchengnan; + [ObservableProperty] private string _text = ""; [ObservableProperty] private Station _thisStation; @@ -21,6 +25,7 @@ namespace CRSim.ViewModels public List TrainInfo { get; set; } = []; + CultureInfo culture = new CultureInfo("zh-CN"); protected ScreenViewModel(ITimeService timeService, ISettingsService settingsService) { @@ -52,6 +57,9 @@ namespace CRSim.ViewModels CurrentTime = _timeService.GetDateTimeNow().ToString("yyyy-MM-dd HH:mm:ss"); CurrentDate = _timeService.GetDateTimeNow().ToString("yyyy-MM-dd"); CurrentSecond = _timeService.GetDateTimeNow().ToString("HH:mm:ss"); + CurrentTime_Dongchengnan = _timeService.GetDateTimeNow().ToString("H:m") + "\n" + + culture.DateTimeFormat.GetDayName(_timeService.GetDateTimeNow().DayOfWeek) + "\n" + + _timeService.GetDateTimeNow().ToString("yyyy/M/d"); } public Task WaitForDataLoadAsync() => _dataLoaded.Task; diff --git a/CRSim/ViewModels/Windows/Stations/Dongchengnan/SecondaryScreenViewModel.cs b/CRSim/ViewModels/Windows/Stations/Dongchengnan/SecondaryScreenViewModel.cs new file mode 100644 index 0000000..8352034 --- /dev/null +++ b/CRSim/ViewModels/Windows/Stations/Dongchengnan/SecondaryScreenViewModel.cs @@ -0,0 +1,41 @@ +namespace CRSim.ViewModels.Dongchengnan +{ + public class SecondaryScreenViewModel : ScreenViewModel + { + public ObservableCollection Screen { get; private set; } = []; + public SecondaryScreenViewModel(ITimeService timeService, ISettingsService settingsService) + : base(timeService, settingsService) + { + ItemsPerPage = 8; + PageCount = 1; + timeService.RefreshSecondsElapsed += RefreshDisplay; + Initialize(); + } + private async void Initialize() + { + await WaitForDataLoadAsync(); + Text = $" 列 车 到 发 信 息"; + 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/Dongchengnan/SecondaryScreenView.xaml b/CRSim/Views/Windows/Stations/Dongchengnan/SecondaryScreenView.xaml new file mode 100644 index 0000000..4cfb5f7 --- /dev/null +++ b/CRSim/Views/Windows/Stations/Dongchengnan/SecondaryScreenView.xaml @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CRSim/Views/Windows/Stations/Dongchengnan/SecondaryScreenView.xaml.cs b/CRSim/Views/Windows/Stations/Dongchengnan/SecondaryScreenView.xaml.cs new file mode 100644 index 0000000..d309e66 --- /dev/null +++ b/CRSim/Views/Windows/Stations/Dongchengnan/SecondaryScreenView.xaml.cs @@ -0,0 +1,33 @@ +using CRSim.ViewModels.Dongchengnan; + +namespace CRSim.Views.Dongchengnan +{ + /// + /// SecondaryScreen.xaml 的交互逻辑 + /// + public partial class SecondaryScreenView : Window + { + public SecondaryScreenViewModel ViewModel { get; } + public SecondaryScreenView(SecondaryScreenViewModel 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(); + } + } + } +}