diff --git a/src/BreCalClient/EditTimesControl.xaml.cs b/src/BreCalClient/EditTimesControl.xaml.cs index b09a40e..09d421d 100644 --- a/src/BreCalClient/EditTimesControl.xaml.cs +++ b/src/BreCalClient/EditTimesControl.xaml.cs @@ -7,6 +7,7 @@ using BreCalClient.misc.Model; using System; using System.Windows; using System.Windows.Media.Imaging; +using Xceed.Wpf.Toolkit; namespace BreCalClient { @@ -27,7 +28,9 @@ namespace BreCalClient #region Properties - public Times Times { get; set; } = new(); + public Times Times { get; set; } = new(); + + public Times? AgencyTimes { get; set; } = new(); public ShipcallControlModel ShipcallModel { get; set; } = new(); @@ -36,9 +39,9 @@ namespace BreCalClient #region event handler private void Window_Loaded(object sender, RoutedEventArgs e) - { - this.CopyToControls(); + { this.EnableControls(); + this.CopyToControls(); } private void buttonOK_Click(object sender, RoutedEventArgs e) @@ -93,7 +96,20 @@ namespace BreCalClient { this.textBoxRemarks.Text = this.Times.Remarks; this.datePickerETABerth.Value = this.Times.EtaBerth; + if(this.datePickerETABerth.IsEnabled && (this.Times.EtaBerth == null) && (this.AgencyTimes?.EtaBerth != null) && (ShipcallModel.Shipcall?.Type == ShipcallType.Arrival)) + { + this.datePickerETABerth.Value = this.AgencyTimes.EtaBerth; + WatermarkTextBox? tb = this.datePickerETABerth.Template.FindName("PART_TextBox", this.datePickerETABerth) as WatermarkTextBox; + if (tb != null) { tb.Focus(); tb.SelectAll(); } + } this.datePickerETDBerth.Value = this.Times.EtdBerth; + if(this.datePickerETDBerth.IsEnabled && (this.Times.EtdBerth == null) && (this.AgencyTimes?.EtdBerth != null) && ((ShipcallModel.Shipcall?.Type == ShipcallType.Departure) || (ShipcallModel.Shipcall?.Type == ShipcallType.Shifting))) + { + this.datePickerETDBerth.Value = this.AgencyTimes.EtdBerth; + WatermarkTextBox? tb = this.datePickerETDBerth.Template.FindName("PART_TextBox", this.datePickerETDBerth) as WatermarkTextBox; + if (tb != null) tb.SelectAll(); + } + this.datePickerLockTime.Value = this.Times.LockTime; this.datePickerZoneEntry.Value = this.Times.ZoneEntry; this.datePickerATA.Value = this.Times.Ata; diff --git a/src/BreCalClient/MainWindow.xaml.cs b/src/BreCalClient/MainWindow.xaml.cs index 38aa748..8c79de2 100644 --- a/src/BreCalClient/MainWindow.xaml.cs +++ b/src/BreCalClient/MainWindow.xaml.cs @@ -854,10 +854,14 @@ namespace BreCalClient if( obj.ShipcallControlModel == null) { return; } if (!obj.ShipcallControlModel.AssignedParticipants.ContainsKey(participantType)) return; // no assigment means no dialog my friend + Times? agencyTimes = obj.ShipcallControlModel.GetTimesForParticipantType(ParticipantType.AGENCY); + // show a dialog that lets the user create / update times for the given shipcall IEditTimesControl etc = (participantType == ParticipantType.TERMINAL) ? new EditTimesTerminalControl() : new EditTimesControl(); etc.Title = obj.ShipcallControlModel.Title; etc.ShipcallModel = obj.ShipcallControlModel; + if (etc is EditTimesControl control) + control.AgencyTimes = agencyTimes; bool wasEdit = false; if (times != null)