refactor: 更改部分变量、属性、转换器名称 [skip cliff]

This commit is contained in:
denglihong2007
2025-06-08 22:04:38 +08:00
parent 090f136e6b
commit 053a67587b
25 changed files with 40 additions and 40 deletions

View File

@@ -3,7 +3,7 @@ using System.Windows.Data;
namespace CRSim.ScreenSimulator.Converters
{
public class TrainNumberToImageConverter : IValueConverter
public class NumberToImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{

View File

@@ -20,8 +20,8 @@ namespace CRSim.ScreenSimulator.Converters
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);
public SolidColorBrush CheckInColor { get; set; } = new(Colors.LightGreen);
public SolidColorBrush StopCheckInColor { get; set; } = new(Colors.Red);
object IMultiValueConverter.Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
var serviceProvider = (IServiceProvider)Application.Current.Resources["ServiceProvider"];
@@ -38,7 +38,7 @@ namespace CRSim.ScreenSimulator.Converters
//过路站
if (_timeService.GetDateTimeNow() > departureTime.Subtract(_settings.PassingCheckInAdvanceDuration) && _timeService.GetDateTimeNow() < departureTime.Subtract(_settings.StopCheckInAdvanceDuration))
{
return CheckingTicketsColor;
return CheckInColor;
}
}
else
@@ -46,16 +46,16 @@ namespace CRSim.ScreenSimulator.Converters
//始发站
if (_timeService.GetDateTimeNow() > departureTime.Subtract(_settings.DepartureCheckInAdvanceDuration) && _timeService.GetDateTimeNow() < departureTime.Subtract(_settings.StopCheckInAdvanceDuration))
{
return CheckingTicketsColor;
return CheckInColor;
}
}
if (_timeService.GetDateTimeNow() > departureTime.Subtract(_settings.StopCheckInAdvanceDuration))
{
return StopCheckingTicketsColor;
return StopCheckInColor;
}
if (values[2] is TimeSpan state && state.TotalMinutes > 0)
{
return StopCheckingTicketsColor;
return StopCheckInColor;
}
if (DisplayMode == "Alternating_Row_Colors" && values.Length > 3 && values[3] is int rowNumber){
return WaitingColorList[rowNumber % WaitingColorList.Count];

View File

@@ -9,7 +9,7 @@ namespace CRSim.ScreenSimulator.ViewModels.Ankang
{
Text = $"西安局集团公司推出西铁行APP站车服务产品欢迎体验使用。";
ItemsPerPage = 7;
PageCount = 1;
ScreenCount = 1;
StationType = StationType.Arrival;
}
}

View File

@@ -8,7 +8,7 @@ namespace CRSim.ScreenSimulator.ViewModels.BeijingNan
: base(timeService, settingsService)
{
ItemsPerPage = 10;
PageCount = 1;
ScreenCount = 1;
StationType = StationType.Departure;
}
}

View File

@@ -8,7 +8,7 @@ namespace CRSim.ScreenSimulator.ViewModels.BeijingXi
: base(timeService, settingsService)
{
ItemsPerPage = 13;
PageCount = 2;
ScreenCount = 2;
StationType = StationType.Departure;
}
}

View File

@@ -9,7 +9,7 @@ namespace CRSim.ScreenSimulator.ViewModels.ChengduDong
{
Text = " 检票口信息请以车站显示屏信息为准。公共场所请妥善保管个人贵重物品。";
ItemsPerPage = 12;
PageCount = 2;
ScreenCount = 2;
StationType = StationType.Departure;
}
}

View File

@@ -9,7 +9,7 @@ namespace CRSim.ScreenSimulator.ViewModels.ChengduShuangliuAirport
{
Text = $"国内航班截载时间为起飞前{settingsService.GetSettings().StopCheckInAdvanceDuration.TotalMinutes}分钟。";
ItemsPerPage = 7;
PageCount = 1;
ScreenCount = 1;
StationType = StationType.Departure;
}
}

View File

@@ -8,7 +8,7 @@ namespace CRSim.ScreenSimulator.ViewModels.DezhouDong
: base(timeService, settingsService)
{
ItemsPerPage = 10;
PageCount = 1;
ScreenCount = 1;
StationType = StationType.Departure;
}
}

View File

@@ -8,7 +8,7 @@ namespace CRSim.ScreenSimulator.ViewModels.GuangdongIntercity
{
Text = $"列 车 到 发 信 息";
ItemsPerPage = 8;
PageCount = 1;
ScreenCount = 1;
}
}
}

View File

@@ -9,7 +9,7 @@ namespace CRSim.ScreenSimulator.ViewModels.Guangyuan
{
Text = "成都铁路客服电话028-12306";
ItemsPerPage = 12;
PageCount = 1;
ScreenCount = 1;
StationType = StationType.Departure;
}
}

View File

@@ -9,7 +9,7 @@ namespace CRSim.ScreenSimulator.ViewModels.Harbin
{
Text = $"开车前{settingsService.GetSettings().StopCheckInAdvanceDuration.TotalMinutes}分钟停止检票";
ItemsPerPage = 6;
PageCount = 2;
ScreenCount = 2;
StationType = StationType.Departure;
}
}

View File

@@ -8,7 +8,7 @@ namespace CRSim.ScreenSimulator.ViewModels.Jinanxi
: base(timeService, settingsService)
{
ItemsPerPage = 9;
PageCount = 1;
ScreenCount = 1;
StationType = StationType.Departure;
SetText();
}

View File

@@ -9,7 +9,7 @@ namespace CRSim.ScreenSimulator.ViewModels.Niuzhou
{
Text = $"开车前{settingsService.GetSettings().PassingCheckInAdvanceDuration.TotalMinutes}分钟开始检票,开车前{settingsService.GetSettings().StopCheckInAdvanceDuration.TotalMinutes}分钟停止检票。";
ItemsPerPage = 10;
PageCount = 1;
ScreenCount = 1;
StationType = StationType.Departure;
}
}

View File

@@ -45,11 +45,11 @@ namespace CRSim.ScreenSimulator.ViewModels
}
[ObservableProperty]
private int _currentPageIndex = 0;
public int PagesCount
public int PageCount
{
get
{
return Math.Min((int)Math.Ceiling((double)TrainInfo.Count / ItemsPerPage * PageCount.Value),_settings.MaxPages);
return Math.Min((int)Math.Ceiling((double)TrainInfo.Count / ItemsPerPage * ScreenCount.Value),_settings.MaxPages);
}
}
public int ItemsPerPage = 1;
@@ -57,7 +57,7 @@ namespace CRSim.ScreenSimulator.ViewModels
//<summary>
// 适用于翻页屏的屏幕个数参数,非翻页屏请不要设置。
//</summary>
public int? PageCount = null;
public int? ScreenCount = null;
private async void Initialize()
{
@@ -150,7 +150,7 @@ namespace CRSim.ScreenSimulator.ViewModels
{
Application.Current.Dispatcher.Invoke(() =>
{
if (PageCount == null)
if (ScreenCount == null)
{
for (int i = 0; i < ItemsPerPage; i++)
{
@@ -165,10 +165,10 @@ namespace CRSim.ScreenSimulator.ViewModels
}
return;
}
int pageCount = (int)Math.Ceiling((double)TrainInfo.Count / (ItemsPerPage * PageCount.Value));
int startIndex = CurrentPageIndex * ItemsPerPage * PageCount.Value;
int pageCount = (int)Math.Ceiling((double)TrainInfo.Count / (ItemsPerPage * ScreenCount.Value));
int startIndex = CurrentPageIndex * ItemsPerPage * ScreenCount.Value;
switch (PageCount)
switch (ScreenCount)
{
case 1:
{

View File

@@ -8,7 +8,7 @@ namespace CRSim.ScreenSimulator.ViewModels.Shanghai
: base(timeService, settingsService)
{
ItemsPerPage = 9;
PageCount = 1;
ScreenCount = 1;
StationType = StationType.Departure;
}
}

View File

@@ -8,7 +8,7 @@ namespace CRSim.ScreenSimulator.ViewModels.Zibo
: base(timeService, settingsService)
{
ItemsPerPage = 8;
PageCount = 2;
ScreenCount = 2;
StationType = StationType.Departure;
}
}

View File

@@ -9,7 +9,7 @@ namespace CRSim.ScreenSimulator.ViewModels.Zibo
{
Text = $"开车前{settingsService.GetSettings().StopCheckInAdvanceDuration.TotalMinutes}分钟停止检票";
ItemsPerPage = 18;
PageCount = 1;
ScreenCount = 1;
StationType = StationType.Departure;
}
}

View File

@@ -12,17 +12,17 @@ namespace CRSim.ScreenSimulator.ViewModels.Zibo
Text = $" 开车前{settingsService.GetSettings().StopCheckInAdvanceDuration.TotalMinutes}分钟停止检票";
StationType = StationType.Departure;
ItemsPerPage = 5;
PageCount = 2;
ScreenCount = 2;
}
public override void RefreshDisplay(object? sender, EventArgs? e)
{
Application.Current.Dispatcher.Invoke(() =>
{
int pageCount = (int)Math.Ceiling((double)TrainInfo.Count / (ItemsPerPage * PageCount.Value));
int pageCount = (int)Math.Ceiling((double)TrainInfo.Count / (ItemsPerPage * ScreenCount.Value));
ScreenA.Clear();
ScreenB.Clear();
int startIndex = CurrentPageIndex * ItemsPerPage * PageCount.Value;
var ItemsToShow = TrainInfo.Skip(startIndex).Take(ItemsPerPage * PageCount.Value).ToList();
int startIndex = CurrentPageIndex * ItemsPerPage * ScreenCount.Value;
var ItemsToShow = TrainInfo.Skip(startIndex).Take(ItemsPerPage * ScreenCount.Value).ToList();
var leftItems = ItemsToShow.Where((item, index) => index % 2 == 0).ToList();
var rightItems = ItemsToShow.Where((item, index) => index % 2 == 1).ToList();
while (leftItems.Count < ItemsPerPage)

View File

@@ -13,7 +13,7 @@
<converters1:EmptyToVisibilityConverter x:Key="EmptyToVisibilityConverter" />
<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" CheckInColor="#1f5b54">
<converters:TrainStateColorConverter.WaitingColorList>
<SolidColorBrush Color="White"/>
<SolidColorBrush Color="#edd16f"/>

View File

@@ -22,11 +22,11 @@
<converters1:ListToStringConverter x:Key="ListToStringConverter" Separator=", " />
<converters1:EmptyToVisibilityConverter x:Key="EmptyToVisibilityConverter" />
<converters1:DateTimeToStringConverter x:Key="DateTimeToStringConverter" Format="HH:mm" />
<converters:TrainNumberToImageConverter x:Key="TrainNumberToImageConverter" />
<converters:NumberToImageConverter x:Key="TrainNumberToImageConverter" />
<converters:IntAddOneConverter x:Key="IntAddOneConverter" />
<converters:ChineseToPinyinConverter x:Key="ChineseToPinyinConverter" Upper="True"/>
<converters:TrainStateConverter x:Key="TrainStateConverter" WaitingText="正常 Normal" CheckInText="正在登机 Boarding" StopCheckInText="关闭 PSG FULL"/>
<converters:TrainStateColorConverter x:Key="TrainStateColorConverter" WaitingColor="#289CFF" CheckingTicketsColor="#FF6A1D" StopCheckingTicketsColor="#4456BE"/>
<converters:TrainStateColorConverter x:Key="TrainStateColorConverter" WaitingColor="#289CFF" CheckInColor="#FF6A1D" StopCheckInColor="#4456BE"/>
<Style TargetType="DataGridColumnHeader">
<Setter Property="Padding" Value="0,4"/>
<Setter Property="BorderBrush" Value="Transparent"/>

View File

@@ -23,7 +23,7 @@
<Setter Property="SeparatorVisibility" Value="Collapsed"/>
</Style>
<converters:TrainStateConverter x:Key="TrainStateConverter" WaitingText="正在候车"/>
<converters:TrainStateColorConverter x:Key="TrainStateColorConverter" WaitingColor="#FAFAB2" CheckingTicketsColor="#36F8C4"/>
<converters:TrainStateColorConverter x:Key="TrainStateColorConverter" WaitingColor="#FAFAB2" CheckInColor="#36F8C4"/>
<converters:LandmarkToStringConverter x:Key="LandmarkToStringConverter"/>
<converters:NumberToStringConverter x:Key="NumberToStringConverter"/>
<converters:TrainInfoToTicketCheckTimeConverter x:Key="TrainInfoToTicketCheckTimeConverter"/>

View File

@@ -17,7 +17,7 @@
<converters1:DateTimeToStringConverter x:Key="DateTimeToStringWeekdayConverter" Format="dddd" />
<converters1:DateTimeToStringConverter x:Key="DateTimeToStringDateConverter" Format="yyyy/M/d" />
<converters:TrainStateConverter x:Key="TrainStateConverter"/>
<converters:TrainStateColorConverter x:Key="TrainStateColorConverter" WaitingColor="#ffffff" CheckingTicketsColor="#00ff00" StopCheckingTicketsColor="#ff0000"/>
<converters:TrainStateColorConverter x:Key="TrainStateColorConverter" WaitingColor="#ffffff" CheckInColor="#00ff00" StopCheckInColor="#ff0000"/>
<Style TargetType="DataGridColumnHeader">
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0"/>

View File

@@ -16,7 +16,7 @@
<converters1:EmptyToVisibilityConverter x:Key="EmptyToVisibilityConverter" />
<converters1:DateTimeToStringConverter x:Key="DateTimeToStringConverter" Format="HH:mm" />
<converters:TrainStateConverter x:Key="TrainStateConverter" WaitingText="正在候车"/>
<converters:TrainStateColorConverter x:Key="TrainStateColorConverter" WaitingColor="#ffffff" CheckingTicketsColor="#00ff00" StopCheckingTicketsColor="#ff0000"/>
<converters:TrainStateColorConverter x:Key="TrainStateColorConverter" WaitingColor="#ffffff" CheckInColor="#00ff00" StopCheckInColor="#ff0000"/>
<Style TargetType="DataGridColumnHeader">
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0"/>

View File

@@ -20,7 +20,7 @@
<converters1:EmptyToVisibilityConverter x:Key="EmptyToVisibilityConverter" />
<converters1:DateTimeToStringConverter x:Key="DateTimeToStringConverter" Format="HH:mm" />
<converters:TrainStateConverter x:Key="TrainStateConverter" />
<converters:TrainStateColorConverter x:Key="TrainStateColorConverter" WaitingColor="white" CheckingTicketsColor="#1ce048" StopCheckingTicketsColor="#df0122"/>
<converters:TrainStateColorConverter x:Key="TrainStateColorConverter" WaitingColor="white" CheckInColor="#1ce048" StopCheckInColor="#df0122"/>
</Window.Resources>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">

View File

@@ -14,7 +14,7 @@
<converters1:EmptyToVisibilityConverter x:Key="EmptyToVisibilityConverter" />
<converters1:DateTimeToStringConverter x:Key="DateTimeToStringConverter" Format="HH:mm" />
<converters:TrainStateConverter x:Key="TrainStateConverter"/>
<converters:TrainStateColorConverter x:Key="TrainStateColorConverter" WaitingColor="#ffffff" CheckingTicketsColor="#85ff3f" StopCheckingTicketsColor="#ff0200" />
<converters:TrainStateColorConverter x:Key="TrainStateColorConverter" WaitingColor="#ffffff" CheckInColor="#85ff3f" StopCheckInColor="#ff0200" />
<Style TargetType="DataGridColumnHeader">
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0"/>