From be170275a6b35b269259f4f2a49204ed60439f2c Mon Sep 17 00:00:00 2001 From: denglihong2007 <98096191+denglihong2007@users.noreply.github.com> Date: Sat, 31 Jan 2026 22:02:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=81=9C=E7=AB=99?= =?UTF-8?q?=E8=BD=A6=E6=AC=A1=E8=87=AA=E5=8A=A8=E5=8B=BE=E9=80=89=E6=A3=80?= =?UTF-8?q?=E7=A5=A8=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/DialogContents/TrainStopDialog.xaml | 16 +++--- .../DialogContents/TrainStopDialog.xaml.cs | 54 +++++++++++++------ 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/CRSim/Views/DialogContents/TrainStopDialog.xaml b/CRSim/Views/DialogContents/TrainStopDialog.xaml index f355c74..cd08d30 100644 --- a/CRSim/Views/DialogContents/TrainStopDialog.xaml +++ b/CRSim/Views/DialogContents/TrainStopDialog.xaml @@ -69,14 +69,18 @@ - - - - - + + + + + + + + - + diff --git a/CRSim/Views/DialogContents/TrainStopDialog.xaml.cs b/CRSim/Views/DialogContents/TrainStopDialog.xaml.cs index 837bbae..b392449 100644 --- a/CRSim/Views/DialogContents/TrainStopDialog.xaml.cs +++ b/CRSim/Views/DialogContents/TrainStopDialog.xaml.cs @@ -1,4 +1,6 @@ -namespace CRSim.Views.DialogContents; +using System.Text.RegularExpressions; + +namespace CRSim.Views.DialogContents; public sealed partial class TrainStopDialog : Page { public TrainStop GeneratedTrainStop; @@ -11,6 +13,8 @@ public sealed partial class TrainStopDialog : Page private readonly Action _onValidityChanged; + private TrainStop originalTrainStop = new TrainStop(); + public TrainStopDialog(List waitingAreas, List platforms, Action onValidityChanged) { WaitingAreas = waitingAreas; @@ -20,7 +24,7 @@ public sealed partial class TrainStopDialog : Page } InitializeComponent(); _onValidityChanged = onValidityChanged; - Validate(null, null); + Validate(this, EventArgs.Empty); } public TrainStopDialog(List waitingAreas, List platforms, TrainStop trainStop, Action onValidityChanged) { @@ -67,15 +71,7 @@ public sealed partial class TrainStopDialog : Page { StatusTextBox.Text = trainStop.Status.Value.TotalMinutes.ToString(); } - if (trainStop.TicketCheckIds != null) - { - foreach (var id in trainStop.TicketCheckIds) - { - //WaitingAreasList.SelectedItems.Add(waitingAreas.SelectMany(x => x.TicketChecks).FirstOrDefault(x => x.Id == id)); - } - } - - Validate(null, null); + originalTrainStop = trainStop; } private static bool ValidateTime(string input, int maxValue) { @@ -108,19 +104,19 @@ public sealed partial class TrainStopDialog : Page private void StartHour_TextChanged(object sender, TextChangedEventArgs e) { - Validate(null, null); + Validate(this, EventArgs.Empty); if (StartHour.Text.Length == 2) StartMinute.Focus(FocusState.Programmatic); } private void StartMinute_TextChanged(object sender, TextChangedEventArgs e) { - Validate(null, null); + Validate(this, EventArgs.Empty); if (StartMinute.Text.Length == 2) EndHour.Focus(FocusState.Programmatic); } private void EndHour_TextChanged(object sender, TextChangedEventArgs e) { - Validate(null, null); + Validate(this, EventArgs.Empty); if (EndHour.Text.Length == 2) EndMinute.Focus(FocusState.Programmatic); } public void GenerateTrainStop() @@ -172,7 +168,35 @@ public sealed partial class TrainStopDialog : Page WaitingAreasList.IsEnabled = false; break; } - Validate(null, null); + Validate(this, EventArgs.Empty); } } + + private void WaitingAreasList_Loaded(object sender, RoutedEventArgs e) + { + if (originalTrainStop.TicketCheckIds != null) + { + WaitingAreasList.SelectedItems.Clear(); + foreach (var area in WaitingAreas) + { + var matchedChecks = area.TicketChecks + .Where(tc => originalTrainStop.TicketCheckIds.Contains(tc.Id)) + .ToList(); + + if (matchedChecks.Count != 0) + { + if (matchedChecks.Count == area.TicketChecks.Count) + { + WaitingAreasList.SelectedItems.Add(area); + } + foreach (var check in matchedChecks) + { + WaitingAreasList.SelectedItems.Add(check); + } + } + } + Validate(this, EventArgs.Empty); + } + + } } \ No newline at end of file