mirror of
https://github.com/denglihong2007/CRSim
synced 2026-08-07 10:05:49 +08:00
@@ -45,7 +45,7 @@
|
||||
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.2.250402" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.2.250402" />
|
||||
<PackageReference Include="CommunityToolkit.WinUI.Converters" Version="8.2.250402" />
|
||||
<PackageReference Include="CRSim.WebsiteSimulator" Version="2.3.109" />
|
||||
<PackageReference Include="CRSim.WebsiteSimulator" Version="3.1.2" />
|
||||
<PackageReference Include="EPPlus" Version="8.0.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.8" />
|
||||
|
||||
@@ -14,6 +14,9 @@ public partial class StationManagementPageViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
public partial string SearchText { get; set; } = "";
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string SearchTrainNumberText { get; set; } = "";
|
||||
|
||||
[ObservableProperty]
|
||||
public partial bool IsSelected { get; set; } = false;
|
||||
|
||||
@@ -29,6 +32,7 @@ public partial class StationManagementPageViewModel : ObservableObject
|
||||
public ObservableCollection<Platform> Platforms { get; private set; } = [];
|
||||
|
||||
public ObservableCollection<TrainStop> TrainStops { get; private set; } = [];
|
||||
public ObservableCollection<TrainStop> FilteredTrainStops =>[.. TrainStops.Where(x => x.Number.ToUpper().Contains(SearchTrainNumberText.ToUpper()))];
|
||||
|
||||
private readonly IDatabaseService _databaseService = App.AppHost.Services.GetService<IDatabaseService>();
|
||||
|
||||
@@ -37,6 +41,8 @@ public partial class StationManagementPageViewModel : ObservableObject
|
||||
private readonly INetworkService _networkService = App.AppHost.Services.GetService<INetworkService>();
|
||||
public StationManagementPageViewModel()
|
||||
{
|
||||
TrainStops.CollectionChanged += (sender, e) =>
|
||||
OnPropertyChanged(nameof(FilteredTrainStops));
|
||||
RefreshStations();
|
||||
}
|
||||
private void UpdateInfoItems()
|
||||
@@ -87,6 +93,7 @@ public partial class StationManagementPageViewModel : ObservableObject
|
||||
WaitingAreas.Clear();
|
||||
Platforms.Clear();
|
||||
TrainStops.Clear();
|
||||
SearchTrainNumberText = string.Empty;
|
||||
if (args is SelectionChangedEventArgs selectedStation && selectedStation.AddedItems.Count > 0)
|
||||
{
|
||||
SelectedStation = _databaseService.GetStationByName(selectedStation.AddedItems[0].ToString());
|
||||
@@ -352,6 +359,12 @@ public partial class StationManagementPageViewModel : ObservableObject
|
||||
#endregion
|
||||
|
||||
#region TrainStop
|
||||
[RelayCommand]
|
||||
public void SearchTrainNumber()
|
||||
{
|
||||
OnPropertyChanged(nameof(FilteredTrainStops));
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public async Task ImportFromTrainNumbers()
|
||||
{
|
||||
|
||||
@@ -167,8 +167,16 @@
|
||||
<AppBarButton Label="从车次数据库导入" Command="{x:Bind ViewModel.ImportFromTrainNumbersCommand}" />
|
||||
</CommandBar.SecondaryCommands>
|
||||
</CommandBar>
|
||||
<AutoSuggestBox PlaceholderText="搜索车次" QueryIcon="Find" Text="{x:Bind ViewModel.SearchTrainNumberText,Mode=TwoWay}"
|
||||
Margin="0,8,0,0" HorizontalAlignment="Stretch">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<interactivity:EventTriggerBehavior EventName="TextChanged">
|
||||
<interactivity:InvokeCommandAction Command="{x:Bind ViewModel.SearchTrainNumberCommand}" />
|
||||
</interactivity:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</AutoSuggestBox>
|
||||
<Border Style="{StaticResource ListViewBorder}" Margin="0,8,0,0">
|
||||
<ListView x:Name="TrainStopsList" ItemsSource="{x:Bind ViewModel.TrainStops}" MaxHeight="300">
|
||||
<ListView x:Name="TrainStopsList" ItemsSource="{x:Bind ViewModel.FilteredTrainStops,Mode=OneWay}" MaxHeight="300">
|
||||
<ListView.Header>
|
||||
<Grid Padding="16,12" ColumnSpacing="16">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
||||
Reference in New Issue
Block a user