feat: 添加列车、站台长度功能,并优化界面

This commit is contained in:
denglihong2007
2025-03-09 01:16:09 +08:00
parent 579c05d9e8
commit c13d35cd60
26 changed files with 412 additions and 273 deletions

View File

@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;
using System.Text.Json;
using System.Threading.Tasks;
using CRSim.Core.Services;
namespace CRSim.Core.Converters
{
@@ -12,6 +8,7 @@ namespace CRSim.Core.Converters
{
private const string TimeFormat = "HH:mm:ss";
public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.String)

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CRSim.Core.Models
{
public class Platform
{
public string Name { get; set; }
public int Length { get; set; }
}
}

View File

@@ -26,6 +26,6 @@ namespace CRSim.Core.Models
public List<StationStop> StationStops { get; set; } = [];
public List<string> Platforms { get; set; } = [];
public List<Platform> Platforms { get; set; } = [];
}
}

View File

@@ -27,5 +27,7 @@ namespace CRSim.Core.Models
public string Platform { get; set; }
public string? Landmark { get; set; }
public int Length { get; set; }
}
}

View File

@@ -133,11 +133,13 @@ namespace CRSim.Core.Services
var platform = string.IsNullOrWhiteSpace(data[5]) ? "未知" : data[5];
var ticketCheck = string.IsNullOrWhiteSpace(data[4]) ? string.Empty : data[4];
if (!station.Platforms.Contains(platform))
var existingPlatform = station.Platforms.FirstOrDefault(x => x.Name == platform);
if (existingPlatform == null)
{
station.Platforms.Add(platform);
station.Platforms.Add(new Platform { Name = platform, Length = 20 });
}
var waitingArea = station.WaitingAreas.FirstOrDefault(x => x.Name == waitingAreaName);
if (waitingArea == null)
{
@@ -181,6 +183,7 @@ namespace CRSim.Core.Services
ArrivalTime = arrivalTime,
DepartureTime = departureTime,
Platform = platform,
Length = data[0].StartsWith('G') || data[0].StartsWith('D') || data[0].StartsWith('C') ? Math.Abs(data[0].GetHashCode()) % 3 == 0 ? 8 : 16 : 18,
Landmark = data[8] + "色" ?? null,
});
}

View File

@@ -10,15 +10,15 @@ namespace CRSim.Converters
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if(value is string number)
if(value is int l)
{
if(number.StartsWith('G')|| number.StartsWith('D')|| number.StartsWith('C'))
if (l % 2 == 0)
{
return Math.Abs(number.GetHashCode()) % 3 == 0 ? "1-8" : "9-16";
return (new List<string> { $"1-{l / 2}", $"{l / 2 + 1}-{l}" })[l.GetHashCode() % 2];
}
else
{
return Math.Abs(number.GetHashCode()) % 2 == 0 ? "1-9" : "10-18";
return (new List<string> { $"1-{(l + 1) / 2}", $"{(l + 1) / 2}-{l}" })[l.GetHashCode() % 2];
}
}
return value;

View File

@@ -12,5 +12,6 @@
public string Platform { get; set; }
public TimeSpan State { get; set; }
public string? Landmark { get; set; }
public int Length { get; set; }
}
}

View File

@@ -145,5 +145,19 @@ namespace CRSim.Services
}
return null;
}
public List<Platform>? GetInputPlatform()
{
var dialog = new PlatformDialog()
{
Owner = _owner
};
bool? result = dialog.ShowDialog();
if (result == true)
{
return dialog.GeneratedPlatforms;
}
return null;
}
}
}

View File

@@ -11,6 +11,7 @@
TrainStop? GetInputTrainStop(TrainStop trainStop);
StationStop? GetInputStationStop(List<string> ticketChecks, List<string> platforms);
StationStop? GetInputStationStop(List<string> ticketChecks, List<string> platforms, StationStop stationStop);
List<Platform>? GetInputPlatform();
(string, List<string>) GetInputTicketCheck(List<string> waitingAreaNames);
void SetOwner(Window owner);
}

View File

@@ -2,6 +2,7 @@ using CRSim.Core.Models;
using System.IO;
using System.Linq;
using System.Text;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace CRSim.ViewModels;
@@ -28,7 +29,7 @@ public partial class StationManagementPageViewModel : ObservableObject
private Station _selectedStation = new();
public ObservableCollection<string> WaitingAreaNames { get; private set; } = [];
public ObservableCollection<string> Platforms { get; private set; } = [];
public ObservableCollection<Platform> Platforms { get; private set; } = [];
public ObservableCollection<TicketCheck> TicketChecks { get; private set; } = [];
@@ -75,7 +76,7 @@ public partial class StationManagementPageViewModel : ObservableObject
{
StationStops.Add(stationStop);
}
foreach(string platform in SelectedStation.Platforms)
foreach(var platform in SelectedStation.Platforms)
{
Platforms.Add(platform);
}
@@ -151,29 +152,14 @@ public partial class StationManagementPageViewModel : ObservableObject
[RelayCommand]
public void AddPlatform()
{
string? platform = _dialogService.GetInput("请输入站台名称");
if (platform != null)
var platforms = _dialogService.GetInputPlatform();
if (platforms != null)
{
string[] platforms = platform.Split('-');
if (platforms.Length == 2 && int.TryParse(platforms[0],out int startindex) && int.TryParse(platforms[1], out int endindex))
foreach (var platform in platforms)
{
var startIndex = Math.Min(startindex, endindex);
var endIndex = Math.Max(startindex, endindex);
for(int i = startIndex; i < endIndex + 1; i++)
if (Platforms.Any(x=>x.Name==platform.Name))
{
if (Platforms.Contains(i.ToString()))
{
_dialogService.ShowMessage("添加失败", $"名称 {i} 站台已存在。");
return;
}
Platforms.Add(i.ToString());
}
}
else
{
if (Platforms.Contains(platform))
{
_dialogService.ShowMessage("添加失败", $"名称 {platform} 站台已存在。");
_dialogService.ShowMessage("添加失败", $"编号 {platform.Name} 站台已存在。");
return;
}
Platforms.Add(platform);
@@ -184,9 +170,9 @@ public partial class StationManagementPageViewModel : ObservableObject
[RelayCommand]
public void DeletePlatform(object selectedPlatform)
{
if (selectedPlatform is string n)
if (selectedPlatform is Platform p)
{
Platforms.Remove(n);
Platforms.Remove(p);
}
}
[RelayCommand]
@@ -240,7 +226,7 @@ public partial class StationManagementPageViewModel : ObservableObject
_databaseService.UpdateStation(SelectedStation.Name, GenerateStation(SelectedStation.Name,WaitingAreaNames,TicketChecks,StationStops,Platforms));
await _databaseService.SaveData();
}
public static Station GenerateStation(string stationName, ObservableCollection<string> waitingAreaNames, ObservableCollection<TicketCheck> ticketChecks,ObservableCollection<StationStop> stationStops,ObservableCollection<string> platforms)
public static Station GenerateStation(string stationName, ObservableCollection<string> waitingAreaNames, ObservableCollection<TicketCheck> ticketChecks,ObservableCollection<StationStop> stationStops,ObservableCollection<Platform> platforms)
{
var station = new Station
{
@@ -336,7 +322,8 @@ public partial class StationManagementPageViewModel : ObservableObject
ArrivalTime = arrivalTime,
DepartureTime = departureTime,
TicketChecks = [TicketChecks[new Random().Next(TicketChecks.Count)].Name],
Platform = Platforms[new Random().Next(Platforms.Count)],
Platform = Platforms[new Random().Next(Platforms.Count)].Name,
Length = firstColumn.StartsWith('G') || firstColumn.StartsWith('D') || firstColumn.StartsWith('C') ? Math.Abs(firstColumn.GetHashCode()) % 3 == 0 ? 8 : 16 : 18,
Landmark = new[] { "红色", "绿色", "褐色", "蓝色", "紫色", "黄色", "橙色",null}[new Random().Next(8)]
});
}
@@ -366,7 +353,7 @@ public partial class StationManagementPageViewModel : ObservableObject
[RelayCommand]
public void AddStationStop()
{
var newStationStop = _dialogService.GetInputStationStop([.. TicketChecks.Select(x => x.Name)], [.. Platforms]);
var newStationStop = _dialogService.GetInputStationStop([.. TicketChecks.Select(x => x.Name)], [.. Platforms.Select(x => x.Name)]);
if (newStationStop != null)
{
if (StationStops.Any(x => x.Number == newStationStop.Number))
@@ -396,7 +383,7 @@ public partial class StationManagementPageViewModel : ObservableObject
{
if (_selectedStationStop is StationStop selectedStationStop)
{
var newStationStop = _dialogService.GetInputStationStop([.. TicketChecks.Select(x => x.Name)], [.. Platforms], selectedStationStop);
var newStationStop = _dialogService.GetInputStationStop([.. TicketChecks.Select(x => x.Name)], [.. Platforms.Select(x => x.Name)], selectedStationStop);
if (newStationStop != null)
{
StationStops[StationStops.IndexOf(selectedStationStop)] = newStationStop;
@@ -431,8 +418,9 @@ public partial class StationManagementPageViewModel : ObservableObject
foreach (StationStop t in stops)
{
t.TicketChecks = [TicketChecks[new Random().Next(TicketChecks.Count)].Name];
t.Platform = Platforms[new Random().Next(Platforms.Count)];
t.Platform = Platforms[new Random().Next(Platforms.Count)].Name;
t.Landmark = new[] { "红色", "绿色", "褐色", "蓝色", "紫色", "黄色", "橙色", null }[new Random().Next(8)];
t.Length = t.Number.StartsWith('G') || t.Number.StartsWith('D') || t.Number.StartsWith('C') ? Math.Abs(t.Number.GetHashCode()) % 3 == 0 ? 8 : 16 : 18;
StationStops.Add(t);
}
}

View File

@@ -35,11 +35,11 @@ public partial class ScreenSimulationPageViewModel : ObservableObject
public string SelectedTicketCheck = "";
public string SelectedPlatform = "";
public string SelectedPlatformName = "";
public ObservableCollection<string> StationNames { get; private set; } = [];
public ObservableCollection<string> TicketChecks { get; private set; } = [];
public ObservableCollection<string> Platforms { get; private set; } = [];
public ObservableCollection<Platform> Platforms { get; private set; } = [];
[ObservableProperty]
private bool _isStartSimulationAvailable = false;
@@ -65,7 +65,7 @@ public partial class ScreenSimulationPageViewModel : ObservableObject
IsStartSimulationAvailable = selectedStyle!=null &&
(!StationNeeded || !string.IsNullOrWhiteSpace(SelectedStationName))&&
(!TicketCheckNeeded || !string.IsNullOrWhiteSpace(SelectedTicketCheck)) &&
(!PlatformNeeded || !string.IsNullOrWhiteSpace(SelectedPlatform));
(!PlatformNeeded || !string.IsNullOrWhiteSpace(SelectedPlatformName));
}
[RelayCommand]
@@ -89,13 +89,15 @@ public partial class ScreenSimulationPageViewModel : ObservableObject
if(s is string station)
{
SelectedStationName = station;
SelectedPlatformName = "";
SelectedTicketCheck = "";
TicketChecks.Clear();
foreach(string ticketCheck in _databaseService.GetStationByName(SelectedStationName).TicketChecks)
{
TicketChecks.Add(ticketCheck);
}
Platforms.Clear();
foreach (string platform in _databaseService.GetStationByName(SelectedStationName).Platforms)
foreach (var platform in _databaseService.GetStationByName(SelectedStationName).Platforms)
{
Platforms.Add(platform);
}
@@ -114,9 +116,9 @@ public partial class ScreenSimulationPageViewModel : ObservableObject
[RelayCommand]
public void SelectPlatform(object s)
{
if (s is string platform)
if (s is Platform platform)
{
SelectedPlatform = platform;
SelectedPlatformName = platform.Name;
}
CheckCanStart();
}
@@ -132,7 +134,7 @@ public partial class ScreenSimulationPageViewModel : ObservableObject
Window.ViewModel.LoadData(_databaseService.GetStationByName(SelectedStationName),
TicketCheckNeeded ? SelectedTicketCheck : string.Empty,
PlatformNeeded ? SelectedPlatform : string.Empty);
PlatformNeeded ? SelectedPlatformName : string.Empty);
Window.Show();
}
}

View File

@@ -58,6 +58,7 @@ namespace CRSim.ViewModels
var trains = station.StationStops;
foreach (var trainNumber in trains)
{
if (trainNumber != null && trainNumber.DepartureTime != null && (ticketCheck==string.Empty || trainNumber.TicketChecks.Contains(ticketCheck)) && (platform == string.Empty || trainNumber.Platform==platform))
{
TrainInfo.Add(new TrainInfo
@@ -70,6 +71,7 @@ namespace CRSim.ViewModels
TicketChecks = trainNumber.TicketChecks,
WaitingArea = station.WaitingAreas.Where(x => x.TicketChecks.Intersect(trainNumber.TicketChecks).ToList().Count!=0).FirstOrDefault().Name,
Platform = trainNumber.Platform,
Length =trainNumber.Length,
Landmark = trainNumber.Landmark,
State = TimeSpan.Zero
});

View File

@@ -11,12 +11,47 @@
Title="StationManagementPage"
d:DesignHeight="450"
d:DesignWidth="800"
FontFamily="Microsoft YaHei"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
mc:Ignorable="d"
FontFamily="Microsoft YaHei">
>
<Page.Resources>
<converters:DateTimeToStringConverter x:Key="DateTimeToStringConverter" Format="HH:mm" />
<converters:TicketCheckConverter x:Key="TicketCheckConverter" Separator=", " />
<Style BasedOn="{StaticResource {x:Type DataGrid}}" x:Key="CustomDataGridStyle" TargetType="DataGrid">
<Setter Property="CellStyle">
<Setter.Value>
<Style TargetType="DataGridCell">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}"/>
<Setter Property="BorderBrush" Value="Transparent"/>
</Trigger>
</Style.Triggers>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</Setter.Value>
</Setter>
<Setter Property="RowStyle">
<Setter.Value>
<Style TargetType="DataGridRow">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="{DynamicResource CardStrokeColorDefaultBrush}"/>
</Trigger>
</Style.Triggers>
</Style>
</Setter.Value>
</Setter>
<Setter Property="CanUserAddRows" Value="False"/>
<Setter Property="CanUserResizeRows" Value="False"/>
<Setter Property="SelectionMode" Value="Single"/>
<Setter Property="GridLinesVisibility" Value="Vertical"/>
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="AutoGenerateColumns" Value="False"/>
<Setter Property="HeadersVisibility" Value="Column"/>
</Style>
</Page.Resources>
<Grid x:Name="ContentPagePane" Height="Auto">
@@ -84,8 +119,8 @@
</MenuItem>
</MenuItem>
</Menu>
<Border Grid.Row="1" Background="{DynamicResource SolidBackgroundFillColorBaseBrush}"
BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}" BorderThickness="1" CornerRadius="4">
<Border Grid.Row="1" Background="{DynamicResource ExpanderHeaderBackground}" CornerRadius="{DynamicResource ControlCornerRadius}"
BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}" BorderThickness="1">
<ScrollViewer VerticalAlignment="Stretch">
<ListView PreviewMouseWheel="StationsList_PreviewMouseWheel" x:Name="StationsList" ItemsSource="{Binding ViewModel.StationNames}" SelectionMode="Single">
<i:Interaction.Triggers>
@@ -143,6 +178,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
@@ -160,10 +196,14 @@
Style="{StaticResource BodyTextBlockStyle}"/>
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding ViewModel.WaitingAreaNames.Count}"
Style="{StaticResource DetailTextBlockStyle}"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text="检票口数:" Margin="0,0,12,0"
<TextBlock Grid.Row="3" Grid.Column="0" Text="检票口数:" Margin="0,0,12,12"
Style="{StaticResource BodyTextBlockStyle}"/>
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding ViewModel.TicketChecks.Count}"
Style="{StaticResource DetailTextBlockStyle}"/>
<TextBlock Grid.Row="4" Grid.Column="0" Text="站台数:" Margin="0,0,12,0"
Style="{StaticResource BodyTextBlockStyle}"/>
<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding ViewModel.Platforms.Count}"
Style="{StaticResource DetailTextBlockStyle}"/>
</Grid>
</Expander.Content>
</Expander>
@@ -234,10 +274,8 @@
</Grid>
<ScrollViewer MaxHeight="250">
<DataGrid ItemsSource="{Binding ViewModel.WaitingAreaNames}" AutoGenerateColumns="False"
CanUserAddRows="False" CanUserResizeRows="False" SelectionMode="Single"
GridLinesVisibility="Vertical" x:Name="WaitingAreasList" IsReadOnly="True"
HeadersVisibility="Column" FontFamily="Microsoft YaHei" PreviewMouseWheel="WaitingAreasList_PreviewMouseWheel">
<DataGrid Style="{StaticResource CustomDataGridStyle}" ItemsSource="{Binding ViewModel.WaitingAreaNames}"
x:Name="WaitingAreasList" PreviewMouseWheel="WaitingAreasList_PreviewMouseWheel">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding .}">
<DataGridTextColumn.Header>
@@ -245,36 +283,6 @@
</DataGridTextColumn.Header>
</DataGridTextColumn>
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#F6F6F6"/>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#F6F6F6"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
</DataGrid>
</ScrollViewer>
</StackPanel>
@@ -349,10 +357,8 @@
</Grid>
<ScrollViewer MaxHeight="250">
<DataGrid ItemsSource="{Binding ViewModel.TicketChecks}" AutoGenerateColumns="False"
CanUserAddRows="False" CanUserResizeRows="False" SelectionMode="Single"
GridLinesVisibility="Vertical" x:Name="TicketChecksList" IsReadOnly="True"
HeadersVisibility="Column" FontFamily="Microsoft YaHei" PreviewMouseWheel="TicketChecksList_PreviewMouseWheel">
<DataGrid Style="{StaticResource CustomDataGridStyle}" ItemsSource="{Binding ViewModel.TicketChecks}"
x:Name="TicketChecksList" PreviewMouseWheel="TicketChecksList_PreviewMouseWheel">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding WaitingAreaName}">
<DataGridTextColumn.Header>
@@ -365,36 +371,6 @@
</DataGridTextColumn.Header>
</DataGridTextColumn>
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#F6F6F6"/>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#F6F6F6"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
</DataGrid>
</ScrollViewer>
</StackPanel>
@@ -468,47 +444,20 @@
</Grid>
<ScrollViewer MaxHeight="250">
<DataGrid ItemsSource="{Binding ViewModel.Platforms}" AutoGenerateColumns="False"
CanUserAddRows="False" CanUserResizeRows="False" SelectionMode="Single"
GridLinesVisibility="Vertical" x:Name="PlatformsList" IsReadOnly="True"
HeadersVisibility="Column" FontFamily="Microsoft YaHei" PreviewMouseWheel="PlatformsList_PreviewMouseWheel">
<DataGrid Style="{StaticResource CustomDataGridStyle}" ItemsSource="{Binding ViewModel.Platforms}"
x:Name="PlatformsList" PreviewMouseWheel="PlatformsList_PreviewMouseWheel">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding .}">
<DataGridTextColumn Binding="{Binding Name}">
<DataGridTextColumn.Header>
<TextBlock Text="站台" Opacity="0.7" Style="{StaticResource CaptionTextBlockStyle}"/>
</DataGridTextColumn.Header>
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding Length}">
<DataGridTextColumn.Header>
<TextBlock Text="长度" Opacity="0.7" Style="{StaticResource CaptionTextBlockStyle}"/>
</DataGridTextColumn.Header>
</DataGridTextColumn>
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#F6F6F6"/>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#F6F6F6"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
</DataGrid>
</ScrollViewer>
</StackPanel>
@@ -610,16 +559,19 @@
</Menu>
</Grid>
<ScrollViewer MaxHeight="250">
<DataGrid ItemsSource="{Binding ViewModel.StationStops}" AutoGenerateColumns="False"
CanUserAddRows="False" CanUserResizeRows="False" SelectionMode="Single"
GridLinesVisibility="Vertical" x:Name="StationStopsList" IsReadOnly="True"
HeadersVisibility="Column" CanUserSortColumns="False" FontFamily="Microsoft YaHei" PreviewMouseWheel="StationStopsList_PreviewMouseWheel">
<DataGrid Style="{StaticResource CustomDataGridStyle}" ItemsSource="{Binding ViewModel.StationStops}"
x:Name="StationStopsList" PreviewMouseWheel="StationStopsList_PreviewMouseWheel">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Number}">
<DataGridTextColumn.Header>
<TextBlock Text="车次" Opacity="0.7" Style="{StaticResource CaptionTextBlockStyle}"/>
</DataGridTextColumn.Header>
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding Length}">
<DataGridTextColumn.Header>
<TextBlock Text="长度" Opacity="0.7" Style="{StaticResource CaptionTextBlockStyle}"/>
</DataGridTextColumn.Header>
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding ArrivalTime,Converter={StaticResource DateTimeToStringConverter}}">
<DataGridTextColumn.Header>
<TextBlock Text="到时" Opacity="0.7" Style="{StaticResource CaptionTextBlockStyle}"/>
@@ -656,39 +608,7 @@
</DataGridTextColumn.Header>
</DataGridTextColumn>
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#F6F6F6"/>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#F6F6F6"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
</DataGrid>
</ScrollViewer>
</StackPanel>
</Expander.Content>
@@ -711,7 +631,7 @@
<TextBlock Opacity="0.7" FontSize="12" Style="{StaticResource CaptionTextBlockStyle}">请再次检查各设施配置是否正确</TextBlock>
</StackPanel>
<Button HorizontalAlignment="Right" Margin="10" Grid.Column="2" Command="{Binding ViewModel.SaveChangesCommand}"
FontFamily="Microsoft YaHei" FontSize="14" Style="{DynamicResource AccentButtonStyle}" Content="保存配置" />
FontSize="14" Style="{DynamicResource AccentButtonStyle}" Content="保存配置" />
</Grid>
</Border>

View File

@@ -32,7 +32,14 @@
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="SelectionTextBox" TargetType="TextBox">
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="TextWrapping" Value="Wrap" />
</Style>
</Page.Resources>
<Grid>
<Grid.RowDefinitions>
@@ -326,17 +333,16 @@
</Border>
</Grid>
<TextBlock Text="关于" FontWeight="SemiBold" Margin="10" FontSize="14"/>
<Border Grid.Row="2" Background="{DynamicResource ExpanderHeaderBackground}"
BorderBrush="{DynamicResource ExpanderHeaderBorderBrush}" BorderThickness="{StaticResource ExpanderBorderThemeThickness}"
Padding="{StaticResource ExpanderPadding}" CornerRadius="{DynamicResource ControlCornerRadius}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Expander>
<Expander.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image
<Image
Grid.Column="0"
Width="20"
Height="20"
@@ -344,15 +350,80 @@
VerticalAlignment="Center"
Source="pack://application:,,,/Assets/CRSimIcon.png" />
<StackPanel
<StackPanel
Grid.Column="1"
Margin="12"
Orientation="Vertical">
<TextBlock Text="{Binding ViewModel.AppVersion}" Style="{StaticResource BodyTextBlockStyle}" />
<TextBlock Opacity="0.7" Style="{StaticResource CaptionTextBlockStyle}">© 电排骨 2025</TextBlock>
</StackPanel>
</Grid>
</Border>
<TextBlock Text="{Binding ViewModel.AppVersion}" />
<TextBlock Opacity="0.7" Style="{StaticResource CaptionTextBlockStyle}">© 电排骨 2025</TextBlock>
</StackPanel>
</Grid>
</Expander.Header>
<Expander.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Grid.Row="0" Style="{StaticResource TopSettingsCardStyle}">
<Grid Margin="48,0,16,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="克隆项目仓库" />
<TextBox Grid.Column="2" Style="{StaticResource SelectionTextBox}" Text="git clone https://github.com/denglihong2007/CRSim.git" Focusable="False"/>
</Grid>
</Border>
<Border Grid.Row="1" Style="{StaticResource SettingsCardStyle}">
<Grid Margin="48,0,16,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="报告漏洞或请求新样式" />
<Button Grid.Column="2" Padding="8" FocusManager.IsFocusScope="True" Click="Open_Issues">
<TextBlock FontFamily="{StaticResource SymbolThemeFontFamily}" Text="&#xe8a7;" />
</Button>
</Grid>
</Border>
<GroupBox Grid.Row="2" BorderThickness="0">
<Border Style="{StaticResource SettingsCardStyle}">
<StackPanel Margin="48,0,16,0" Orientation="Vertical">
<TextBlock Margin="0,0,0,12" Text="项目引用" />
<TextBlock Style="{StaticResource LinkTextBlockStyle}">
<Hyperlink Click="Open_ToolkitInformation" Style="{StaticResource DefaultHyperlinkStyle}">CommunityToolkit.Mvvm</Hyperlink>
</TextBlock>
<TextBlock Style="{StaticResource LinkTextBlockStyle}">
<Hyperlink Click="Open_DIInformation" AutomationProperties.Name="Link to Dependency Injection NuGet Package" Style="{StaticResource DefaultHyperlinkStyle}">Microsoft.Extensions.DependencyInjection</Hyperlink>
</TextBlock>
<TextBlock Style="{StaticResource LinkTextBlockStyle}">
<Hyperlink Click="Open_HostingInformation" AutomationProperties.Name="Link to .NET Generic Host Package" Style="{StaticResource DefaultHyperlinkStyle}">Microsoft.Extensions.Hosting</Hyperlink>
</TextBlock>
</StackPanel>
</Border>
</GroupBox>
<GroupBox Grid.Row="3" BorderThickness="0">
<Border Style="{StaticResource BottomSettingsCardStyle}">
<StackPanel Margin="48,0,16,0" Orientation="Vertical">
<TextBlock Margin="0,0,0,12" Text="贡献者"/>
<TextBlock
Text="wxl0430"
TextWrapping="Wrap" />
</StackPanel>
</Border>
</GroupBox>
</Grid>
</Expander.Content>
</Expander>
</StackPanel>
</ScrollViewer>
</Grid>

View File

@@ -19,5 +19,25 @@ namespace CRSim.Views
DataContext = this;
InitializeComponent();
}
private void Open_ToolkitInformation(object sender, RoutedEventArgs e)
{
Process.Start(new ProcessStartInfo("https://www.nuget.org/packages/CommunityToolkit.Mvvm/") { UseShellExecute = true });
}
private void Open_DIInformation(object sender, RoutedEventArgs e)
{
Process.Start(new ProcessStartInfo("https://www.nuget.org/packages/Microsoft.Extensions.DependencyInjection/") { UseShellExecute = true });
}
private void Open_HostingInformation(object sender, RoutedEventArgs e)
{
Process.Start(new ProcessStartInfo("https://www.nuget.org/packages/Microsoft.Extensions.Hosting") { UseShellExecute = true });
}
private void Open_Issues(object sender, RoutedEventArgs e)
{
Process.Start(new ProcessStartInfo("https://github.com/denglihong2007/CRSim/issues/new") { UseShellExecute = true });
}
}
}

View File

@@ -12,6 +12,7 @@
d:DesignHeight="450"
d:DesignWidth="800"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
FontFamily="Microsoft YaHei"
mc:Ignorable="d">
<Page.Resources>
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
@@ -96,8 +97,7 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="车站" Style="{StaticResource BodyTextBlockStyle}" VerticalAlignment="Center"/>
<ComboBox Grid.Column="2" MinWidth="128" ItemsSource="{Binding ViewModel.StationNames}" x:Name="StationsComboBox"
FontFamily="Microsoft YaHei">
<ComboBox Grid.Column="2" MinWidth="128" ItemsSource="{Binding ViewModel.StationNames}" x:Name="StationsComboBox">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding ViewModel.SelectStationCommand}"
@@ -115,8 +115,7 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="站台" Style="{StaticResource BodyTextBlockStyle}" VerticalAlignment="Center"/>
<ComboBox Grid.Column="2" MinWidth="128" ItemsSource="{Binding ViewModel.Platforms}" x:Name="PlatformsComboBox"
FontFamily="Microsoft YaHei">
<ComboBox Grid.Column="2" MinWidth="128" ItemsSource="{Binding ViewModel.Platforms}" x:Name="PlatformsComboBox" DisplayMemberPath="Name">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding ViewModel.SelectPlatformCommand}"
@@ -135,8 +134,7 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="检票口" Style="{StaticResource BodyTextBlockStyle}" VerticalAlignment="Center"/>
<ComboBox Grid.Column="2" MinWidth="128" ItemsSource="{Binding ViewModel.TicketChecks}" x:Name="TicketChecksComboBox"
FontFamily="Microsoft YaHei">
<ComboBox Grid.Column="2" MinWidth="128" ItemsSource="{Binding ViewModel.TicketChecks}" x:Name="TicketChecksComboBox">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding ViewModel.SelectTicketCheckCommand}"
@@ -153,8 +151,13 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="文字提示" Style="{StaticResource BodyTextBlockStyle}" VerticalAlignment="Center"/>
<TextBox Grid.Column="2" MaxWidth="256" MinWidth="128" FontFamily="Microsoft YaHei" Text="{Binding ViewModel.Text ,Mode=TwoWay}"/>
<StackPanel Grid.Column="0" Orientation="Vertical">
<TextBlock Text="文字提示" Style="{StaticResource BodyTextBlockStyle}"/>
<TextBlock Opacity="0.7" Style="{StaticResource CaptionTextBlockStyle}">
留空即为默认
</TextBlock>
</StackPanel>
<TextBox Grid.Column="2" MaxWidth="256" MinWidth="128" Text="{Binding ViewModel.Text ,Mode=TwoWay}"/>
</Grid>
</Border>
@@ -179,7 +182,7 @@
<TextBlock Opacity="0.7" FontSize="12" Style="{StaticResource CaptionTextBlockStyle}">按下Esc以关闭窗口</TextBlock>
</StackPanel>
<Button HorizontalAlignment="Right" Margin="10" Grid.Column="2" Command="{Binding ViewModel.StartSimulationCommand}" IsEnabled="{Binding ViewModel.IsStartSimulationAvailable}"
FontFamily="Microsoft YaHei" FontSize="14" Style="{DynamicResource AccentButtonStyle}" Content="启动窗口" />
FontSize="14" Style="{DynamicResource AccentButtonStyle}" Content="启动窗口" />
</Grid>
</Border>

View File

@@ -10,14 +10,10 @@
MinHeight="224.43" MaxHeight="224.43"
WindowStyle="None"
WindowStartupLocation="CenterOwner">
<StackPanel Background="{DynamicResource ButtonBackground}">
<StackPanel Background="{DynamicResource SolidBackgroundFillColorQuarternaryBrush}">
<TextBlock FontFamily="Microsoft YaHei" FontSize="28" Margin="24,32,0,24" Text="操作提醒"/>
<TextBlock x:Name="Notice" FontFamily="Microsoft YaHei" Margin="24,0,24,24" Style="{StaticResource BodyTextBlockStyle}"/>
<Rectangle Height="1">
<Rectangle.Fill>
<SolidColorBrush Color="#CCCCCC"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle Height="1" Fill="{DynamicResource SeparatorBorderBrush}"/>
<StackPanel Background="{DynamicResource SolidBackgroundFillColorBaseBrush}" Orientation="Horizontal">
<Button Style="{DynamicResource AccentButtonStyle}" Content="确定" FontFamily="Microsoft YaHei"
HorizontalAlignment="Stretch" Click="OkButton_Click" Margin="24,24,4,24" x:Name="AccentButton"

View File

@@ -12,10 +12,10 @@
MaxWidth="432"
WindowStyle="None"
WindowStartupLocation="CenterOwner">
<StackPanel Background="{DynamicResource ButtonBackground}">
<StackPanel Background="{DynamicResource SolidBackgroundFillColorQuarternaryBrush}">
<TextBlock x:Name="Notice" FontFamily="Microsoft YaHei" FontSize="28" Margin="24,32,0,24"/>
<TextBox KeyDown="InputTextBox_KeyDown" FontFamily="Microsoft YaHei" x:Name="InputTextBox" Margin="24,0,24,24" MinWidth="384" TextChanged="InputTextBox_TextChanged"/>
<Rectangle Height="1" Fill="#CCCCCC"/>
<Rectangle Height="1" Fill="{DynamicResource SeparatorBorderBrush}"/>
<StackPanel Background="{DynamicResource SolidBackgroundFillColorBaseBrush}" Orientation="Horizontal">
<Button Style="{DynamicResource AccentButtonStyle}" Content="确定" FontFamily="Microsoft YaHei"
HorizontalAlignment="Stretch" Click="OkButton_Click" Margin="24,24,4,24" x:Name="AccentButton"

View File

@@ -12,14 +12,10 @@
MaxWidth="432"
WindowStyle="None"
WindowStartupLocation="CenterOwner">
<StackPanel Background="{DynamicResource ButtonBackground}">
<StackPanel Background="{DynamicResource SolidBackgroundFillColorQuarternaryBrush}">
<TextBlock x:Name="Title" FontFamily="Microsoft YaHei" FontSize="28" Margin="24,32,0,20"/>
<TextBlock x:Name="Description" Style="{StaticResource BodyTextBlockStyle}" Margin="24,0,0,24"/>
<Rectangle Height="1">
<Rectangle.Fill>
<SolidColorBrush Color="#CCCCCC"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle Height="1" Fill="{DynamicResource SeparatorBorderBrush}"/>
<StackPanel Background="{DynamicResource SolidBackgroundFillColorBaseBrush}" Orientation="Horizontal" HorizontalAlignment="Stretch" FlowDirection="RightToLeft">
<Button Style="{DynamicResource AccentButtonStyle}" Content="关闭" FontFamily="Microsoft YaHei" Click="OkButton_Click" Margin="24,24,0,24" x:Name="AccentButton"
Width="170" Height="40" HorizontalAlignment="Right" FontSize="14"/>

View File

@@ -0,0 +1,44 @@
<Window x:Class="CRSim.Views.PlatformDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CRSim.Views"
mc:Ignorable="d"
Title="UserInputDialog"
MinHeight="267.91"
MinWidth="432"
MaxHeight="267.91"
MaxWidth="432"
FontFamily="Microsoft YaHei"
WindowStyle="None"
WindowStartupLocation="CenterOwner">
<StackPanel Background="{DynamicResource SolidBackgroundFillColorQuarternaryBrush}">
<TextBlock Text="添加站台" FontSize="28" Margin="24,32,0,24"/>
<Grid Margin="24,0,24,24">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="站台名" Margin="0,0,24,12" Style="{StaticResource BodyTextBlockStyle}"/>
<TextBox Grid.Row="1" Grid.Column="0" KeyDown="InputTextBox_KeyDown" x:Name="NameTextBox" Width="96"
TextChanged="InputTextBox_TextChanged" Margin="0,0,24,0"/>
<TextBlock Grid.Row="0" Grid.Column="1" Text="站台长度" Margin="0,0,24,12" Style="{StaticResource BodyTextBlockStyle}"/>
<TextBox Grid.Row="1" Grid.Column="1" KeyDown="InputTextBox_KeyDown" x:Name="LengthTextBox" Width="96"
TextChanged="InputTextBox_TextChanged" Margin="0,0,24,0" Text="20"/>
</Grid>
<Rectangle Height="1" Fill="{DynamicResource SeparatorBorderBrush}"/>
<StackPanel Background="{DynamicResource SolidBackgroundFillColorBaseBrush}" Orientation="Horizontal">
<Button Style="{DynamicResource AccentButtonStyle}" Content="确定"
HorizontalAlignment="Stretch" Click="OkButton_Click" Margin="24,24,4,24" x:Name="AccentButton"
Width="188" IsEnabled="False" Height="40"/>
<Button Content="取消"
HorizontalAlignment="Stretch" Click="CancelButton_Click" Margin="4,24,24,24"
Width="188" Height="40"/>
</StackPanel>
</StackPanel>
</Window>

View File

@@ -0,0 +1,72 @@
using CRSim.Core.Models;
namespace CRSim.Views
{
/// <summary>
/// UserInputDialog.xaml 的交互逻辑
/// </summary>
public partial class PlatformDialog : Window
{
public List<Platform> GeneratedPlatforms = [];
public PlatformDialog()
{
WindowChrome.SetWindowChrome(
this,
new WindowChrome
{
CaptionHeight = 50,
CornerRadius = default,
GlassFrameThickness = new Thickness(-1),
ResizeBorderThickness = ResizeMode == ResizeMode.NoResize ? default : new Thickness(4),
UseAeroCaptionButtons = true
}
);
InitializeComponent();
NameTextBox.Focus();
}
private void OkButton_Click(object sender, RoutedEventArgs e)
{
string[] platforms = NameTextBox.Text.Split('-');
var Length = int.Parse(LengthTextBox.Text);
if (platforms.Length == 2 && int.TryParse(platforms[0], out int startindex) && int.TryParse(platforms[1], out int endindex))
{
var startIndex = Math.Min(startindex, endindex);
var endIndex = Math.Max(startindex, endindex);
for (int i = startIndex; i < endIndex + 1; i++)
{
GeneratedPlatforms.Add(new Platform { Name = i.ToString(), Length = Length });
}
}
else
{
GeneratedPlatforms.Add(new Platform { Name = platforms[0], Length = Length });
}
DialogResult = true;
Close();
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
Close();
}
private void InputTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (AccentButton == null) return;
AccentButton.IsEnabled = !string.IsNullOrWhiteSpace(NameTextBox.Text) && !string.IsNullOrWhiteSpace(LengthTextBox.Text) && int.TryParse(LengthTextBox.Text, out int i) && i > 0;
}
private void InputTextBox_KeyDown(object sender, KeyEventArgs e)
{
if(e.Key == Key.Enter &&
!string.IsNullOrWhiteSpace(NameTextBox.Text) &&
!string.IsNullOrWhiteSpace(LengthTextBox.Text) && int.TryParse(LengthTextBox.Text, out int i) && i > 0)
{
OkButton_Click(null, null);
}
return;
}
}
}

View File

@@ -7,9 +7,9 @@
mc:Ignorable="d"
Title="StationStopDialog"
WindowStyle="None" FontFamily="Microsoft YaHei"
MinWidth="562" MaxWidth="562" MinHeight="546.77" MaxHeight="546.77"
SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterOwner">
<Grid Background="{DynamicResource ButtonBackground}">
<Grid Background="{DynamicResource SolidBackgroundFillColorQuarternaryBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
@@ -32,27 +32,23 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource BodyTextBlockStyle}" Text="车次" Margin="0,0,0,12"/>
<TextBox Grid.Row="1" Grid.Column="0" x:Name="NumberTextBox" Width="96" HorizontalAlignment="Left" Margin="0,0,0,16" TextChanged="NumberTextBox_TextChanged"/>
<TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource BodyTextBlockStyle}" Text="站台" Margin="24,0,0,12"/>
<ComboBox Grid.Row="1" Grid.Column="1" x:Name="PlatformComboBox" Width="96" HorizontalAlignment="Left" Margin="24,0,0,16" SelectedIndex="0" ItemsSource="{Binding Platforms}"/>
<TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource BodyTextBlockStyle}" Text="长度" Margin="24,0,0,12"/>
<TextBox Grid.Row="1" Grid.Column="1" x:Name="LengthTextBox" Width="96" HorizontalAlignment="Left" Margin="24,0,0,16" TextChanged="NumberTextBox_TextChanged"/>
<TextBlock Grid.Row="3" Grid.Column="0" Style="{StaticResource BodyTextBlockStyle}" Text="站台" Margin="0,0,0,12"/>
<ComboBox Grid.Row="4" Grid.Column="0" x:Name="PlatformComboBox" Width="96" HorizontalAlignment="Left" Margin="0,0,0,16" SelectedIndex="0" ItemsSource="{Binding Platforms}"/>
<TextBlock Grid.Row="0" Grid.Column="2" Style="{StaticResource BodyTextBlockStyle}" Text="地标" Margin="24,0,0,12"/>
<ComboBox Grid.Row="1" Grid.Column="2" x:Name="LandmarkComboBox" Width="96" HorizontalAlignment="Left" Margin="24,0,0,16" SelectedIndex="0" ItemsSource="{Binding Landmarks}"/>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource BodyTextBlockStyle}" Text="始发站" Margin="0,0,0,12"/>
<TextBox Grid.Row="1" Grid.Column="0" x:Name="DepartureTextBox" Width="96" HorizontalAlignment="Left" Margin="0,0,0,16" TextChanged="NumberTextBox_TextChanged"/>
<TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource BodyTextBlockStyle}" Text="终到站" Margin="24,0,0,12"/>
<TextBox Grid.Row="1" Grid.Column="1" x:Name="ArrivalTextBox" Width="96" HorizontalAlignment="Left" Margin="24,0,0,16" TextChanged="NumberTextBox_TextChanged"/>
<TextBlock Grid.Row="3" Grid.Column="1" Style="{StaticResource BodyTextBlockStyle}" Text="始发站" Margin="24,0,0,12"/>
<TextBox Grid.Row="4" Grid.Column="1" x:Name="DepartureTextBox" Width="96" HorizontalAlignment="Left" Margin="24,0,0,16" TextChanged="NumberTextBox_TextChanged"/>
<TextBlock Grid.Row="3" Grid.Column="2" Style="{StaticResource BodyTextBlockStyle}" Text="终到站" Margin="24,0,0,12"/>
<TextBox Grid.Row="4" Grid.Column="2" x:Name="ArrivalTextBox" Width="96" HorizontalAlignment="Left" Margin="24,0,0,16" TextChanged="NumberTextBox_TextChanged"/>
</Grid>
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="站点类型" Margin="0,0,0,12"/>
<StackPanel x:Name="StationKindPanel" Orientation="Horizontal" Margin="0,0,0,16">
@@ -84,8 +80,8 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Style="{StaticResource BodyTextBlockStyle}" Text="检票口" Margin="0,0,0,12"/>
<Border Grid.Row="1" Background="{DynamicResource SolidBackgroundFillColorBaseBrush}"
BorderBrush="#EAEAEA" BorderThickness="1" CornerRadius="4" Width="154" Height="310.336">
<Border Grid.Row="1" Background="{DynamicResource ExpanderHeaderBackground}" CornerRadius="{DynamicResource ControlCornerRadius}"
BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}" BorderThickness="1" Width="154" Height="300">
<ScrollViewer VerticalAlignment="Stretch">
<ListView PreviewMouseWheel="TicketChecksCheckList_PreviewMouseWheel" x:Name="TicketChecksCheckList" ItemsSource="{Binding TicketChecksList}">
<ListView.ItemTemplate>
@@ -99,12 +95,7 @@
</Border>
</Grid>
</Grid>
<Rectangle Grid.Row="2" Height="1">
<Rectangle.Fill>
<SolidColorBrush Color="#CCCCCC"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="2" Height="1" Fill="{DynamicResource SeparatorBorderBrush}"/>
<Grid Grid.Row="3" HorizontalAlignment="Stretch" Background="{DynamicResource SolidBackgroundFillColorBaseBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>

View File

@@ -37,6 +37,7 @@ namespace CRSim.Views
);
InitializeComponent();
IntermediateStation.IsChecked = true;
LengthTextBox.Text = "16";
TicketChecksList.Clear();
foreach (string s in ticketChecks)
{
@@ -72,6 +73,7 @@ namespace CRSim.Views
NumberTextBox.Text = stationStop.Number;
ArrivalTextBox.Text = stationStop.Terminal;
DepartureTextBox.Text = stationStop.Origin;
LengthTextBox.Text = stationStop.Length.ToString();
StationKindPanel.IsEnabled = false;
if (stationStop.ArrivalTime != null)
{
@@ -124,6 +126,7 @@ namespace CRSim.Views
DepartureTime = EndHour.IsEnabled ? DateTime.Parse($"{EndHour.Text}:{EndMinute.Text}") : null,
TicketChecks = TicketChecksList.Where(x => x.Checked).Select(x => x.TicketCheck).ToList(),
Platform = (string)PlatformComboBox.SelectedItem,
Length = int.Parse(LengthTextBox.Text),
Landmark = (string)LandmarkComboBox.SelectedItem == "无" ? null: (string)LandmarkComboBox.SelectedItem,
};
DialogResult = true;
@@ -189,7 +192,13 @@ namespace CRSim.Views
(!EndMinute.IsEnabled || ValidateTime(EndMinute.Text, 60));
// 当所有条件满足时,启用 AccentButton
AccentButton.IsEnabled = areTextBoxesFilled && !string.IsNullOrWhiteSpace(NumberTextBox.Text) && !string.IsNullOrWhiteSpace(ArrivalTextBox.Text) && !string.IsNullOrWhiteSpace(DepartureTextBox.Text) && PlatformComboBox.SelectedItem!=null;
AccentButton.IsEnabled =
areTextBoxesFilled &&
!string.IsNullOrWhiteSpace(NumberTextBox.Text) &&
!string.IsNullOrWhiteSpace(ArrivalTextBox.Text) &&
!string.IsNullOrWhiteSpace(DepartureTextBox.Text) &&
int.TryParse(LengthTextBox.Text,out int i) && i > 0 &&
PlatformComboBox.SelectedItem != null;
}
private T FindVisualChild<T>(DependencyObject obj) where T : DependencyObject

View File

@@ -11,7 +11,7 @@
MinWidth="432" MinHeight="272.91"
MaxWidth="432" MaxHeight="272.91"
WindowStartupLocation="CenterOwner">
<Grid Background="{DynamicResource ButtonBackground}">
<Grid Background="{DynamicResource SolidBackgroundFillColorQuarternaryBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
@@ -33,11 +33,7 @@
<TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource BodyTextBlockStyle}" Text="检票口" Margin="24,0,0,0"/>
<TextBox Grid.Row="1" Grid.Column="1" x:Name="TicketCheckInputBox" Width="128" Margin="24,0,0,0" TextChanged="InputTextBox_TextChanged" KeyDown="InputTextBox_KeyDown"/>
</Grid>
<Rectangle Grid.Row="2" Height="1">
<Rectangle.Fill>
<SolidColorBrush Color="#CCCCCC"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="2" Height="1" Fill="{DynamicResource SeparatorBorderBrush}"/>
<Grid Grid.Row="3" HorizontalAlignment="Stretch" Background="{DynamicResource SolidBackgroundFillColorBaseBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>

View File

@@ -10,7 +10,7 @@
MinWidth="432" MinHeight="468.82"
MaxWidth="432" MaxHeight="468.82"
WindowStartupLocation="CenterOwner">
<Grid Background="{DynamicResource ButtonBackground}">
<Grid Background="{DynamicResource SolidBackgroundFillColorQuarternaryBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
@@ -51,11 +51,8 @@
</StackPanel>
</Grid>
<Rectangle Grid.Row="2" Height="1">
<Rectangle.Fill>
<SolidColorBrush Color="#CCCCCC"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle Grid.Row="2" Height="1" Fill="{DynamicResource SeparatorBorderBrush}"/>
<Grid Grid.Row="3" HorizontalAlignment="Stretch" Background="{DynamicResource SolidBackgroundFillColorBaseBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>

View File

@@ -128,7 +128,7 @@
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding TrainNumber,Converter={StaticResource NumberToStringConverter}}">
<DataGridTextColumn Binding="{Binding Length,Converter={StaticResource NumberToStringConverter}}">
<DataGridTextColumn.HeaderTemplate>
<DataTemplate>
<TextBlock Text="车厢" Padding="2" HorizontalAlignment="Stretch" TextAlignment="Center" Background="#0036DF" Width="145"/>