From 2d8a895e9f4ce406740c12edc14c01e75ccbd7a2 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Fri, 13 Oct 2023 09:53:04 +0200 Subject: [PATCH] bugfix enable controls correctly on dialog load --- src/BreCalClient/EditShipcallControl.xaml.cs | 52 ++++++++++---------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/src/BreCalClient/EditShipcallControl.xaml.cs b/src/BreCalClient/EditShipcallControl.xaml.cs index acc8fc0..1e4a6d5 100644 --- a/src/BreCalClient/EditShipcallControl.xaml.cs +++ b/src/BreCalClient/EditShipcallControl.xaml.cs @@ -90,31 +90,10 @@ namespace BreCalClient this.EnableControls(); } - #endregion - - #region Context menu handlers - - private void contextMenuItemClearAgency_Click(object sender, RoutedEventArgs e) - { - this.comboBoxAgency.SelectedIndex = -1; - this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.AGENCY); - } - - private void contextMenuItemArrivalBerth_Click(object sender, RoutedEventArgs e) - { - this.comboBoxArrivalBerth.SelectedIndex = -1; - this.ShipcallModel.Berth = ""; - } - - private void contextMenuItemDepartureBerth_Click(object sender, RoutedEventArgs e) - { - this.comboBoxDepartureBerth.SelectedIndex -= 1; - } - - private void comboBoxCategories_SelectionChanged(object sender, SelectionChangedEventArgs e) + private void comboBoxCategories_SelectionChanged(object? sender, SelectionChangedEventArgs? e) { TypeEnum? type = this.comboBoxCategories.SelectedItem as TypeEnum?; - if(type != null) + if (type != null) { switch (type) { @@ -146,6 +125,27 @@ namespace BreCalClient #endregion + #region Context menu handlers + + private void contextMenuItemClearAgency_Click(object sender, RoutedEventArgs e) + { + this.comboBoxAgency.SelectedIndex = -1; + this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.AGENCY); + } + + private void contextMenuItemArrivalBerth_Click(object sender, RoutedEventArgs e) + { + this.comboBoxArrivalBerth.SelectedIndex = -1; + this.ShipcallModel.Berth = ""; + } + + private void contextMenuItemDepartureBerth_Click(object sender, RoutedEventArgs e) + { + this.comboBoxDepartureBerth.SelectedIndex -= 1; + } + + #endregion + #region private methods private void CopyToModel() @@ -184,7 +184,8 @@ namespace BreCalClient // get port authority from berth int? berthId = this.ShipcallModel.Shipcall.ArrivalBerthId; - if (berthId == null) berthId = this.ShipcallModel.Shipcall.DepartureBerthId; + berthId ??= this.ShipcallModel.Shipcall.DepartureBerthId; + if (berthId != null) { Berth? selectedBerth = BreCalLists.Berths.Find((x) => x.Id == berthId); @@ -266,8 +267,9 @@ namespace BreCalClient this.datePickerETA.IsEnabled = isAgency || isBsmd; this.datePickerETD.IsEnabled = isAgency; - this.labelBSMDGranted.Visibility = editRightGrantedForBSMD ? Visibility.Visible : Visibility.Hidden; + + this.comboBoxCategories_SelectionChanged(null, null); } #endregion