Skip to content

Commit

Permalink
Check for vehicle count during removal.
Browse files Browse the repository at this point in the history
  • Loading branch information
dodo0822 committed Jan 11, 2021
1 parent af15ed7 commit 2295565
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions LocoSwap.Language/Resources/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions LocoSwap.Language/Resources/Resources.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@
<data name="msg_cannot_load_vehicle" xml:space="preserve">
<value>Fahrzeug "{0}" kann nicht geladen werden!</value>
</data>
<data name="msg_consist_empty" xml:space="preserve">
<value>Es muss mindestens ein Fahrzeug nach der Entfernung geben.</value>
</data>
<data name="msg_error" xml:space="preserve">
<value>Fehler</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions LocoSwap.Language/Resources/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@
<data name="msg_cannot_load_vehicle" xml:space="preserve">
<value>Could not load vehicle "{0}"!</value>
</data>
<data name="msg_consist_empty" xml:space="preserve">
<value>The consist must contain at least one vehicle after the removal!</value>
</data>
<data name="msg_error" xml:space="preserve">
<value>Error</value>
</data>
Expand Down
10 changes: 10 additions & 0 deletions LocoSwap/ScenarioEditWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@ private void RemoveButton_Click(object sender, RoutedEventArgs e)
}

Consist consist = (Consist)ConsistListBox.SelectedItem;

if (consist.Vehicles.Count == VehicleListBox.SelectedItems.Count)
{
MessageBox.Show(
LocoSwap.Language.Resources.msg_consist_empty,
LocoSwap.Language.Resources.msg_message,
MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}

foreach (ScenarioVehicle vehicle in VehicleListBox.SelectedItems)
{
ViewModel.Scenario.RemoveVehicle(consist.Idx, vehicle.Idx);
Expand Down

0 comments on commit 2295565

Please sign in to comment.