From 0420b1bd71d6524e02f3d095abf140b99858eab7 Mon Sep 17 00:00:00 2001 From: denglihong2007 <98096191+denglihong2007@users.noreply.github.com> Date: Sat, 22 Nov 2025 22:59:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BD=A6=E7=AB=99=E8=BD=A6=E6=AC=A1?= =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CRSim/CRSim.csproj | 2 +- CRSim/ViewModels/StationManagementPageViewModel.cs | 13 +++++++++++++ CRSim/Views/StationManagementPage.xaml | 10 +++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CRSim/CRSim.csproj b/CRSim/CRSim.csproj index eeee04d..facf08f 100644 --- a/CRSim/CRSim.csproj +++ b/CRSim/CRSim.csproj @@ -45,7 +45,7 @@ - + diff --git a/CRSim/ViewModels/StationManagementPageViewModel.cs b/CRSim/ViewModels/StationManagementPageViewModel.cs index 8eb3c0b..b92717d 100644 --- a/CRSim/ViewModels/StationManagementPageViewModel.cs +++ b/CRSim/ViewModels/StationManagementPageViewModel.cs @@ -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 Platforms { get; private set; } = []; public ObservableCollection TrainStops { get; private set; } = []; + public ObservableCollection FilteredTrainStops =>[.. TrainStops.Where(x => x.Number.ToUpper().Contains(SearchTrainNumberText.ToUpper()))]; private readonly IDatabaseService _databaseService = App.AppHost.Services.GetService(); @@ -37,6 +41,8 @@ public partial class StationManagementPageViewModel : ObservableObject private readonly INetworkService _networkService = App.AppHost.Services.GetService(); 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() { diff --git a/CRSim/Views/StationManagementPage.xaml b/CRSim/Views/StationManagementPage.xaml index ecec83b..d0ba63b 100644 --- a/CRSim/Views/StationManagementPage.xaml +++ b/CRSim/Views/StationManagementPage.xaml @@ -167,8 +167,16 @@ + + + + + + + - +