mirror of
https://github.com/denglihong2007/CRSim
synced 2026-08-06 09:16:25 +08:00
chore: 适配最新commit
This commit is contained in:
@@ -18,11 +18,11 @@ namespace CRSim.ScreenSimulator.Converters
|
||||
Alternating_Row_Colors: 候车状态隔行异色显示(第4个参数控制行号)。
|
||||
*/
|
||||
|
||||
public List<SolidColorBrush> WaitingColorList { get; set; } = new List<SolidColorBrush> { new(Colors.White), new(Colors.Yellow) };
|
||||
public List<SolidColorBrush> WaitingColorList { get; set; } = [];
|
||||
public SolidColorBrush WaitingColor { get; set; } = new(Colors.White);
|
||||
public SolidColorBrush CheckingTicketsColor { get; set; } = new(Colors.LightGreen);
|
||||
public SolidColorBrush StopCheckingTicketsColor { get; set; } = new(Colors.Red);
|
||||
object IMultiValueConverter.Convert(object[] values, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
object IMultiValueConverter.Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var serviceProvider = (IServiceProvider)Application.Current.Resources["ServiceProvider"];
|
||||
_timeService = serviceProvider.GetRequiredService<ITimeService>();
|
||||
|
||||
@@ -1,45 +1,15 @@
|
||||
using CRSim.Core.Models;
|
||||
using CRSim.Core.Services;
|
||||
using CRSim.ScreenSimulator.Models;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
namespace CRSim.ScreenSimulator.ViewModels.BeijingNan
|
||||
{
|
||||
public class PrimaryScreenViewModel : ScreenViewModel
|
||||
{
|
||||
public ObservableCollection<TrainInfo> LeftScreen { get; private set; } = [];
|
||||
public PrimaryScreenViewModel(ITimeService timeService, ISettingsService settingsService)
|
||||
: base(timeService, settingsService)
|
||||
{
|
||||
ItemsPerPage = 10;
|
||||
PageCount = 1;
|
||||
StationType = StationType.Departure;
|
||||
timeService.RefreshSecondsElapsed += RefreshDisplay;
|
||||
Initialize();
|
||||
}
|
||||
private async void Initialize()
|
||||
{
|
||||
await WaitForDataLoadAsync();
|
||||
RefreshDisplay(null,null);
|
||||
}
|
||||
private void RefreshDisplay(object? sender, EventArgs e)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
int pageCount = (int)Math.Ceiling((double)TrainInfo.Count / (ItemsPerPage * PageCount));
|
||||
LeftScreen.Clear();
|
||||
int startIndex = CurrentPageIndex * ItemsPerPage * PageCount;
|
||||
var leftItems = TrainInfo.Skip(startIndex).Take(ItemsPerPage).ToList();
|
||||
while (leftItems.Count < ItemsPerPage) // Fill up with new object() if not enough items
|
||||
{
|
||||
leftItems.Add(new TrainInfo());
|
||||
}
|
||||
foreach (var item in leftItems)
|
||||
{
|
||||
LeftScreen.Add(item);
|
||||
}
|
||||
CurrentPageIndex = CurrentPageIndex + 1 >= Math.Min(_settings.MaxPages, pageCount) ? 0 : CurrentPageIndex + 1;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,12 @@
|
||||
<converters1:ListToStringConverter x:Key="ListToStringConverter" Separator="" />
|
||||
<converters1:DateTimeToStringConverter x:Key="DateTimeToStringConverter" Format="HH:mm" />
|
||||
<converters:TrainStateConverter x:Key="TrainStateConverter" WaitingText="正在候车"/>
|
||||
<converters:TrainStateColorConverter x:Key="TrainStateColorConverter" DisplayMode="Alternating_Row_Colors" CheckingTicketsColor="#1f5b54"/>
|
||||
<converters:TrainStateColorConverter x:Key="TrainStateColorConverter" DisplayMode="Alternating_Row_Colors" CheckingTicketsColor="#1f5b54">
|
||||
<converters:TrainStateColorConverter.WaitingColorList>
|
||||
<SolidColorBrush Color="White"/>
|
||||
<SolidColorBrush Color="#edd16f"/>
|
||||
</converters:TrainStateColorConverter.WaitingColorList>
|
||||
</converters:TrainStateColorConverter>
|
||||
<converters:TextSpacingConverter x:Key="TextSpacingConverter" />
|
||||
<Style TargetType="DataGridColumnHeader">
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using CRSim.ScreenSimulator.ViewModels.BeijingNan;
|
||||
using CRSim.ScreenSimulator.Converters;
|
||||
using System.Windows;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace CRSim.ScreenSimulator.Views.BeijingNan
|
||||
{
|
||||
public partial class PrimaryScreenView : BaseScreenView
|
||||
@@ -14,13 +9,6 @@ namespace CRSim.ScreenSimulator.Views.BeijingNan
|
||||
InitializeComponent();
|
||||
ViewModel = viewModel;
|
||||
DataContext = viewModel;
|
||||
|
||||
var trainStateColorConverter = (TrainStateColorConverter)Resources["TrainStateColorConverter"];
|
||||
trainStateColorConverter.WaitingColorList = new List<SolidColorBrush>
|
||||
{
|
||||
new SolidColorBrush(Colors.White),
|
||||
new SolidColorBrush((Color)ColorConverter.ConvertFromString("#edd16f"))
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user